From 0eaff0bb071ff98f91a548048c0c93c3b6e4b65f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 18 Aug 2013 14:42:39 -0500 Subject: [PATCH] fix enter key workaround. minor. typo. --- lib/program.js | 13 ++++++++++--- lib/widget.js | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/program.js b/lib/program.js index 0b28036..9380a8e 100644 --- a/lib/program.js +++ b/lib/program.js @@ -259,9 +259,7 @@ Program.prototype.listen = function() { } if (key.name === 'return' && key.sequence === '\r') { - key.name = 'enter'; - self.input.emit('keypress', ch, key); - key.name = 'return'; + self.input.emit('keypress', ch, merge({}, key, { name: 'enter' })); } var name = (key.ctrl ? 'C-' : '') @@ -3568,6 +3566,15 @@ function unshiftEvent(obj, event, listener) { }); }; +function merge(out) { + slice.call(arguments, 1).forEach(function(obj) { + Object.keys(obj).forEach(function(key) { + out[key] = obj[key]; + }); + }); + return out; +} + /** * Expose */ diff --git a/lib/widget.js b/lib/widget.js index fa4df25..6ace8e9 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -893,7 +893,7 @@ Screen.prototype.draw = function(start, end) { } if (clr && neq) { - lx = ly = -1; + lx = -1, ly = -1; if (data !== attr) { out += this.codeAttr(data); attr = data; @@ -917,7 +917,7 @@ Screen.prototype.draw = function(start, end) { // supports it. Maybe only try to use ECH here. // //if (this.tput && this.tput.strings.erase_chars) // if (!clr && neq && (xx - x) > 10) { - // lx = ly = -1; + // lx = -1, ly = -1; // if (data !== attr) { // out += this.codeAttr(data); // attr = data; @@ -1860,7 +1860,7 @@ function Element(options) { }); this.on('detach', function() { - delete self._lpos; + delete self.lpos; }); if (options.hoverBg != null) {