diff options
author | KatolaZ <katolaz@freaknet.org> | 2019-08-01 11:26:12 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2019-08-01 11:26:12 +0100 |
commit | 08485aacd8d561f2650175b7a16211262396b2ce (patch) | |
tree | dda64aa4e35020ee230d53bcf1aa0e66c8fdd1c6 /draw.c | |
parent | f660595c236a21555d3558dd51afae4a67d651a3 (diff) |
add undo in erase mode
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -168,7 +168,6 @@ update_box: void draw_arrow(int x, int y, char *a, int a_len, int fix){ - /* FIXME: copy affected lines to undo */ int i, j, cur_dir; char line; void (*f)(int, int, char); @@ -285,13 +284,24 @@ void erase(FILE *fc){ /*FIXME: add affected lines to undo */ char c; int orig_x = x, orig_y = y; + char first = 1, opened = 0; status_bar(); show_cursor(); - invalidate_undo(); while((c=fgetc(fc))!=EOF && c!=27 && c!= 'x' && c != '\n'){ if (!move_around(c, fc)) continue; check_bound(); + if (first || + (y != orig_y && ! opened) || + (y == orig_y && x != orig_x && !opened) ){ + copy_lines_to_ring(MIN(y, orig_y), MAX(y, orig_y), PRV_STATE); + first = 0; + opened = 1; + } do_erase(orig_x, orig_y); + if (y != orig_y && opened){ + copy_lines_to_ring(MIN(y, orig_y), MAX(y, orig_y), NEW_STATE); + opened = 0; + } step = 1; modified = 1; orig_x = x; @@ -300,6 +310,8 @@ void erase(FILE *fc){ status_bar(); show_cursor(); } + if (opened) + copy_lines_to_ring(y, y, NEW_STATE); mode = MOVE; } |