fix setTerminal. add termswitch test.

This commit is contained in:
Christopher Jeffrey 2015-08-05 23:30:37 -07:00
parent 9b5673edf7
commit 64072411bb
3 changed files with 60 additions and 16 deletions

View File

@ -302,14 +302,9 @@ Program.prototype.__defineSetter__('terminal', function(terminal) {
});
Program.prototype.setTerminal = function(terminal) {
if (!this.tput) {
this._terminal = terminal;
delete this._tputSetup;
this.setupTput();
return;
}
this._terminal = terminal;
this.tput.terminal = terminal;
this.tput.setup();
};
Program.prototype.has = function(name) {

View File

@ -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() {

53
test/widget-termswitch.js Normal file
View File

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