aboutsummaryrefslogtreecommitdiff
path: root/window-copy.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-04-24 21:06:12 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-04-24 21:06:12 +0000
commitdc8fb9fb23f22ef4f2aedaee55d6e008b0089be3 (patch)
tree3cc3ef81dd964eae140f7ee5106f90ee42df69d2 /window-copy.c
parent8738141913517ae50d71b17ec531ce9f85dceb4d (diff)
downloadrtmux-dc8fb9fb23f22ef4f2aedaee55d6e008b0089be3.tar.gz
rtmux-dc8fb9fb23f22ef4f2aedaee55d6e008b0089be3.tar.bz2
rtmux-dc8fb9fb23f22ef4f2aedaee55d6e008b0089be3.zip
Tweak copy behaviour slightly in vi mode to be closer to real vi. From
Tiago Resende.
Diffstat (limited to 'window-copy.c')
-rw-r--r--window-copy.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/window-copy.c b/window-copy.c
index b3879f62..329a6f76 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -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;