Scrolling mouse wheel while shift modifier key is held generates fake cursor key events. With ctrl modifier added, speed is multi- plied by the value of "mouse-scroll-speedup" variable (default 3). --- trunk/examples/tmux.vim | 2 +- trunk/input-keys.c | 15 +++++++++++++-- trunk/options-table.c | 7 +++++++ trunk/tmux.1 | 3 +++ 4 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/trunk/examples/tmux.vim b/trunk/examples/tmux.vim index 8a66c00..6040a55 100644 --- a/trunk/examples/tmux.vim +++ b/trunk/examples/tmux.vim @@ -51,7 +51,7 @@ syn keyword tmuxOptsSet \ display-panes-[active-]colour display-[panes-]time history-limit \ lock-after-time lock-command lock-server message-[command-]attr \ message-[command-]bg message-[command-]fg message-limit - \ mouse-resize-pane mouse-select-pane mouse-select-window mouse-utf8 + \ mouse-resize-pane mouse-select-pane mouse-select-window mouse-scroll-speedup mouse-utf8 \ pane-[active-]border-bg pane-[active-]border-fg prefix prefix2 \ renumber-windows repeat-time set-remain-on-exit set-titles \ set-titles-string status status-attr status-bg status-fg diff --git a/trunk/input-keys.c b/trunk/input-keys.c index 2b8533d..0822b5b 100644 --- a/trunk/input-keys.c +++ b/trunk/input-keys.c @@ -203,6 +203,17 @@ input_mouse(struct window_pane *wp, struct mouse_event *m) { char buf[10]; size_t len; + int i, lines; + + /* Shift + mouse wheel scrolling: fake cursor key press events. */ + if (m->b & MOUSE_45 && m->b & MOUSE_SHIFT) { + /* + ctrl modifier: scroll at high speed. */ + lines = (m->b & MOUSE_CTRL) ? + options_get_number(&global_s_options, "mouse-scroll-speedup") : 1; + for (i = 0; i < lines; i++) + input_key(wp, (m->b & MOUSE_BUTTON) == MOUSE_1 ? KEYC_UP : KEYC_DOWN); + return; + } if (wp->screen->mode & ALL_MOUSE_MODES) { if (wp->screen->mode & MODE_MOUSE_UTF8) { @@ -222,13 +233,13 @@ input_mouse(struct window_pane *wp, struct mouse_event *m) return; } - if ((m->b & 3) != 1 && + if ((m->b & MOUSE_BUTTON) != MOUSE_2 && options_get_number(&wp->window->options, "mouse-copy-mode") == 1) { if (window_pane_set_mode(wp, &window_copy_mode) == 0) { window_copy_init_from_pane(wp); if (wp->mode->mouse != NULL) wp->mode->mouse(wp, NULL, m); + return; } - return; } } diff --git a/trunk/options-table.c b/trunk/options-table.c index c9b8406..f829eac 100644 --- a/trunk/options-table.c +++ b/trunk/options-table.c @@ -241,6 +241,13 @@ const struct options_table_entry session_options_table[] = { .default_num = 0 }, + { .name = "mouse-scroll-speedup", + .type = OPTIONS_TABLE_NUMBER, + .minimum = 0, + .maximum = INT_MAX, + .default_num = 3 + }, + { .name = "mouse-utf8", .type = OPTIONS_TABLE_FLAG, .default_num = 0 diff --git a/trunk/tmux.1 b/trunk/tmux.1 index 011dbf3..173898f 100644 --- a/trunk/tmux.1 +++ b/trunk/tmux.1 @@ -2208,6 +2208,9 @@ The mouse click is also passed through to the application as normal. .Xc If on, clicking the mouse on a window name in the status line will select that window. +.It Ic mouse-scroll-speedup Ar number +How many lines a mouse wheel event will scroll when the ctrl modifier is held. +The default is 3. .It Xo Ic mouse-utf8 .Op Ic on | off .Xc -- 1.7.10.4 ------------------------------------------------------------------------------ How fast is your code? 3 out of 4 devs don\\\'t know how their code performs in production. Find out how slow your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219672;13503038;z? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users