diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-01-27 20:18:53 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-01-27 20:18:53 +0000 |
commit | b64578cf238eb7963184d131424c1331c522df16 (patch) | |
tree | 2ae1287d831cbd4b0420e4f456e1952609c500df /usr.bin/tmux | |
parent | 1ab48add32748e3b8da815cad2aafa77310873e9 (diff) |
Alter next-word to have vi-like movement behaviour, and add next-word-end with
the existing emacs behaviour. From Micah Cowan.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/mode-key.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 42 |
4 files changed, 50 insertions, 7 deletions
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c index 9efc6ca9db9..56b76bba7ba 100644 --- a/usr.bin/tmux/mode-key.c +++ b/usr.bin/tmux/mode-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-key.c,v 1.27 2010/01/25 21:33:39 nicm Exp $ */ +/* $OpenBSD: mode-key.c,v 1.28 2010/01/27 20:18:52 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -90,6 +90,7 @@ struct mode_key_cmdstr mode_key_cmdstr_copy[] = { { MODEKEYCOPY_MIDDLELINE, "middle-line" }, { MODEKEYCOPY_NEXTPAGE, "page-down" }, { MODEKEYCOPY_NEXTWORD, "next-word" }, + { MODEKEYCOPY_NEXTWORDEND, "next-word-end" }, { MODEKEYCOPY_PREVIOUSPAGE, "page-up" }, { MODEKEYCOPY_PREVIOUSWORD, "previous-word" }, { MODEKEYCOPY_RIGHT, "cursor-right" }, @@ -276,7 +277,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = { { '\027' /* C-w */, 0, MODEKEYCOPY_COPYSELECTION }, { '\033' /* Escape */, 0, MODEKEYCOPY_CANCEL }, { 'b' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSWORD }, - { 'f' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTWORD }, + { 'f' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTWORDEND }, { 'g', 0, MODEKEYCOPY_GOTOLINE }, { 'm' | KEYC_ESCAPE, 0, MODEKEYCOPY_BACKTOINDENTATION }, { 'n', 0, MODEKEYCOPY_SEARCHAGAIN }, diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index d9cd0784cc2..06c8678f9be 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.142 2010/01/25 21:33:39 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.143 2010/01/27 20:18:52 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 25 2010 $ +.Dd $Mdocdate: January 27 2010 $ .Dt TMUX 1 .Os .Sh NAME @@ -555,7 +555,8 @@ The following keys are supported as appropriate for the mode: .It Li "Half page down" Ta "C-d" Ta "M-Down" .It Li "Half page up" Ta "C-u" Ta "M-Up" .It Li "Next page" Ta "C-f" Ta "Page down" -.It Li "Next word" Ta "w" Ta "M-f" +.It Li "Next word" Ta "w" Ta "" +.It Li "Next word end" Ta "e" Ta "M-f" .It Li "Paste buffer" Ta "p" Ta "C-y" .It Li "Previous page" Ta "C-b" Ta "Page up" .It Li "Previous word" Ta "b" Ta "M-b" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index ddf1dfd15ae..ff317275d3f 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.199 2010/01/25 21:33:39 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.200 2010/01/27 20:18:52 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -461,6 +461,7 @@ enum mode_key_cmd { MODEKEYCOPY_MIDDLELINE, MODEKEYCOPY_NEXTPAGE, MODEKEYCOPY_NEXTWORD, + MODEKEYCOPY_NEXTWORDEND, MODEKEYCOPY_PREVIOUSPAGE, MODEKEYCOPY_PREVIOUSWORD, MODEKEYCOPY_RIGHT, diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index d86630e64b4..25c9143639d 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.39 2010/01/25 22:34:11 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.40 2010/01/27 20:18:52 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -64,6 +64,7 @@ void window_copy_cursor_right(struct window_pane *); void window_copy_cursor_up(struct window_pane *, int); void window_copy_cursor_down(struct window_pane *, int); void window_copy_cursor_next_word(struct window_pane *); +void window_copy_cursor_next_word_end(struct window_pane *); void window_copy_cursor_previous_word(struct window_pane *); void window_copy_scroll_up(struct window_pane *, u_int); void window_copy_scroll_down(struct window_pane *, u_int); @@ -336,6 +337,9 @@ window_copy_key(struct window_pane *wp, struct client *c, int key) case MODEKEYCOPY_NEXTWORD: window_copy_cursor_next_word(wp); break; + case MODEKEYCOPY_NEXTWORDEND: + window_copy_cursor_next_word_end(wp); + break; case MODEKEYCOPY_PREVIOUSWORD: window_copy_cursor_previous_word(wp); break; @@ -1169,6 +1173,42 @@ window_copy_cursor_next_word(struct window_pane *wp) xx = window_copy_find_length(wp, py); yy = screen_hsize(base_s) + screen_size_y(base_s) - 1; + /* Are we in a word? Skip it! */ + while (!window_copy_is_space(wp, px, py)) + px++; + + /* Find the start of a word. */ + while (px > xx || window_copy_is_space(wp, px, py)) { + /* Past the end of the line? Nothing but spaces. */ + if (px > xx) { + if (py == yy) + return; + window_copy_cursor_down(wp, 0); + px = 0; + + py = screen_hsize(base_s) + data->cy - data->oy; + xx = window_copy_find_length(wp, py); + } + px++; + } + + window_copy_update_cursor(wp, px, data->cy); + if (window_copy_update_selection(wp)) + window_copy_redraw_lines(wp, data->cy, 1); +} + +void +window_copy_cursor_next_word_end(struct window_pane *wp) +{ + struct window_copy_mode_data *data = wp->modedata; + struct screen *base_s = &wp->base; + u_int px, py, xx, yy; + + px = data->cx; + py = screen_hsize(base_s) + data->cy - data->oy; + xx = window_copy_find_length(wp, py); + yy = screen_hsize(base_s) + screen_size_y(base_s) - 1; + /* Are we on spaces? Skip 'em! */ while (px > xx || window_copy_is_space(wp, px, py)) { /* Nothing but spaces past the end of the line, so move down. */ |