TIP: Click on subject to list as thread! ANSI
echo: mystic
to: ROB SWINDELL
from: G00R00
date: 2020-05-17 21:39:00
subject: Re: Mouse support in Netr

 RS> However, when testing with Netrunner2, an upper-left left-button click
 RS> sends this:
 RS> 27 1b
 RS> 91 5b '['
 RS> 77 4d 'M'
 RS> 48 30 '0'
 RS> 41 29 ')'
 RS> 41 29 ')'
 RS> 
 RS> What mouse protocol is this and do you have a reference document?

Hey Rob,

I'd be happy to (try to) help!

The latest NetRunner is beta 19 which uses either XTERM(?) or maybe VT200(?)
mouse support. I used whatever the default was in PUTTY at the time so that
it'd be compatible with Mystic "out of the box".

I used to have a bookmark that had a reference but I can't seem to find it at
the moment.  I read through my code and I did have some source code notes
that I can pass along, and a chunk of code from PUTTY that can be used as a
reference to its various mouse modes.

(Some observations that I just made by looking at my code:)

(It looks like the X/Y coordinates are just the ascii character corresponding
to the X/Y coordinate with with +32 added to it to avoid conflict with low
ascii control characters. So coordinates 1, 1 would be represented as
Ascii#33;Ascii#33. This means its limited to a terminal size of 223x223 though
which is something I overlooked at the time.  It also looks like Mystic sends
esc[?1000h to the Unix terminal when running in Unix to enable mouse reporting,
so that seems like a clue we can Google to find out officially what it is.
NetRunner also translates a wheel spin to either the up or down arrow ANSI
escape sequence for max usefulness with non-mouse-aware BBSes)

Notes:

(*  PUTTY
  ESC[Ma;b;c
  // low two bits of "a" encode button: 0=MB1 pressed, 1=2 pressed, 2=3
  // pressed, 3=release
  // next 3 bits encode modifiers (4=shift,8=meta,16=control)
  // b,c are x and y coordinates of cursor

    int encstate = 0, r, c, wheel;
    char abuf[32];
    int len = 0;

    if (term->ldisc) {

        switch (braw) {
          case MBT_LEFT:
         encstate = 0x00;           /* left button down */
                wheel = FALSE;
         break;
          case MBT_MIDDLE:
         encstate = 0x01;
                wheel = FALSE;
         break;
          case MBT_RIGHT:
         encstate = 0x02;
                wheel = FALSE;
         break;
          case MBT_WHEEL_UP:
         encstate = 0x40;
                wheel = TRUE;
         break;
          case MBT_WHEEL_DOWN:
         encstate = 0x41;
                wheel = TRUE;
         break;
          default:
                return;
        }
            if (wheel) {
                if (a != MA_CLICK)
                    return;
            } else switch (a) {
          case MA_DRAG:
         if (term->xterm_mouse == 1)
             return;
         encstate += 0x20;
         break;
          case MA_RELEASE:
         if (!term->xterm_extended_mouse)
             encstate = 0x03;
         term->mouse_is_down = 0;
         break;
          case MA_CLICK:
         if (term->mouse_is_down == braw)
             return;
         term->mouse_is_down = braw;
         break;
              default:
                return;
        }
        if (shift)
         encstate += 0x04;
        if (ctrl)
         encstate += 0x10;
        r = y + 1;
        c = x + 1;

        if (term->xterm_extended_mouse) {
         len = sprintf(abuf, "\033[<%d;%d;%d%c", encstate, c, r, a ==
MA_RELEASE ? 'm' : 'M');
        } else if (term->urxvt_extended_mouse) {
         len = sprintf(abuf, "\033[%d;%d;%dM", encstate + 32, c, r);
        } else if (c <= 223 && r <= 223) {
         len = sprintf(abuf, "\033[M%c%c%c", encstate + 32, c + 32, r + 32);
        }

*)

--- Mystic BBS v1.12 A46 2020/05/17 (Windows/64)
* Origin: Sector 7 | Mystic WHQ (1:129/215)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.