summaryrefslogtreecommitdiff
path: root/draw.c
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-08-01 11:26:12 +0100
committerKatolaZ <katolaz@freaknet.org>2019-08-01 11:26:12 +0100
commit08485aacd8d561f2650175b7a16211262396b2ce (patch)
treedda64aa4e35020ee230d53bcf1aa0e66c8fdd1c6 /draw.c
parentf660595c236a21555d3558dd51afae4a67d651a3 (diff)
add undo in erase mode
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/draw.c b/draw.c
index bc6657d..ae90458 100644
--- a/draw.c
+++ b/draw.c
@@ -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;
}