summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-03-01 23:53:28 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-03-01 23:53:28 +0000
commit69e26d6eaf0e15c89509d539c529b0e02f715d7c (patch)
tree27b4ab0e5bc0ec676ed5033565cf484d9c3c0c6d /usr.bin
parent49e1733747bd6981f6a910e48bdb08dd22a203d9 (diff)
Extend the end-of-line key so that in normal mode a second press moves
the cursor to the end of a wrapped line (if present) and in rectangle mode it toggles between the end of the text and the last cell on the line. From Micah Cowan.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/window-copy.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 030557019d2..54553efaeab 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.48 2010/02/22 20:41:16 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.49 2010/03/01 23:53:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1149,12 +1149,27 @@ void
window_copy_cursor_end_of_line(struct window_pane *wp)
{
struct window_copy_mode_data *data = wp->modedata;
+ struct screen *base_s = &wp->base;
+ struct grid *gd = base_s->grid;
u_int px, py;
- py = screen_hsize(&wp->base) + data->cy - data->oy;
+ py = screen_hsize(base_s) + data->cy - data->oy;
px = window_copy_find_length(wp, py);
+ if (data->cx == px) {
+ if (data->screen.sel.flag && data->rectflag)
+ px = screen_size_x(&wp->base);
+ if (gd->linedata[py].flags & GRID_LINE_WRAPPED) {
+ while (py < gd->sy + gd->hsize &&
+ gd->linedata[py].flags & GRID_LINE_WRAPPED) {
+ window_copy_cursor_down(wp, 0);
+ py = screen_hsize(base_s) + data->cy - data->oy;
+ }
+ px = window_copy_find_length(wp, py);
+ }
+ }
window_copy_update_cursor(wp, px, data->cy);
+
if (window_copy_update_selection(wp))
window_copy_redraw_lines(wp, data->cy, 1);
}
@@ -1233,7 +1248,8 @@ window_copy_cursor_up(struct window_pane *wp, int scroll_only)
if (!data->screen.sel.flag || !data->rectflag) {
py = screen_hsize(&wp->base) + data->cy - data->oy;
px = window_copy_find_length(wp, py);
- if (data->cx >= data->lastsx || data->cx > px)
+ if ((data->cx >= data->lastsx && data->cx != px) ||
+ data->cx > px)
window_copy_cursor_end_of_line(wp);
}
}
@@ -1266,7 +1282,8 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only)
if (!data->screen.sel.flag || !data->rectflag) {
py = screen_hsize(&wp->base) + data->cy - data->oy;
px = window_copy_find_length(wp, py);
- if (data->cx >= data->lastsx || data->cx > px)
+ if ((data->cx >= data->lastsx && data->cx != px) ||
+ data->cx > px)
window_copy_cursor_end_of_line(wp);
}
}