From df73eb5e3edb9c6cb4d1fdba80a515a2abe523a5 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 31 Jan 2015 01:51:12 -0800 Subject: [PATCH] Revert "add workarounds for libvte mouse events. see #89." This reverts commit bb61e5c1446c3c3f3833fee5b8e0b52320926eae. --- lib/keys.js | 6 ------ lib/program.js | 28 +++++----------------------- test/program-mouse.js | 10 +--------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/lib/keys.js b/lib/keys.js index 1a0853b..8950648 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -117,12 +117,6 @@ function emitKey(stream, s) { } } - // libvte sometimes sends mouse events in chunks. - // deal with this in a better way later. - if (process.env.VTE_VERSION) { - if (~s.indexOf('\x1b[M')) return; - } - key.sequence = s; if (s === '\r') { diff --git a/lib/program.js b/lib/program.js index 9ead86c..7f9b11d 100644 --- a/lib/program.js +++ b/lib/program.js @@ -355,19 +355,13 @@ Program.prototype.bindMouse = function() { , self = this; this.on('data', function(data) { - var text = decoder.write(data); - if (!text) return; - self._bindMouse(text, data); + data = decoder.write(data); + if (!data) return; + self._bindMouse(data); }); }; -Program.saneMouse = /^\x1b\[M([\x00\u0020-\uffff]{3})/; -Program.vteMouse = /^\x1b\[M([\u0000-\uffff]{3})/; -Program.x10Mouse = !process.env.VTE_VERSION - ? Program.saneMouse - : Program.vteMouse; - -Program.prototype._bindMouse = function(s, buf) { +Program.prototype._bindMouse = function(s) { var self = this , key , parts; @@ -389,24 +383,12 @@ Program.prototype._bindMouse = function(s, buf) { } // XTerm / X10 - if (parts = Program.x10Mouse.exec(s)) { + if (parts = /^\x1b\[M([\x00\u0020-\uffff]{3})/.exec(s)) { var b = parts[1].charCodeAt(0) , x = parts[1].charCodeAt(1) , y = parts[1].charCodeAt(2) , mod; - if (process.env.VTE_VERSION) { - if (x > 65000) { - x = buf[4]; - } - - // if libvte goes over 255, it sends this. - // it can't go beyond 262 with this: - if (x > 0x00 && x < 0x20) { - x += 223; - } - } - key.name = 'mouse'; key.type = 'X10'; diff --git a/test/program-mouse.js b/test/program-mouse.js index 90e9eda..b5daa0f 100644 --- a/test/program-mouse.js +++ b/test/program-mouse.js @@ -22,14 +22,6 @@ program.on('mouse', function(data) { console.log(data); }); -program.input.on('data', function(data) { - program.cup(10, 0); - program.write(JSON.stringify(data + '')); - program.nel(); - program.cr(); - program.write(JSON.stringify(Array.prototype.slice.call(data))); -}); - program.key(['q', 'escape', 'C-c'], function() { program.showCursor(); program.disableMouse(); @@ -40,6 +32,6 @@ program.key(['q', 'escape', 'C-c'], function() { program.on('keypress', function(ch, data) { if (data.name === 'mouse') return; program.clear(); - program.cup(20, 0); + program.cup(0, 0); console.log(data); });