summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-01-25 22:34:12 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-01-25 22:34:12 +0000
commitab1d43b60f7c8a6f66dcf39bcdb2b87ce860626b (patch)
tree95e9f5572ff77b11eebc9728c240f1713b9b3598 /usr.bin
parent51494282de20f797dd81eb9956075266c267186d (diff)
Hugely simplify window_copy_cursor_next_word, which was way overcomplicated.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/window-copy.c68
1 files changed, 22 insertions, 46 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 54ca657fa7f..d86630e64b4 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.38 2010/01/25 21:37:40 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.39 2010/01/25 22:34:11 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1161,56 +1161,33 @@ void
window_copy_cursor_next_word(struct window_pane *wp)
{
struct window_copy_mode_data *data = wp->modedata;
- struct screen *s = &data->screen;
- u_int px, py, xx, skip;
+ struct screen *base_s = &wp->base;
+ u_int px, py, xx, yy;
px = data->cx;
- py = screen_hsize(&wp->base) + data->cy - data->oy;
+ py = screen_hsize(base_s) + data->cy - data->oy;
xx = window_copy_find_length(wp, py);
-
- skip = 1;
- if (px < xx) {
- /* If currently on a space, skip space. */
- if (window_copy_is_space(wp, px, py))
- skip = 0;
- } else
- skip = 0;
- for (;;) {
- if (px >= xx) {
- if (skip) {
- px = xx;
- break;
- }
-
- while (px >= xx) {
- if (data->cy == screen_size_y(s) - 1) {
- if (data->oy == 0)
- goto out;
- }
-
- px = 0;
- window_copy_cursor_down(wp, 0);
-
- py =screen_hsize(
- &wp->base) + data->cy - data->oy;
- xx = window_copy_find_length(wp, py);
- }
- }
-
- if (skip) {
- /* Currently skipping non-space (until space). */
- if (window_copy_is_space(wp, px, py))
- break;
- } else {
- /* Currently skipping space (until non-space). */
- if (!window_copy_is_space(wp, px, py))
- skip = 1;
+ 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. */
+ 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++;
}
-out:
+ /* Find the end of this word. */
+ while (!window_copy_is_space(wp, px, py))
+ px++;
+
window_copy_update_cursor(wp, px, data->cy);
if (window_copy_update_selection(wp))
window_copy_redraw_lines(wp, data->cy, 1);
@@ -1239,8 +1216,7 @@ window_copy_cursor_previous_word(struct window_pane *wp)
goto out;
window_copy_cursor_up(wp, 0);
- py = screen_hsize(
- &wp->base) + data->cy - data->oy;
+ py = screen_hsize(&wp->base) + data->cy - data->oy;
px = window_copy_find_length(wp, py);
}
}