diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-27 07:42:46 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-27 07:42:46 +0000 |
commit | d68a576257b3d0aeb1cb5ae1cdd2f36c1580d473 (patch) | |
tree | c9f2bbfacd7a154e032c5ac50d2291554044a24f /usr.bin/tmux | |
parent | 052d5bb4250757e31a51d68d65dd6012003b19c7 (diff) |
Change previous-word behavior to move to the beginning of the word (matches
emacs and vi). From Kalle Olavi Niemitalo.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 57 |
1 files changed, 21 insertions, 36 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 41d3a0eb6da..dc9cb7311d7 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.7 2009/07/23 17:03:47 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.8 2009/07/27 07:42:45 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -796,55 +796,40 @@ out: window_copy_set_cursor_x(wp, px); } +/* Move to the previous place where a word begins. */ void window_copy_cursor_previous_word(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; - u_int ox, px, py, skip; + u_int px, py; - ox = px = data->ox + data->cx; + px = data->ox + data->cx; py = screen_hsize(&wp->base) + data->cy - data->oy; - skip = 1; - if (px != 0) { - /* If currently on a space, skip space. */ - if (window_copy_is_space(wp, px - 1, py)) - skip = 0; - } + /* Move back to the previous word character. */ for (;;) { - if (px == 0) { - if (ox != 0) + if (px > 0) { + px--; + if (!window_copy_is_space(wp, px, py)) break; - - while (px == 0) { - if (data->cy == 0 && - (screen_hsize(&wp->base) == 0 || - data->oy >= screen_hsize(&wp->base) - 1)) - goto out; - - window_copy_cursor_up(wp); - - py = screen_hsize( - &wp->base) + data->cy - data->oy; - px = window_copy_find_length(wp, py); - } - goto out; - } - - if (skip) { - /* Currently skipping non-space (until space). */ - if (window_copy_is_space(wp, px - 1, py)) - skip = 0; } else { - /* Currently skipping space (until non-space). */ - if (!window_copy_is_space(wp, px - 1, py)) - break; + if (data->cy == 0 && + (screen_hsize(&wp->base) == 0 || + data->oy >= screen_hsize(&wp->base) - 1)) + goto out; + window_copy_cursor_up(wp); + + py = screen_hsize( + &wp->base) + data->cy - data->oy; + px = window_copy_find_length(wp, py); } + } + /* Move back to the beginning of this word. */ + while (px > 0 && !window_copy_is_space(wp, px - 1, py)) px--; - } -out: +out: window_copy_set_cursor_x(wp, px); } |