<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] mouse tracking support



Hello Anatoly,

 On Sunday, April 3, 2005 at 1:49:24 AM +0300, Anatoly Vorobey wrote:

> a patch to enable [some degree of] mouse tracking support

    Thank you! I'm not personally a mouse fan, but some users like it.
And wheel is probably the best UI for scrolling (especially when wheel
is physically on the keyboard or touchpad).


> events that are recognised are: button clicks and wheel movements for
> wheel mice.

    A pity horizontal wheel is impossible.


> ncurses doesn't support wheel movement recognition.

    I confirm wheel works with Ncurses 5.4.20050319 with
--enable-ext-mouse and your patch modified for BUTTON5_CLICKED.


> In message index menu, wheel movement scrolls the menu; clicking a
> line moves the selection to that message, if it's not selected, or
> displays the message if it's alrady selected

    This could be extended to all other menus.


> In pager mode, wheel movement scrolls the view.

    Clicks and wheel while on $pager_index_lines could act as in index.


> PuTTY - only works with ncurses, because PuTTY doesn't support the
> "old X10 compatibility mode".

    Clicks and wheel work with Slang once PuTTY 0.58 patched with
putty-0.56-ab.x10_mouse.2.patch, but $TERM must be xterm or so
(SLtt_set_mouse_mode() must be forced for $TERM=putty).


> introduce a runtime option to use/not use mouse tracking

    At best $mouse_tracking should be settable in macros or hooks, so
say user can activate it in some folders (with long mails to scroll),
and revert back to default terminal copy/paste mouse in other folders.
Or automatically do tracking only if at least one binding exists in
current context. Or both.


> integrate recognition of HAVE_SLANG_MOUSE/HAVE_NCURSES_MOUSE into
> configure

    --enable-mouse-tracking only, the Slang/Ncurses alternative is
already done elsewhere.


> configurable speed of wheel scrolling

    With acceleration, to have both precision and speed. Today it's
precise line-by-line, but one full and fast wheel movement scrolls only
7-8 lines.


> gnome-terminal sends too much information in violation, strictly
> speaking, of the X10 compatibility mode

    Does gnome-terminal send exactly the same events as PuTTY with
x10_mouse.2, namely push for the 5 buttons, with no releases, no
modifiers, no drag, no nothing else?

    Side note: x10_mouse.1 was sending only 3 buttons no wheel, and
worked fine with "slrn -m". Events for wheel badly break Slrn with
x10_mouse.2.


Bye!    Alain.
-- 
PuTTY 0.58 is released.
256 colors, improved Unicode, bidir, combining chars, CJK, IPv6.
diff -prud putty-0.56-src.orig/terminal.c putty-0.56-src/terminal.c
--- putty-0.56-src.orig/terminal.c      Sun Oct 24 14:37:32 2004
+++ putty-0.56-src/terminal.c   Wed Apr  6 21:06:00 2005
@@ -1237,6 +1237,10 @@ static void toggle_mode(Terminal *term, 
          case 8:                      /* DECARM: auto key repeat */
            term->repeat_off = !state;
            break;
+         case 9:                      /* X10 compatibility mouse reporting */
+           term->xterm_mouse = state ? 3 : 0;
+           set_raw_mouse_mode(term->frontend, state);
+           break;
          case 10:                     /* DECEDM: set local edit mode */
            term->term_editing = state;
            if (term->ldisc)           /* cause ldisc to notice changes */
@@ -4146,7 +4150,7 @@ void term_mouse(Terminal *term, Mouse_Bu
            }
            switch (a) {
              case MA_DRAG:
-               if (term->xterm_mouse == 1)
+               if ((term->xterm_mouse == 1) || (term->xterm_mouse == 3))
                    return;
                encstate += 0x20;
                break;
@@ -4167,6 +4171,19 @@ void term_mouse(Terminal *term, Mouse_Bu
                encstate += 0x10;
            r = y + 33;
            c = x + 33;
+           if (term->xterm_mouse == 3) {       /* X10 compatibility mode */
+             switch (encstate) {               /* report only simple events */
+               case 0x20:      /* buttons */
+               case 0x21:
+               case 0x22:
+                 /* break; */
+               case 0x60:      /* wheel */
+               case 0x61:
+                 break;
+               default:
+                 return;
+             }
+           }
 
            sprintf(abuf, "\033[M%c%c%c", encstate, c, r);
            ldisc_send(term->ldisc, abuf, 6, 0);