mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 16:43:11 +01:00
Hugely simplify window_copy_cursor_next_word, which was way overcomplicated.
This commit is contained in:
parent
e31480cf44
commit
f26312ffbf
@ -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