more tmux 2.0 workarounds.

This commit is contained in:
Christopher Jeffrey 2015-07-20 04:02:43 -07:00
parent a04c944069
commit 44017d988b
6 changed files with 18 additions and 3 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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);