diff --git a/lib/program.js b/lib/program.js index 1b7aa72..62b18b9 100644 --- a/lib/program.js +++ b/lib/program.js @@ -89,6 +89,8 @@ function Program(options) { this.isRxvt = /rxvt/i.test(process.env.COLORTERM); this.isXterm = false; + this.isTMUX = this.term('screen') && !!process.env.TMUX; + this._buf = ''; this._flush = this.flush.bind(this); @@ -3159,6 +3161,16 @@ Program.prototype.enableMouse = function() { if (this.term('xterm') || this.term('screen') || (this.tput && this.tput.strings.key_mouse)) { + // NOTE: Latest versions of tmux seem to only + // support cellMotion (not allMotion). + if (process.env.TMUX) { + return this.setMouse({ + vt200Mouse: true, + utfMouse: true, + cellMotion: true, + allMotion: true + }, true); + } return this.setMouse({ vt200Mouse: true, utfMouse: true, diff --git a/lib/widgets/element.js b/lib/widgets/element.js index a445d75..d5b2494 100644 --- a/lib/widgets/element.js +++ b/lib/widgets/element.js @@ -342,6 +342,7 @@ Element.prototype.setContent = function(content, noClear, noTags) { }; Element.prototype.getContent = function() { + if (!this._clines) return ''; return this._clines.fake.join('\n'); }; @@ -809,7 +810,7 @@ Element.prototype.enableDrag = function(verify) { this.onScreenEvent('mouse', this._dragM = function(data) { if (self.screen._dragging !== self) return; - if (data.action !== 'mousedown') { + if (data.action !== 'mousedown' && data.action !== 'mousemove') { delete self.screen._dragging; delete self._drag; return; diff --git a/lib/widgets/screen.js b/lib/widgets/screen.js index a417e6a..26c19ca 100644 --- a/lib/widgets/screen.js +++ b/lib/widgets/screen.js @@ -545,7 +545,11 @@ Screen.prototype._initHover = function() { self.render(); }); + // XXX This can cause problems if the + // terminal does not support allMotion. + // Workaround: check to see if content is set. this.on('element mouseup', function(el, data) { + if (!self._hoverText.getContent()) return; if (!el._hoverOptions) return; self.append(self._hoverText); self.render();