allow VTE mouse access to cells up to 287. see #89.

This commit is contained in:
Christopher Jeffrey 2015-02-01 08:47:24 -08:00
parent 1d900c928d
commit e9b3bdac34
2 changed files with 24 additions and 2 deletions

View File

@ -401,6 +401,27 @@ Program.prototype._bindMouse = function(s, buf) {
} }
} }
// XTerm / X10 for buggy VTE
// VTE can only send unsigned chars and no unicode for coords. This limits
// them to 0xff. However, normally the x10 protocol does not allow a byte
// under 0x20, but since VTE can have the bytes overflow, we can consider
// bytes below 0x20 to be up to 0xff + 0x20. This gives a limit of 287. Since
// characters ranging from 223 to 248 confuse javascript's utf parser, we
// need to parse the raw binary.
if (this.isVTE && buf[0] === 0x1b && buf[1] === 0x5b && buf[2] === 0x4d) {
var b = buf[3]
, x = buf[4]
, y = buf[5];
if (x < 0x20) x += 255;
if (y < 0x20) y += 255;
s = '\x1b[M'
+ String.fromCharCode(b)
+ String.fromCharCode(x)
+ String.fromCharCode(y);
}
// XTerm / X10 // XTerm / X10
if (parts = /^\x1b\[M([\x00\u0020-\uffff]{3})/.exec(s)) { if (parts = /^\x1b\[M([\x00\u0020-\uffff]{3})/.exec(s)) {
var b = parts[1].charCodeAt(0) var b = parts[1].charCodeAt(0)

View File

@ -36,9 +36,10 @@ program.on('keypress', function(ch, data) {
console.log(data); console.log(data);
}); });
program.on('mousebuf', function(buf) { program.on('mouse-debug', function(data) {
program.cup(20, 0); program.cup(20, 0);
console.log(buf); data = Array.prototype.slice.call(data);
console.log(data);
}); });
// program.getCursor(function(err, data) { // program.getCursor(function(err, data) {