I'm an amateur programmer who's interested in adding a click-drag method to the vt320 terminal emulator at http://javassh.org/download/source/de/mud/terminal/vt320.html. I'm looking through the source for mouse press function and came upon this:
byte b[] = new byte[6];
b[0] = 27;
b[1] = (byte) '[';
b[2] = (byte) 'M';
b[3] = (byte) mousecode;
b[4] = (byte) (0x20 + x + 1);
b[5] = (byte) (0x20 + y + 1);
write(b); // FIXME: writeSpecial here
Where x and y are the character positions and mousecode has to do with the mouse button. Seems fairly straightfoward to add a mouse drag message. Can anyone point me in the direction of what the bytes should be? Or am I missing a very obvious roadblock? I'm mostly interested in sending click-drag to vim, running on Connectbot for android. Seems like it would be a really sweet thing to have.
Terminal mouse mode is perhaps best described by xterm's ctlseqs document. In summary, when the terminal is in one of the mouse reporting modes, it sends events in the form
CSI M Ps Px Py
Where CSI is either the single C1 CSI control (0x9b
) or the two-byte sequence ESC (0x1b
) [.
Ps, Px and Py encode the "status", x and y coordinate, as a single byte which is offset by 0x20
to ensure it is a GL printable and not a C0 control byte. Px and Py should be obvious. Ps is a bitmask containing the following fields:
0
to 2
for buttons 1 to 3, or 3
for a release (it does not encode which button was released)Shift
modifier is held (though most terminals will capture mouse internally and not report it to applications in this condition)Alt
modifier is heldCtrl
modifier is heldThere are three mouse modes that use this reporting, all set by DECSM; Set DEC private mode (CSI ? Pn h):