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