diff options
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -112,7 +112,7 @@ void draw_box(int x1, int y1, int fix){ if (fix == FIX){ f = set_xy; - copy_lines_to_ring(ymin, ymax, CUR); + copy_lines_to_ring(ymin, ymax, PRV_STATE); } else f = draw_xy; @@ -130,7 +130,7 @@ void draw_box(int x1, int y1, int fix){ f(xmax, ymin, corner); f(xmax, ymax, corner); if (fix == FIX) - copy_lines_to_ring(ymin, ymax, LST); + copy_lines_to_ring(ymin, ymax, NEW_STATE); show_cursor(); } @@ -316,10 +316,10 @@ void visual_box(FILE *fc){ case 'x':/* erase */ if (c == 'x') yank_region(MIN(orig_x,x), MIN(orig_y,y), MAX(orig_x, x), MAX(orig_y, y)); - copy_lines_to_ring(MIN(orig_y, y), MAX(orig_y, y), CUR); + copy_lines_to_ring(MIN(orig_y, y), MAX(orig_y, y), PRV_STATE); erase_box(orig_x, orig_y, f); erase_blank_lines(MIN(y,orig_y), MAX(y, orig_y)); - copy_lines_to_ring(MIN(orig_y, y), MAX(orig_y, y), LST); + copy_lines_to_ring(MIN(orig_y, y), MAX(orig_y, y), NEW_STATE); modified = 1; goto vis_exit; @@ -345,9 +345,9 @@ void paste(){ int y2; y2 = y + cutbuf.num - 1; - copy_lines_to_ring(y, y2, CUR); + copy_lines_to_ring(y, y2, PRV_STATE); paste_region(x, y); - copy_lines_to_ring(y, y2, LST); + copy_lines_to_ring(y, y2, NEW_STATE); redraw(); } @@ -356,28 +356,32 @@ void put_lines(lineset_t *u){ for (i=0; i< u->num; i++){ n = u->l[i].n; - ensure_line_length(&(screen.l[i]), u->l[i].lst); + ensure_line_length(&(screen.l[i]), strlen(u->l[i].s)); strcpy(screen.l[n].s, u->l[i].s); - screen.l[n].lst = u->l[i].lst; + screen.l[n].lst = strlen(u->l[i].s)-1; } } void undo_change(){ if (undo_cur >= 0){ + if (undo_cur > undo_lst) + undo_cur = undo_lst; put_lines(& (undo[undo_cur])); - undo_cur --; + undo_cur -= 2; + modified = 1; } redraw(); - modified = 1; } void redo_change(){ - if (undo_cur < undo_lst){ - undo_cur ++; - put_lines(& (undo[undo_cur])); + if (undo_cur <= undo_lst-2){ + if (undo_cur > 0) + put_lines(& (undo[undo_cur+1])); + undo_cur +=2; + put_lines(& (undo[undo_cur+1])); + modified = 1; } redraw(); - modified = 1; } |