summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2014-08-11 22:18:16 +0000
committernicm <nicm>2014-08-11 22:18:16 +0000
commit29d20a55b645600feca1b54a13333e598336dad2 (patch)
treeea4fb9fdc5ebf7c6f7ba1899f203575668856e51
parentf518a077b176e65a30a187af21b00b0b9031dad7 (diff)
Fix two copy mode problems:
1. In vi mode the selection doesn't include the last character if you moved the cursor up or left. 2. In emacs mode the selection includes the last character if you moved the cursor to the left. From Balazs Kezes.
-rw-r--r--screen.c23
-rw-r--r--tmux.h1
-rw-r--r--window-copy.c1
3 files changed, 20 insertions, 5 deletions
diff --git a/screen.c b/screen.c
index 2b0e9fba..3e7d9924 100644
--- a/screen.c
+++ b/screen.c
@@ -276,6 +276,7 @@ int
screen_check_selection(struct screen *s, u_int px, u_int py)
{
struct screen_sel *sel = &s->sel;
+ u_int xx;
if (!sel->flag)
return (0);
@@ -325,16 +326,24 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
if (py < sel->sy || py > sel->ey)
return (0);
- if ((py == sel->sy && px < sel->sx)
- || (py == sel->ey && px > sel->ex))
+ if (py == sel->sy && px < sel->sx)
+ return 0;
+
+ if (py == sel->ey && px > sel->ex)
return (0);
} else if (sel->sy > sel->ey) {
/* starting line > ending line -- upward selection. */
if (py > sel->sy || py < sel->ey)
return (0);
- if ((py == sel->sy && px >= sel->sx)
- || (py == sel->ey && px < sel->ex))
+ if (py == sel->ey && px < sel->ex)
+ return (0);
+
+ if (sel->modekeys == MODEKEY_EMACS)
+ xx = sel->sx - 1;
+ else
+ xx = sel->sx;
+ if (py == sel->sy && px > xx)
return (0);
} else {
/* starting line == ending line. */
@@ -343,7 +352,11 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
if (sel->ex < sel->sx) {
/* cursor (ex) is on the left */
- if (px > sel->sx || px < sel->ex)
+ if (sel->modekeys == MODEKEY_EMACS)
+ xx = sel->sx - 1;
+ else
+ xx = sel->sx;
+ if (px > xx || px < sel->ex)
return (0);
} else {
/* selection start (sx) is on the left */
diff --git a/tmux.h b/tmux.h
index a0cbbd41..bfc70544 100644
--- a/tmux.h
+++ b/tmux.h
@@ -794,6 +794,7 @@ LIST_HEAD(joblist, job);
struct screen_sel {
int flag;
int rectflag;
+ int modekeys;
u_int sx;
u_int sy;
diff --git a/window-copy.c b/window-copy.c
index 17f9751b..24f94121 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -199,6 +199,7 @@ window_copy_init(struct window_pane *wp)
mode_key_init(&data->mdata, &mode_key_tree_emacs_copy);
else
mode_key_init(&data->mdata, &mode_key_tree_vi_copy);
+ s->sel.modekeys = keys;
data->backing = NULL;