From 0fd9a97202dc2878d9cf21f3bea01b599c21e61b Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 20 Apr 2015 09:39:21 +0000 Subject: [PATCH] Make jump-to-backward/jump-to-forward repeatable with jump-reverse/jump-again, from Jacob Niehus. --- window-copy.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/window-copy.c b/window-copy.c index a0560716..afa609ed 100644 --- a/window-copy.c +++ b/window-copy.c @@ -75,8 +75,8 @@ void window_copy_cursor_up(struct window_pane *, int); void window_copy_cursor_down(struct window_pane *, int); void window_copy_cursor_jump(struct window_pane *); void window_copy_cursor_jump_back(struct window_pane *); -void window_copy_cursor_jump_to(struct window_pane *); -void window_copy_cursor_jump_to_back(struct window_pane *); +void window_copy_cursor_jump_to(struct window_pane *, int); +void window_copy_cursor_jump_to_back(struct window_pane *, int); void window_copy_cursor_next_word(struct window_pane *, const char *); void window_copy_cursor_next_word_end(struct window_pane *, const char *); void window_copy_cursor_previous_word(struct window_pane *, const char *); @@ -397,11 +397,11 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess, } if (data->inputtype == WINDOW_COPY_JUMPTOFORWARD) { for (; np != 0; np--) - window_copy_cursor_jump_to(wp); + window_copy_cursor_jump_to(wp, 0); } if (data->inputtype == WINDOW_COPY_JUMPTOBACK) { for (; np != 0; np--) - window_copy_cursor_jump_to_back(wp); + window_copy_cursor_jump_to_back(wp, 0); } } data->jumptype = data->inputtype; @@ -643,10 +643,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess, window_copy_cursor_jump_back(wp); } else if (data->jumptype == WINDOW_COPY_JUMPTOFORWARD) { for (; np != 0; np--) - window_copy_cursor_jump_to(wp); + window_copy_cursor_jump_to(wp, 1); } else if (data->jumptype == WINDOW_COPY_JUMPTOBACK) { for (; np != 0; np--) - window_copy_cursor_jump_to_back(wp); + window_copy_cursor_jump_to_back(wp, 1); } break; case MODEKEYCOPY_JUMPREVERSE: @@ -658,10 +658,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess, window_copy_cursor_jump(wp); } else if (data->jumptype == WINDOW_COPY_JUMPTOFORWARD) { for (; np != 0; np--) - window_copy_cursor_jump_to_back(wp); + window_copy_cursor_jump_to_back(wp, 1); } else if (data->jumptype == WINDOW_COPY_JUMPTOBACK) { for (; np != 0; np--) - window_copy_cursor_jump_to(wp); + window_copy_cursor_jump_to(wp, 1); } break; case MODEKEYCOPY_JUMPBACK: @@ -1944,7 +1944,7 @@ window_copy_cursor_jump_back(struct window_pane *wp) } void -window_copy_cursor_jump_to(struct window_pane *wp) +window_copy_cursor_jump_to(struct window_pane *wp, int jump_again) { struct window_copy_mode_data *data = wp->modedata; struct screen *back_s = data->backing; @@ -1952,7 +1952,7 @@ window_copy_cursor_jump_to(struct window_pane *wp) struct utf8_data ud; u_int px, py, xx; - px = data->cx + 1; + px = data->cx + 1 + jump_again; py = screen_hsize(back_s) + data->cy - data->oy; xx = window_copy_find_length(wp, py); @@ -1971,7 +1971,7 @@ window_copy_cursor_jump_to(struct window_pane *wp) } void -window_copy_cursor_jump_to_back(struct window_pane *wp) +window_copy_cursor_jump_to_back(struct window_pane *wp, int jump_again) { struct window_copy_mode_data *data = wp->modedata; struct screen *back_s = data->backing; @@ -1985,6 +1985,9 @@ window_copy_cursor_jump_to_back(struct window_pane *wp) if (px > 0) px--; + if (jump_again && px > 0) + px--; + for (;;) { gc = grid_peek_cell(back_s->grid, px, py); grid_cell_get(gc, &ud);