From 44017d988bc880f14e9aa30fd28612ff4e09b433 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 20 Jul 2015 04:02:43 -0700 Subject: [PATCH] more tmux 2.0 workarounds. --- README.md | 2 +- lib/program.js | 6 ++++-- lib/widgets/element.js | 1 + lib/widgets/listbar.js | 1 + lib/widgets/message.js | 1 + lib/widgets/terminal.js | 10 ++++++++++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0b0e478..ce550bd 100644 --- a/README.md +++ b/README.md @@ -467,7 +467,7 @@ The base element. - __border__ - Border object, see below. - __content__ - Element's text content. - __clickable__ - Element is clickable. -- __input__ - Element is focusable and can receive key input. +- __input, keyable__ - Element is focusable and can receive key input. - __focused__ - Element is focused. - __hidden__ - Whether the element is hidden. - __label__ - A simple text label for the element. diff --git a/lib/program.js b/lib/program.js index beae9f2..d25da4e 100644 --- a/lib/program.js +++ b/lib/program.js @@ -1496,11 +1496,13 @@ Program.prototype._write = function(text) { // Real: `DCS tmux; ESC Pt ESC \` Program.prototype._twrite = function(data) { if (this.tmux) { + // Replace all STs with BELs so they can be nested within the DCS code. + data = data.replace(/\x1b\\/g, '\x07'); + // Wrap in tmux forward DCS: data = '\x1bPtmux;\x1b' + data + '\x1b\\'; - // Should work but tmux doesn't implement ST correctly: - // data = '\x1bPtmux;\x1b' + data + '\x07'; // NOTE: Flushing the buffer is required in some cases. this.flush(); + // Write out raw now that the buffer is flushed. return this.output.write(data); } return this._write(data); diff --git a/lib/widgets/element.js b/lib/widgets/element.js index d80acf0..a0d4e8d 100644 --- a/lib/widgets/element.js +++ b/lib/widgets/element.js @@ -136,6 +136,7 @@ function Element(options) { if (this.border.bottom == null) this.border.bottom = true; } + // if (options.mouse || options.clickable) { if (options.clickable) { this.screen._listenMouse(this); } diff --git a/lib/widgets/listbar.js b/lib/widgets/listbar.js index c3a1b63..ac46768 100644 --- a/lib/widgets/listbar.js +++ b/lib/widgets/listbar.js @@ -262,6 +262,7 @@ Listbar.prototype.appendItem = function(item, callback) { this.select(0); } + // XXX May be affected by new element.options.mouse option. if (this.mouse) { el.on('click', function(data) { self.emit('action', el, self.selected); diff --git a/lib/widgets/message.js b/lib/widgets/message.js index 26dbfa9..8d3f8aa 100644 --- a/lib/widgets/message.js +++ b/lib/widgets/message.js @@ -97,6 +97,7 @@ Message.prototype.display = function(text, time, callback) { self.removeScreenEvent('keypress', fn); end(); }); + // XXX May be affected by new element.options.mouse option. if (!self.options.mouse) return; self.onScreenEvent('mouse', function fn(data) { if (data.action === 'mousemove') return; diff --git a/lib/widgets/terminal.js b/lib/widgets/terminal.js index 8a494a3..3b1891e 100644 --- a/lib/widgets/terminal.js +++ b/lib/widgets/terminal.js @@ -31,6 +31,11 @@ function Terminal(options) { Box.call(this, options); + // XXX Workaround for all motion + if (this.screen.program.tmux && this.screen.program.tmuxVersion >= 2) { + this.screen.program.enableMouse(); + } + this.handler = options.handler; this.shell = options.shell || process.env.SHELL || 'sh'; this.args = options.args || []; @@ -187,6 +192,11 @@ Terminal.prototype.bootstrap = function() { self.emit('title', title); }); + this.term.on('passthrough', function(data) { + self.screen.program.flush(); + self.screen.program.output.write(data); + }); + this.on('resize', function() { nextTick(function() { self.term.resize(self.width - self.iwidth, self.height - self.iheight);