diff options
author | 2013-10-23 11:31:03 +0000 | |
---|---|---|
committer | 2013-10-23 11:31:03 +0000 | |
commit | 6e3081ec9de81ad9bbf07a497729bacb4468e839 (patch) | |
tree | f7d9e7360e859416068bede5d0c2a2bf771460f9 | |
parent | adapt to new DL_BLKTOSEC(); ok krw (diff) | |
download | wireguard-openbsd-6e3081ec9de81ad9bbf07a497729bacb4468e839.tar.xz wireguard-openbsd-6e3081ec9de81ad9bbf07a497729bacb4468e839.zip |
Key to swap to other end of selection (bound to o with vi keys), from J
Raynor.
-rw-r--r-- | usr.bin/tmux/mode-key.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 40 |
4 files changed, 46 insertions, 5 deletions
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c index 7c1504683fa..6edcc157d3b 100644 --- a/usr.bin/tmux/mode-key.c +++ b/usr.bin/tmux/mode-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-key.c,v 1.54 2013/07/05 14:44:06 nicm Exp $ */ +/* $OpenBSD: mode-key.c,v 1.55 2013/10/23 11:31:03 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -292,6 +292,7 @@ const struct mode_key_entry mode_key_vi_copy[] = { { 'k', 0, MODEKEYCOPY_UP }, { 'l', 0, MODEKEYCOPY_RIGHT }, { 'n', 0, MODEKEYCOPY_SEARCHAGAIN }, + { 'o', 0, MODEKEYCOPY_OTHEREND }, { 't', 0, MODEKEYCOPY_JUMPTO }, { 'q', 0, MODEKEYCOPY_CANCEL }, { 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE }, diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index d6e7057c224..12ee5342bc7 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.374 2013/10/10 23:31:28 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.375 2013/10/23 11:31:03 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 10 2013 $ +.Dd $Mdocdate: October 23 2013 $ .Dt TMUX 1 .Os .Sh NAME @@ -870,6 +870,7 @@ The following keys are supported as appropriate for the mode: .It Li "Next space, end of word" Ta "E" Ta "" .It Li "Next word" Ta "w" Ta "" .It Li "Next word end" Ta "e" Ta "M-f" +.It Li "Other end of selection" Ta "o" Ta "" .It Li "Paste buffer" Ta "p" Ta "C-y" .It Li "Previous page" Ta "C-b" Ta "Page up" .It Li "Previous word" Ta "b" Ta "M-b" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index e05ade7eebd..8253dda3154 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.431 2013/10/20 17:28:43 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.432 2013/10/23 11:31:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -564,6 +564,7 @@ enum mode_key_cmd { MODEKEYCOPY_NEXTSPACEEND, MODEKEYCOPY_NEXTWORD, MODEKEYCOPY_NEXTWORDEND, + MODEKEYCOPY_OTHEREND, MODEKEYCOPY_PREVIOUSPAGE, MODEKEYCOPY_PREVIOUSSPACE, MODEKEYCOPY_PREVIOUSWORD, diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index a1505b0958e..a5c9bc07a4b 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.94 2013/07/12 09:52:36 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.95 2013/10/23 11:31:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -65,6 +65,7 @@ u_int window_copy_find_length(struct window_pane *, u_int); void window_copy_cursor_start_of_line(struct window_pane *); void window_copy_cursor_back_to_indentation(struct window_pane *); void window_copy_cursor_end_of_line(struct window_pane *); +void window_copy_other_end(struct window_pane *); void window_copy_cursor_left(struct window_pane *); void window_copy_cursor_right(struct window_pane *); void window_copy_cursor_up(struct window_pane *, int); @@ -415,6 +416,10 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key) case MODEKEYCOPY_CANCEL: window_pane_reset_mode(wp); return; + case MODEKEYCOPY_OTHEREND: + for (; np != 0; np--) + window_copy_other_end(wp); + break; case MODEKEYCOPY_LEFT: for (; np != 0; np--) window_copy_cursor_left(wp); @@ -1619,6 +1624,39 @@ window_copy_cursor_end_of_line(struct window_pane *wp) } void +window_copy_other_end(struct window_pane *wp) +{ + struct window_copy_mode_data *data = wp->modedata; + struct screen *s = &data->screen; + u_int selx, sely, cx, cy, yy; + + if (!s->sel.flag) + return; + + selx = data->selx; + sely = data->sely; + cx = data->cx; + cy = data->cy; + yy = screen_hsize(data->backing) + data->cy - data->oy; + + data->selx = cx; + data->sely = yy; + data->cx = selx; + + if (sely < screen_hsize(data->backing) - data->oy) { + data->oy = screen_hsize(data->backing) - sely; + data->cy = 0; + } else if (sely > screen_hsize(data->backing) - data->oy + screen_size_y(s)) { + data->oy = screen_hsize(data->backing) - sely + screen_size_y(s) - 1; + data->cy = screen_size_y(s) - 1; + + } else + data->cy = cy + sely - yy; + + window_copy_redraw_screen(wp); +} + +void window_copy_cursor_left(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; |