diff options
author | KatolaZ <katolaz@freaknet.org> | 2019-08-08 08:39:04 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2019-08-08 08:39:04 +0100 |
commit | c16e74036e791b2c1f9c19841fc75a60067aefec (patch) | |
tree | 50357c892796256d0acdc233641576d07afcf085 /draw.c | |
parent | 9127db5e322c1b0cd57adf90e8cfefad66020fe2 (diff) |
fix bug with global movements in arrow mode
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -148,7 +148,7 @@ void get_box(FILE *fc){ while((c=fgetc(fc))!=EOF && c != 27 && c!= 'b' && c != '\n'){ if (change_style(c)) goto update_box; - if (!move_around(c, fc)) + if (!move_around(c, fc, 1)) continue; check_bound(&x, &y); redraw(); @@ -166,7 +166,7 @@ update_box: mode = MOVE; } -void draw_arrow(int xl, int yl, char *a, int a_len, int fix){ +void draw_arrow(int xl, int yl, short *a, int a_len, int fix){ int i, j, cur_dir; char line; @@ -218,12 +218,12 @@ void get_arrow(FILE *fc){ char c; int orig_x=x, orig_y=y, arrow_len; - static char *arrow = NULL; + static short *arrow = NULL; static int arrow_sz; if (!arrow){ arrow_sz = 100; - arrow = malloc(arrow_sz * sizeof(char)); + arrow = malloc(arrow_sz * sizeof(short)); } arrow_len = 0; dir = DIR_N; @@ -234,17 +234,19 @@ void get_arrow(FILE *fc){ while((c=fgetc(fc))!=EOF && c != 27 && c!= 'a' && c != '\n'){ if (change_style(c)) goto update_arrow; - if (!move_around(c, fc)) + if (!move_around(c, fc, 0)) continue; check_bound(&x, &y); /* FIXME: if we are out of bound, do nothing? */ if (arrow_len == arrow_sz){ arrow_sz *=2; - arrow = realloc(arrow, arrow_sz * sizeof(char)); + arrow = realloc(arrow, arrow_sz * sizeof(short)); } - arrow[arrow_len++] = dir; - arrow[arrow_len++] = step; - redraw(); + if (dir != DIR_N){ + arrow[arrow_len++] = dir; + arrow[arrow_len++] = step; + } + redraw(); step = 1; update_arrow: draw_arrow(orig_x, orig_y, arrow, arrow_len, NOFIX); @@ -289,7 +291,7 @@ void erase(FILE *fc){ status_bar(); show_cursor(); while((c=fgetc(fc))!=EOF && c!=27 && c!= 'x' && c != '\n'){ - if (!move_around(c, fc)) continue; + if (!move_around(c, fc, 0)) continue; check_bound(&x, &y); if (first || (y != orig_y && ! opened) || @@ -329,7 +331,7 @@ void visual_box(FILE *fc){ set_video(VIDEO_REV); draw_box(x,y,NOFIX); while((c=fgetc(fc))!=EOF && c != 27 && c!= 'v' && c != '\n'){ - if (!move_around(c, fc)) switch(c){ + if (!move_around(c, fc, 1)) switch(c){ case 'y': /* yank (copy) */ yank_region(MIN(orig_x,x), MIN(orig_y,y), MAX(orig_x, x), MAX(orig_y, y)); goto vis_exit; |