diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-02-22 20:28:22 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-02-22 20:28:22 +0000 |
commit | fc3abfcbc94d6518e68a34805a9765e5389f5b12 (patch) | |
tree | f6e3cca0e00c228ca112dde282abc50cb3ee2641 /usr.bin/tmux | |
parent | db2dc988b649f7e85b52504a31e2a19250d2bdda (diff) |
Another copy mode fix from Micah Cowan: in rectangle copy mode, the cursor
should not wrap at the end of the text on the line but should be allowed to
move freely.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index c9541ba6193..9ecbb5d95d5 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.46 2010/02/19 00:03:21 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.47 2010/02/22 20:28:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -52,6 +52,7 @@ void window_copy_update_cursor(struct window_pane *, u_int, u_int); void window_copy_start_selection(struct window_pane *); int window_copy_update_selection(struct window_pane *); void window_copy_copy_selection(struct window_pane *, struct client *); +void window_copy_clear_selection(struct window_pane *); void window_copy_copy_line( struct window_pane *, char **, size_t *, u_int, u_int, u_int); int window_copy_in_set(struct window_pane *, u_int, u_int, const char *); @@ -213,7 +214,7 @@ window_copy_resize(struct window_pane *wp, u_int sx, u_int sy) if (data->cx > sx) data->cx = sx; - screen_clear_selection(&data->screen); + window_copy_clear_selection(wp); screen_write_start(&ctx, NULL, s); window_copy_write_lines(wp, &ctx, 0, screen_size_y(s) - 1); @@ -330,7 +331,7 @@ window_copy_key(struct window_pane *wp, struct client *c, int key) window_copy_redraw_screen(wp); break; case MODEKEYCOPY_CLEARSELECTION: - screen_clear_selection(&data->screen); + window_copy_clear_selection(wp); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_COPYSELECTION: @@ -1050,6 +1051,20 @@ window_copy_copy_line(struct window_pane *wp, } } +void +window_copy_clear_selection(struct window_pane *wp) +{ + struct window_copy_mode_data *data = wp->modedata; + u_int px, py; + + screen_clear_selection(&data->screen); + + py = screen_hsize(&wp->base) + data->cy - data->oy; + px = window_copy_find_length(wp, py); + if (data->cx > px) + window_copy_update_cursor(wp, px, data->cy); +} + int window_copy_in_set(struct window_pane *wp, u_int px, u_int py, const char *set) { @@ -1159,8 +1174,12 @@ window_copy_cursor_right(struct window_pane *wp) struct window_copy_mode_data *data = wp->modedata; u_int px, py; - py = screen_hsize(&wp->base) + data->cy - data->oy; - px = window_copy_find_length(wp, py); + if (data->screen.sel.flag && data->rectflag) + px = screen_size_x(&data->screen); + else { + py = screen_hsize(&wp->base) + data->cy - data->oy; + px = window_copy_find_length(wp, py); + } if (data->cx >= px) { window_copy_cursor_start_of_line(wp); @@ -1205,10 +1224,12 @@ window_copy_cursor_up(struct window_pane *wp, int scroll_only) } } - py = screen_hsize(&wp->base) + data->cy - data->oy; - px = window_copy_find_length(wp, py); - if (data->cx >= data->lastsx || data->cx > px) - window_copy_cursor_end_of_line(wp); + 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) + window_copy_cursor_end_of_line(wp); + } } void @@ -1236,10 +1257,12 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only) window_copy_redraw_lines(wp, data->cy - 1, 2); } - py = screen_hsize(&wp->base) + data->cy - data->oy; - px = window_copy_find_length(wp, py); - if (data->cx >= data->lastsx || data->cx > px) - window_copy_cursor_end_of_line(wp); + 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) + window_copy_cursor_end_of_line(wp); + } } void @@ -1417,9 +1440,15 @@ void window_copy_rectangle_toggle(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; + u_int px, py; data->rectflag = !data->rectflag; + py = screen_hsize(&wp->base) + data->cy - data->oy; + px = window_copy_find_length(wp, py); + if (data->cx > px) + window_copy_update_cursor(wp, px, data->cy); + window_copy_update_selection(wp); window_copy_redraw_screen(wp); } |