mirror of
https://github.com/tmux/tmux.git
synced 2024-11-05 02:18:47 +00:00
Sync OpenBSD patchset 619:
Hugely simplify window_copy_cursor_next_word, which was way overcomplicated.
This commit is contained in:
parent
22dd0beaa0
commit
1a6cb5fd54
@ -1,4 +1,4 @@
|
||||
/* $Id: window-copy.c,v 1.97 2010-01-28 22:42:36 tcunha Exp $ */
|
||||
/* $Id: window-copy.c,v 1.98 2010-01-28 22:43:24 tcunha 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);
|
||||
yy = screen_hsize(base_s) + screen_size_y(base_s) - 1;
|
||||
|
||||
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;
|
||||
}
|
||||
/* 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;
|
||||
|
||||
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);
|
||||
}
|
||||
py = screen_hsize(base_s) + 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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user