From 5d72fb1938bfd31e67d3e6dff83572701e298412 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 17 Feb 2015 22:12:49 -0800 Subject: [PATCH] fix Terminal element. check for allocated gpmclient. --- lib/program.js | 2 ++ lib/widget.js | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/program.js b/lib/program.js index d20eeba..b9ebc96 100644 --- a/lib/program.js +++ b/lib/program.js @@ -750,6 +750,8 @@ Program.prototype.enableGpm = function() { var self = this; var gpmclient = require('./gpmclient') + if (this.gpm) return; + this.gpm = gpmclient(); this.gpm.on('btndown', function(btn, modifier, x, y) { diff --git a/lib/widget.js b/lib/widget.js index ce4f8b5..43ee042 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -6596,10 +6596,12 @@ Terminal.prototype.bootstrap = function() { this.screen.on('mouse', function(data) { if (self.screen.focused !== self) return; + if (data.x < self.left + self.ileft) return; if (data.y < self.top + self.itop) return; if (data.x > self.left - self.ileft + self.width) return; if (data.y > self.top - self.itop + self.height) return; + if (self.term.x10Mouse || self.term.vt200Mouse || self.term.normalMouse @@ -6611,13 +6613,14 @@ Terminal.prototype.bootstrap = function() { } else { return; } - var b = data.raw[0]; - //var x = data.x - (self.left + self.ileft); - //var y = data.y - (self.top + self.itop); - var x = data.x - self.left; - var y = data.y - self.top; + + var b = data.raw[0] + , x = data.x - self.left + , y = data.y - self.top + , s; + if (self.term.urxvtMouse) { - var s = '\x1b[' + s = '\x1b[' + String.fromCharCode(b) + ';' + String.fromCharCode(x) @@ -6628,7 +6631,7 @@ Terminal.prototype.bootstrap = function() { if (!self.screen.program.sgrMouse) { b -= 32; } - var s = '\x1b[<' + s = '\x1b[<' + String.fromCharCode(b) + ';' + String.fromCharCode(x) @@ -6636,11 +6639,12 @@ Terminal.prototype.bootstrap = function() { + String.fromCharCode(y) + (data.action === 'mousedown' ? 'M' : 'm'); } else { - var s = '\x1b[M' + s = '\x1b[M' + String.fromCharCode(b) + String.fromCharCode(x + 32) + String.fromCharCode(y + 32); } + self.handler(s); }); @@ -6749,18 +6753,14 @@ Terminal.prototype.render = function() { // default foreground = 257 if (((line[x][0] >> 9) & 0x1ff) === 257) { - if (!((line[x][0] >> 18) & 8)) { - line[x][0] &= ~(0x1ff << 9); - line[x][0] |= ((this.dattr >> 9) & 0x1ff) << 9; - } + line[x][0] &= ~(0x1ff << 9); + line[x][0] |= ((this.dattr >> 9) & 0x1ff) << 9; } // default background = 256 if ((line[x][0] & 0x1ff) === 256) { - if (!((line[x][0] >> 18) & 8)) { - line[x][0] &= ~0x1ff; - line[x][0] |= this.dattr & 0x1ff; - } + line[x][0] &= ~0x1ff; + line[x][0] |= this.dattr & 0x1ff; } }