diff --git a/lib/program.js b/lib/program.js index 42cc81e..6412682 100644 --- a/lib/program.js +++ b/lib/program.js @@ -302,14 +302,9 @@ Program.prototype.__defineSetter__('terminal', function(terminal) { }); Program.prototype.setTerminal = function(terminal) { - if (!this.tput) { - this._terminal = terminal; - this.setupTput(); - return; - } this._terminal = terminal; - this.tput.terminal = terminal; - this.tput.setup(); + delete this._tputSetup; + this.setupTput(); }; Program.prototype.has = function(name) { diff --git a/lib/widgets/screen.js b/lib/widgets/screen.js index 5ece71d..a443c44 100644 --- a/lib/widgets/screen.js +++ b/lib/widgets/screen.js @@ -257,25 +257,21 @@ Screen.prototype.__defineGetter__('terminal', function() { }); Screen.prototype.__defineSetter__('terminal', function(terminal) { - return this.program.terminal = terminal; + this.setTerminal(terminal); + return this.program.terminal; }); Screen.prototype.setTerminal = function(terminal) { - var entered = !!this.program.isAlt - , result; - + var entered = !!this.program.isAlt; if (entered) { this.program._buf = ''; this.leave(); } - - result = this.program.setTerminal(terminal); - + this.program.setTerminal(terminal); + this.tput = this.program.tput; if (entered) { this.enter(); } - - return result; }; Screen.prototype.enter = function() { diff --git a/test/widget-termswitch.js b/test/widget-termswitch.js new file mode 100644 index 0000000..3a8752c --- /dev/null +++ b/test/widget-termswitch.js @@ -0,0 +1,53 @@ +var blessed = require('../') + , screen; + +screen = blessed.screen({ + dump: __dirname + '/logs/termswitch.log', + smartCSR: true, + warnings: true +}); + +var lorem = require('fs').readFileSync(__dirname + '/git.diff', 'utf8'); + +var btext = blessed.box({ + parent: screen, + left: 'center', + top: 'center', + width: '80%', + height: '80%', + style: { + bg: 'green' + }, + border: 'line', + content: 'CSR should still work.' +}); + +var text = blessed.scrollabletext({ + parent: screen, + content: lorem, + border: 'line', + left: 'center', + top: 'center', + draggable: true, + width: '50%', + height: '50%', + mouse: true, + keys: true, + vi: true +}); + +text.focus(); + +screen.key('q', function() { + return process.exit(0); +}); + +screen.render(); + +setTimeout(function() { + // screen.setTerminal('vt100'); + screen.terminal = 'vt100'; + screen.render(); + text.setContent(screen.program._terminal); + screen.render(); +}, 1000);