Instead of forcing mouse scroll to 1 in choose mode, scale it down
authornicm <nicm@openbsd.org>
Thu, 8 May 2014 07:54:47 +0000 (07:54 +0000)
committernicm <nicm@openbsd.org>
Thu, 8 May 2014 07:54:47 +0000 (07:54 +0000)
instead. Means modifier keys still increase the line count, just not as
much. Based on a diff from Marcel Partap.

usr.bin/tmux/tmux.h
usr.bin/tmux/tty-keys.c
usr.bin/tmux/window-choose.c

index ed02f47..ce7cdda 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.458 2014/05/08 06:03:30 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.459 2014/05/08 07:54:47 nicm Exp $ */
 
 /*
  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1130,6 +1130,9 @@ LIST_HEAD(tty_terms, tty_term);
 #define MOUSE_WHEEL_UP 0
 #define MOUSE_WHEEL_DOWN 1
 
+/* Mouse wheel multipler. */
+#define MOUSE_WHEEL_SCALE 3
+
 /* Mouse event bits. */
 #define MOUSE_EVENT_DOWN 0x1
 #define MOUSE_EVENT_DRAG 0x2
index 53b3bf0..2515c60 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.65 2014/04/03 08:20:29 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.66 2014/05/08 07:54:47 nicm Exp $ */
 
 /*
  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -752,11 +752,11 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
                if (b & MOUSE_MASK_SHIFT)
                        m->scroll = 1;
                else
-                       m->scroll = 3;
+                       m->scroll = MOUSE_WHEEL_SCALE;
                if (b & MOUSE_MASK_META)
-                       m->scroll *= 3;
+                       m->scroll *= MOUSE_WHEEL_SCALE;
                if (b & MOUSE_MASK_CTRL)
-                       m->scroll *= 3;
+                       m->scroll *= MOUSE_WHEEL_SCALE;
 
                b &= MOUSE_MASK_BUTTONS;
                if (b == 0)
index f36ae13..553d341 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-choose.c,v 1.53 2014/04/17 14:13:59 nicm Exp $ */
+/* $OpenBSD: window-choose.c,v 1.54 2014/05/08 07:54:47 nicm Exp $ */
 
 /*
  * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -721,17 +721,22 @@ window_choose_mouse(struct window_pane *wp, struct session *sess,
        struct window_choose_mode_data  *data = wp->modedata;
        struct screen                   *s = &data->screen;
        struct window_choose_mode_item  *item;
-       u_int                            idx;
+       u_int                            idx, i, n;
 
        if (m->event == MOUSE_EVENT_WHEEL) {
                /*
-                * Don't use m->scroll and just move line-by-line or it's
-                * annoying.
+                * Multiple line scrolling by default is annoying, so scale
+                * m->scroll back down.
                 */
-               if (m->wheel == MOUSE_WHEEL_UP)
-                       window_choose_key(wp, sess, KEYC_UP);
-               else
-                       window_choose_key(wp, sess, KEYC_DOWN);
+               n = m->scroll;
+               if (n >= MOUSE_WHEEL_SCALE)
+                       n /= MOUSE_WHEEL_SCALE;
+               for (i = 0; i < n; i++) {
+                       if (m->wheel == MOUSE_WHEEL_UP)
+                               window_choose_key(wp, sess, KEYC_UP);
+                       else
+                               window_choose_key(wp, sess, KEYC_DOWN);
+               }
                return;
        }