How to have a terminal emulator send click drag messages?

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.

Answers


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:

  • Bits 0 to 1 encode the button number; 0 to 2 for buttons 1 to 3, or 3 for a release (it does not encode which button was released)
  • Bit 2 is set if the Shift modifier is held (though most terminals will capture mouse internally and not report it to applications in this condition)
  • Bit 3 is set if the Alt modifier is held
  • Bit 4 is set if the Ctrl modifier is held
  • Bit 5 is set if the mouse event is a drag motion rather than a press.
  • Bit 6 is set to extend the mouse button range to buttons 4 and 5, used for the scroll wheel.

There are three mouse modes that use this reporting, all set by DECSM; Set DEC private mode (CSI ? Pn h):

  • Mode 1000 reports mouse press and release events only
  • Mode 1002 reports mouse press, release, and motion when a button is held (drag)
  • Mode 1003 reports mouse press, release, and motion events even without a button held

Need Your Help

How to get Page ID from Facebook Iframe

javascript html facebook iframe

After I installed the iframehost app and edited content. The app how to know my page id and render the content successfully. I want to make an app such as it.

what's wrong with this approach re referencing another project in Xcode 4?

iphone xcode ios xcode4

I'm trying to reference another Xcode4 project within Xcode4 but having troubles - what's I'm currently doing is as follows: