| robertwessel2@yahoo.com 2005-08-23, 6:55 pm |
|
Chris wrote:
> Ah - as usual, soon after posting out of frustration, I stumbled across
> my own answer.
>
> You need to use the decimal values of the coordinates and subtract 32
> from them to obtain column and row values.
>
> So - in my examples above:
>
> ! = 33 - 32 = 1
> " = 34 - 32 = 2
> 8 = 56 - 32 = 24
>
> Of course - the 't' does not work here ( t = 116 - 32 = 84 ), but that
> is because my emulator window was in fact set to 84 columns wide.
>
> With this in mind, I shoul dbe able to make my program "mouse aware".
>
> Has anyone had any experience with this? Any pointers/tips would be
> appreciated ...
My suggestion is to go yell at whoever came up with this scheme. It's
some perverse hybrid of ANSI and non-ANSI control sequence syntax. I
mean, for crying out load, attaching this device to a host that doesn't
have specific knowledge of it will cause all sorts of errors. At least
if the device *had* conformed to the usual CSI syntax, any host would
be able to parse the string, and say, I don't know what this is (and
perhaps issue a beep or an error message). Instead, it'll see CSI+M
(which will probably get the beep) plus three characters that it'll
treat as ordinary input.
FWIW, a CSI sequence should be of the form: "CSI P...P I...I F" where
P...P is zero or more parameter bytes in the range 0x30 to 0x3f, I...I
is zero or more intermediate bytes in the range 0x20 to 0x2f, and F is
a final byte terminating the sequence in the range 0x40 to 0x7e (which
is the critical item from a parsing perspective). So typically you'd
expect to see something like "CSI 12;45;2M" to define something like
this (where the three parameters might be row, column, button, and the
M is what terminates the sequence and defines its major meaning. If it
were done right, then a host could ignore/beep the sequence just like
it could ignore/beep a "CSI 123~" from a terminal with a hypothetical
F112 key.
Rant aside, you're probably just going to have to recognize the CSI M
initiator, and then suck in the next three characters. Note that CSI
can be coded as either "Esc [" (0x1b, 0x5b) or, if the terminal is in
eight bit mode, as the single character: 0x9b.
|