summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-06-10 07:58:43 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-06-10 07:58:43 +0000
commitdd056fad59c9e41dbc10488754a5f764412f782a (patch)
tree4b96b46dc345c5e38b054bc4fb2f14ae39d5fcd6 /usr.bin/tmux
parent9f045ea7228c40dce4e6b5ac78e2d84a6fe92c8e (diff)
Fix rectangle selection, from Anindya Mukherjee, GitHub issue 2709.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/window-copy.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 90bf7f90a09..73d3204b130 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.323 2021/06/10 07:56:47 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.324 2021/06/10 07:58:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1102,10 +1102,13 @@ static enum window_copy_cmd_action
window_copy_cmd_cursor_right(struct window_copy_cmd_state *cs)
{
struct window_mode_entry *wme = cs->wme;
+ struct window_copy_mode_data *data = wme->data;
u_int np = wme->prefix;
- for (; np != 0; np--)
- window_copy_cursor_right(wme, 0);
+ for (; np != 0; np--) {
+ window_copy_cursor_right(wme, data->screen.sel != NULL &&
+ data->rectflag);
+ }
return (WINDOW_COPY_CMD_NOTHING);
}
@@ -4427,10 +4430,12 @@ window_copy_cursor_up(struct window_mode_entry *wme, int scroll_only)
struct window_copy_mode_data *data = wme->data;
struct screen *s = &data->screen;
u_int ox, oy, px, py;
+ int norectsel;
+ norectsel = data->screen.sel == NULL || !data->rectflag;
oy = screen_hsize(data->backing) + data->cy - data->oy;
ox = window_copy_find_length(wme, oy);
- if (data->cx != ox) {
+ if (norectsel && data->cx != ox) {
data->lastcx = data->cx;
data->lastsx = ox;
}
@@ -4439,7 +4444,8 @@ window_copy_cursor_up(struct window_mode_entry *wme, int scroll_only)
window_copy_other_end(wme);
if (scroll_only || data->cy == 0) {
- data->cx = data->lastcx;
+ if (norectsel)
+ data->cx = data->lastcx;
window_copy_scroll_down(wme, 1);
if (scroll_only) {
if (data->cy == screen_size_y(s) - 1)
@@ -4448,7 +4454,11 @@ window_copy_cursor_up(struct window_mode_entry *wme, int scroll_only)
window_copy_redraw_lines(wme, data->cy, 2);
}
} else {
- window_copy_update_cursor(wme, data->lastcx, data->cy - 1);
+ if (norectsel) {
+ window_copy_update_cursor(wme, data->lastcx,
+ data->cy - 1);
+ } else
+ window_copy_update_cursor(wme, data->cx, data->cy - 1);
if (window_copy_update_selection(wme, 1, 0)) {
if (data->cy == screen_size_y(s) - 1)
window_copy_redraw_lines(wme, data->cy, 1);
@@ -4457,7 +4467,7 @@ window_copy_cursor_up(struct window_mode_entry *wme, int scroll_only)
}
}
- if (data->screen.sel == NULL || !data->rectflag) {
+ if (norectsel) {
py = screen_hsize(data->backing) + data->cy - data->oy;
px = window_copy_find_length(wme, py);
if ((data->cx >= data->lastsx && data->cx != px) ||
@@ -4494,10 +4504,12 @@ window_copy_cursor_down(struct window_mode_entry *wme, int scroll_only)
struct window_copy_mode_data *data = wme->data;
struct screen *s = &data->screen;
u_int ox, oy, px, py;
+ int norectsel;
+ norectsel = data->screen.sel == NULL || !data->rectflag;
oy = screen_hsize(data->backing) + data->cy - data->oy;
ox = window_copy_find_length(wme, oy);
- if (data->cx != ox) {
+ if (norectsel && data->cx != ox) {
data->lastcx = data->cx;
data->lastsx = ox;
}
@@ -4506,17 +4518,22 @@ window_copy_cursor_down(struct window_mode_entry *wme, int scroll_only)
window_copy_other_end(wme);
if (scroll_only || data->cy == screen_size_y(s) - 1) {
- data->cx = data->lastcx;
+ if (norectsel)
+ data->cx = data->lastcx;
window_copy_scroll_up(wme, 1);
if (scroll_only && data->cy > 0)
window_copy_redraw_lines(wme, data->cy - 1, 2);
} else {
- window_copy_update_cursor(wme, data->lastcx, data->cy + 1);
+ if (norectsel) {
+ window_copy_update_cursor(wme, data->lastcx,
+ data->cy + 1);
+ } else
+ window_copy_update_cursor(wme, data->cx, data->cy + 1);
if (window_copy_update_selection(wme, 1, 0))
window_copy_redraw_lines(wme, data->cy - 1, 2);
}
- if (data->screen.sel == NULL || !data->rectflag) {
+ if (norectsel) {
py = screen_hsize(data->backing) + data->cy - data->oy;
px = window_copy_find_length(wme, py);
if ((data->cx >= data->lastsx && data->cx != px) ||