Make jump-to-backward/jump-to-forward repeatable with
authornicm <nicm@openbsd.org>
Mon, 20 Apr 2015 09:39:21 +0000 (09:39 +0000)
committernicm <nicm@openbsd.org>
Mon, 20 Apr 2015 09:39:21 +0000 (09:39 +0000)
jump-reverse/jump-again, from Jacob Niehus.

usr.bin/tmux/window-copy.c

index 9c74d0a..c886cf6 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.126 2015/04/19 21:34:21 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.127 2015/04/20 09:39:21 nicm Exp $ */
 
 /*
  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);