mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Work out mouse scroll wheel effect when the mouse is first detected and
store it in struct mouse_event, reduce the scroll size the 3 but allow shift to reduce it to 1 and meta and ctrl to multiply by 3 if the terminal supports them, also support wheel in choose mode. From Marcel Partap.
This commit is contained in:
parent
8824dae6f7
commit
acef311fe3
1
tmux.h
1
tmux.h
@ -1168,6 +1168,7 @@ struct mouse_event {
|
|||||||
|
|
||||||
u_int button;
|
u_int button;
|
||||||
u_int clicks;
|
u_int clicks;
|
||||||
|
u_int scroll;
|
||||||
|
|
||||||
int wheel;
|
int wheel;
|
||||||
int event;
|
int event;
|
||||||
|
@ -749,6 +749,15 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
|
|||||||
m->x = x;
|
m->x = x;
|
||||||
m->y = y;
|
m->y = y;
|
||||||
if (b & MOUSE_MASK_WHEEL) {
|
if (b & MOUSE_MASK_WHEEL) {
|
||||||
|
if (b & MOUSE_MASK_SHIFT)
|
||||||
|
m->scroll = 1;
|
||||||
|
else
|
||||||
|
m->scroll = 3;
|
||||||
|
if (b & MOUSE_MASK_META)
|
||||||
|
m->scroll *= 3;
|
||||||
|
if (b & MOUSE_MASK_CTRL)
|
||||||
|
m->scroll *= 3;
|
||||||
|
|
||||||
b &= MOUSE_MASK_BUTTONS;
|
b &= MOUSE_MASK_BUTTONS;
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
m->wheel = MOUSE_WHEEL_UP;
|
m->wheel = MOUSE_WHEEL_UP;
|
||||||
|
@ -721,7 +721,17 @@ window_choose_mouse(
|
|||||||
struct window_choose_mode_data *data = wp->modedata;
|
struct window_choose_mode_data *data = wp->modedata;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
struct window_choose_mode_item *item;
|
struct window_choose_mode_item *item;
|
||||||
u_int idx;
|
u_int i, idx;
|
||||||
|
|
||||||
|
if (m->event == MOUSE_EVENT_WHEEL) {
|
||||||
|
for (i = 0; i < m->scroll; i++) {
|
||||||
|
if (m->wheel == MOUSE_WHEEL_UP)
|
||||||
|
window_choose_key(wp, sess, KEYC_UP);
|
||||||
|
else
|
||||||
|
window_choose_key(wp, sess, KEYC_DOWN);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (~m->event & MOUSE_EVENT_CLICK)
|
if (~m->event & MOUSE_EVENT_CLICK)
|
||||||
return;
|
return;
|
||||||
|
@ -871,19 +871,20 @@ window_copy_mouse(
|
|||||||
|
|
||||||
/* If mouse wheel (buttons 4 and 5), scroll. */
|
/* If mouse wheel (buttons 4 and 5), scroll. */
|
||||||
if (m->event == MOUSE_EVENT_WHEEL) {
|
if (m->event == MOUSE_EVENT_WHEEL) {
|
||||||
if (m->wheel == MOUSE_WHEEL_UP) {
|
for (i = 0; i < m->scroll; i++) {
|
||||||
for (i = 0; i < 5; i++)
|
if (m->wheel == MOUSE_WHEEL_UP)
|
||||||
window_copy_cursor_up(wp, 1);
|
window_copy_cursor_up(wp, 1);
|
||||||
} else if (m->wheel == MOUSE_WHEEL_DOWN) {
|
else {
|
||||||
for (i = 0; i < 5; i++)
|
|
||||||
window_copy_cursor_down(wp, 1);
|
window_copy_cursor_down(wp, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We reached the bottom, leave copy mode,
|
* We reached the bottom, leave copy mode, but
|
||||||
* but only if no selection is in progress.
|
* only if no selection is in progress.
|
||||||
*/
|
*/
|
||||||
if (data->oy == 0 && !s->sel.flag)
|
if (data->oy == 0 && !s->sel.flag)
|
||||||
goto reset_mode;
|
goto reset_mode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user