diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-04-24 21:06:13 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-04-24 21:06:13 +0000 |
commit | 845c90f59b8a1ee8f0c8d4cc236c44ad6b79157b (patch) | |
tree | e2aae91d023aad08a62520e7f0b454e5e112e8ce /usr.bin/tmux/window-copy.c | |
parent | ad561e4755a78b67059e6b9cb974fc63735ff9ab (diff) |
Tweak copy behaviour slightly in vi mode to be closer to real vi. From
Tiago Resende.
Diffstat (limited to 'usr.bin/tmux/window-copy.c')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 44d9d1b5aa2..a45f6fa119e 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.68 2011/04/19 21:31:33 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.69 2011/04/24 21:06:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1225,6 +1225,7 @@ window_copy_copy_selection(struct window_pane *wp) size_t off; u_int i, xx, yy, sx, sy, ex, ey, limit; u_int firstsx, lastex, restex, restsx; + int keys; if (!s->sel.flag) return; @@ -1261,6 +1262,14 @@ window_copy_copy_selection(struct window_pane *wp) * end (restex) of all other lines. */ xx = screen_size_x(s); + + /* + * Behave according to mode-keys. If it is emacs, copy like emacs, + * keeping the top-left-most character, and dropping the + * bottom-right-most, regardless of copy direction. If it is vi, also + * keep bottom-right-most character. + */ + keys = options_get_number(&wp->window->options, "mode-keys"); if (data->rectflag) { /* * Need to ignore the column with the cursor in it, which for @@ -1268,8 +1277,14 @@ window_copy_copy_selection(struct window_pane *wp) */ if (data->selx < data->cx) { /* Selection start is on the left. */ - lastex = data->cx; - restex = data->cx; + if (keys == MODEKEY_EMACS) { + lastex = data->cx; + restex = data->cx; + } + else { + lastex = data->cx + 1; + restex = data->cx + 1; + } firstsx = data->selx; restsx = data->selx; } else { @@ -1280,11 +1295,10 @@ window_copy_copy_selection(struct window_pane *wp) restsx = data->cx; } } else { - /* - * Like emacs, keep the top-left-most character, and drop the - * bottom-right-most, regardless of copy direction. - */ - lastex = ex; + if (keys == MODEKEY_EMACS) + lastex = ex; + else + lastex = ex + 1; restex = xx; firstsx = sx; restsx = 0; |