mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-22 05:48:40 +01:00
Make scrolling behaviour more sensible and maintain cursor position, as
if the same had been done line-by-line. From Michal Mazurek.
This commit is contained in:
parent
fa97b0a95b
commit
312a7a1e62
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
struct screen *window_copy_init(struct window_pane *);
|
struct screen *window_copy_init(struct window_pane *);
|
||||||
void window_copy_free(struct window_pane *);
|
void window_copy_free(struct window_pane *);
|
||||||
|
void window_copy_pagedown(struct window_pane *);
|
||||||
void window_copy_resize(struct window_pane *, u_int, u_int);
|
void window_copy_resize(struct window_pane *, u_int, u_int);
|
||||||
void window_copy_key(struct window_pane *, struct client *, struct session *,
|
void window_copy_key(struct window_pane *, struct client *, struct session *,
|
||||||
key_code, struct mouse_event *);
|
key_code, struct mouse_event *);
|
||||||
@ -324,15 +325,80 @@ window_copy_pageup(struct window_pane *wp)
|
|||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
u_int n;
|
u_int n, ox, oy;
|
||||||
|
|
||||||
|
oy = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
|
ox = window_copy_find_length(wp, oy);
|
||||||
|
|
||||||
|
if (s->sel.lineflag == LINE_SEL_LEFT_RIGHT && oy == data->sely)
|
||||||
|
window_copy_other_end(wp);
|
||||||
|
|
||||||
|
if (data->cx != ox) {
|
||||||
|
data->lastcx = data->cx;
|
||||||
|
data->lastsx = ox;
|
||||||
|
}
|
||||||
|
data->cx = data->lastcx;
|
||||||
|
|
||||||
n = 1;
|
n = 1;
|
||||||
if (screen_size_y(s) > 2)
|
if (screen_size_y(s) > 2)
|
||||||
n = screen_size_y(s) - 2;
|
n = screen_size_y(s) - 2;
|
||||||
|
|
||||||
if (data->oy + n > screen_hsize(data->backing))
|
if (data->oy + n > screen_hsize(data->backing))
|
||||||
data->oy = screen_hsize(data->backing);
|
data->oy = screen_hsize(data->backing);
|
||||||
else
|
else
|
||||||
data->oy += n;
|
data->oy += n;
|
||||||
|
|
||||||
|
if (!data->screen.sel.flag || !data->rectflag) {
|
||||||
|
u_int py = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
|
u_int px = window_copy_find_length(wp, py);
|
||||||
|
if ((data->cx >= data->lastsx && data->cx != px) || data->cx > px)
|
||||||
|
window_copy_cursor_end_of_line(wp);
|
||||||
|
}
|
||||||
|
|
||||||
|
window_copy_update_selection(wp, 1);
|
||||||
|
window_copy_redraw_screen(wp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
window_copy_pagedown(struct window_pane *wp)
|
||||||
|
{
|
||||||
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
|
struct screen *s = &data->screen;
|
||||||
|
u_int n, ox, oy;
|
||||||
|
|
||||||
|
oy = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
|
ox = window_copy_find_length(wp, oy);
|
||||||
|
|
||||||
|
if (s->sel.lineflag == LINE_SEL_RIGHT_LEFT && oy == data->sely)
|
||||||
|
window_copy_other_end(wp);
|
||||||
|
|
||||||
|
if (data->cx != ox) {
|
||||||
|
data->lastcx = data->cx;
|
||||||
|
data->lastsx = ox;
|
||||||
|
}
|
||||||
|
data->cx = data->lastcx;
|
||||||
|
|
||||||
|
n = 1;
|
||||||
|
if (screen_size_y(s) > 2)
|
||||||
|
n = screen_size_y(s) - 2;
|
||||||
|
|
||||||
|
if (data->oy < n)
|
||||||
|
data->oy = 0;
|
||||||
|
else
|
||||||
|
data->oy -= n;
|
||||||
|
|
||||||
|
if (!data->screen.sel.flag || !data->rectflag) {
|
||||||
|
u_int py = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
|
u_int px = window_copy_find_length(wp, py);
|
||||||
|
if ((data->cx >= data->lastsx && data->cx != px) || data->cx > px)
|
||||||
|
window_copy_cursor_end_of_line(wp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->scroll_exit && data->oy == 0) {
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
window_copy_update_selection(wp, 1);
|
window_copy_update_selection(wp, 1);
|
||||||
window_copy_redraw_screen(wp);
|
window_copy_redraw_screen(wp);
|
||||||
}
|
}
|
||||||
@ -479,21 +545,8 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
|
|||||||
window_copy_pageup(wp);
|
window_copy_pageup(wp);
|
||||||
break;
|
break;
|
||||||
case MODEKEYCOPY_NEXTPAGE:
|
case MODEKEYCOPY_NEXTPAGE:
|
||||||
n = 1;
|
for (; np != 0; np--)
|
||||||
if (screen_size_y(s) > 2)
|
window_copy_pagedown(wp);
|
||||||
n = screen_size_y(s) - 2;
|
|
||||||
for (; np != 0; np--) {
|
|
||||||
if (data->oy < n)
|
|
||||||
data->oy = 0;
|
|
||||||
else
|
|
||||||
data->oy -= n;
|
|
||||||
}
|
|
||||||
if (data->scroll_exit && data->oy == 0) {
|
|
||||||
window_pane_reset_mode(wp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window_copy_update_selection(wp, 1);
|
|
||||||
window_copy_redraw_screen(wp);
|
|
||||||
break;
|
break;
|
||||||
case MODEKEYCOPY_HALFPAGEUP:
|
case MODEKEYCOPY_HALFPAGEUP:
|
||||||
n = screen_size_y(s) / 2;
|
n = screen_size_y(s) / 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user