diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-03-01 23:53:27 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-03-01 23:53:27 +0000 |
commit | 56a33b157b4ca607850eedb6397c48707698537a (patch) | |
tree | 300fe043b60b78ce941ef7b52559f11895747050 | |
parent | c7046b9a0c338323fc478e9146371f80b843e336 (diff) | |
download | rtmux-56a33b157b4ca607850eedb6397c48707698537a.tar.gz rtmux-56a33b157b4ca607850eedb6397c48707698537a.tar.bz2 rtmux-56a33b157b4ca607850eedb6397c48707698537a.zip |
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.
-rw-r--r-- | window-copy.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/window-copy.c b/window-copy.c index 82ae9a2b..6497b174 100644 --- a/window-copy.c +++ b/window-copy.c @@ -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); } } |