|
@ -66,6 +66,7 @@ ReadStream.prototype.isTTY = true; |
|
|
Some patterns seen in terminal key escape codes, derived from combos seen |
|
|
Some patterns seen in terminal key escape codes, derived from combos seen |
|
|
at http://www.midnight-commander.org/browser/lib/tty/key.c
|
|
|
at http://www.midnight-commander.org/browser/lib/tty/key.c
|
|
|
|
|
|
|
|
|
|
|
|
ESC letter |
|
|
ESC [ letter |
|
|
ESC [ letter |
|
|
ESC [ modifier letter |
|
|
ESC [ modifier letter |
|
|
ESC [ 1 ; modifier letter |
|
|
ESC [ 1 ; modifier letter |
|
@ -89,9 +90,10 @@ ReadStream.prototype.isTTY = true; |
|
|
- two leading ESCs apparently mean the same as one leading ESC |
|
|
- two leading ESCs apparently mean the same as one leading ESC |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
// Regex used for ansi escape code splitting
|
|
|
// Regexes used for ansi escape code splitting
|
|
|
var splitKeyCodeRe = |
|
|
var metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/, |
|
|
/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;(\d+))?([a-zA-Z]))/; |
|
|
functionKeyCodeRe = |
|
|
|
|
|
/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;(\d+))?([a-zA-Z]))/; |
|
|
|
|
|
|
|
|
ReadStream.prototype._emitKey = function(s) { |
|
|
ReadStream.prototype._emitKey = function(s) { |
|
|
var char, |
|
|
var char, |
|
@ -140,7 +142,13 @@ ReadStream.prototype._emitKey = function(s) { |
|
|
key.name = s.toLowerCase(); |
|
|
key.name = s.toLowerCase(); |
|
|
key.shift = true; |
|
|
key.shift = true; |
|
|
|
|
|
|
|
|
} else if (parts = splitKeyCodeRe.exec(s)) { |
|
|
} else if (parts = metaKeyCodeRe.exec(s)) { |
|
|
|
|
|
// meta+character key
|
|
|
|
|
|
key.name = parts[1].toLowerCase(); |
|
|
|
|
|
key.meta = true; |
|
|
|
|
|
key.shift = /^[A-Z]$/.test(parts[1]); |
|
|
|
|
|
|
|
|
|
|
|
} else if (parts = functionKeyCodeRe.exec(s)) { |
|
|
// ansi escape sequence
|
|
|
// ansi escape sequence
|
|
|
|
|
|
|
|
|
// reassemble the key code leaving out leading \x1b's,
|
|
|
// reassemble the key code leaving out leading \x1b's,
|
|
|