diff options
author | David Walter Seikel | 2014-04-15 18:41:02 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-04-15 18:41:02 +1000 |
commit | af7889727e2e86f4cd2709173be4522db044e78e (patch) | |
tree | 9a57d548933fd2e77dd2cd69a44bd81dcb6f79f5 | |
parent | Switch to xread, remove excess error checking stuff. (diff) | |
download | boxes-af7889727e2e86f4cd2709173be4522db044e78e.zip boxes-af7889727e2e86f4cd2709173be4522db044e78e.tar.gz boxes-af7889727e2e86f4cd2709173be4522db044e78e.tar.bz2 boxes-af7889727e2e86f4cd2709173be4522db044e78e.tar.xz |
Better comments about CSI.
Diffstat (limited to '')
-rw-r--r-- | handlekeys.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/handlekeys.c b/handlekeys.c index 4938039..e605966 100644 --- a/handlekeys.c +++ b/handlekeys.c | |||
@@ -276,6 +276,8 @@ void handle_keys(long extra, int (*handle_event)(long extra, struct keyevent *ev | |||
276 | if (pendingEsc) continue; | 276 | if (pendingEsc) continue; |
277 | 277 | ||
278 | // Check if it's a CSI before we check for the known key sequences. | 278 | // Check if it's a CSI before we check for the known key sequences. |
279 | // C29B is the UTF8 encoding of CSI. | ||
280 | // In all cases we reduce CSI to 9B to keep the keys table shorter. | ||
279 | if ((('\x1B' == buffer[0]) && ('[' == buffer[1])) | 281 | if ((('\x1B' == buffer[0]) && ('[' == buffer[1])) |
280 | || (('\xC2' == buffer[0]) && ('\x9B' == buffer[1]))) | 282 | || (('\xC2' == buffer[0]) && ('\x9B' == buffer[1]))) |
281 | { | 283 | { |
@@ -305,25 +307,32 @@ void handle_keys(long extra, int (*handle_event)(long extra, struct keyevent *ev | |||
305 | if (csi) | 307 | if (csi) |
306 | { | 308 | { |
307 | /* ECMA-048 section 5.2 defines this, and is unreadable. | 309 | /* ECMA-048 section 5.2 defines this, and is unreadable. |
308 | * General CSI format - CSI [private] n1 ; n2 [extra] final | 310 | * So I'll include some notes here that tries to simplify that. |
309 | * private 0x3c to 0x3f "<=>?" If first byte is one of these, | 311 | * |
310 | * this is a private command, if it's | 312 | * The CSI format is - CSI [private] n1 ; n2 [extra] final |
311 | * one of the other n1 ones, | 313 | * Each of those parts, except for the initial CSI bytes, is an ordinary |
312 | * it's not private. | 314 | * ASCII character. |
313 | * n1 0x30 to 0x3f "01234567890:;<=>?" | 315 | * |
314 | * ASCII digits forming a "number" | 316 | * The optional [private] part is one of these characters "<=>?". |
315 | * 0x3a ":" Used for floats, not expecting any. | 317 | * If the first byte is one of these, then this is a private command, if |
316 | * Could also be used as some other sort of | 318 | * it's one of the other n1 ones, it's not private. |
317 | * inter digit separator. | 319 | * |
318 | * 0x3b [;] Separates the parameters. | 320 | * Next is a semi colon separated list of parameters (n1, n2, etc), which |
319 | * extra 0x20 to 0x2f [ !"#$%&'()*+,-./] | 321 | * can be any characters from this set "01234567890:;<=>?". What the non |
320 | * Can be multiple, likely isn't. | 322 | * digit ones mean is up to the command. Parameters can be left out, but |
321 | * final 0x40 to 0x7e "@A .. Z[\]^_`a .. z{|}~" | 323 | * their defaults are command dependant. |
322 | * It's private if 0x70 to 0x7e "p .. z{|}~" | 324 | * |
323 | * Though the "private" ~ is used for key codes. | 325 | * Next is an optional [extra] part from this set of characters |
324 | * We also have SS3 "\x1BO" for other keys, | 326 | * "!#$%&'()*+,-./", which includes double quotes. Can be many of these, |
325 | * but that's not a CSI. | 327 | * likely isn't. |
326 | * C0 controls, DEL (0x7f), or high characters are undefined. | 328 | * |
329 | * Finally is the "final" from this set of characters "@[\]^_`{|}~", plus | ||
330 | * upper and lower case letters. It's private if it's one of these | ||
331 | * "pqrstuvwxyz{|}~". Though the "private" ~ is used for key codes. | ||
332 | * | ||
333 | * A full CSI command is the private, extra, and final parts. | ||
334 | * | ||
335 | * Any C0 controls, DEL (0x7f), or higher characters are undefined. | ||
327 | * TODO - So abort the current CSI and start from scratch on one of those. | 336 | * TODO - So abort the current CSI and start from scratch on one of those. |
328 | */ | 337 | */ |
329 | 338 | ||