fix initial setContent call. fix spawn() cursor handling.

This commit is contained in:
Christopher Jeffrey 2013-07-23 16:37:54 -05:00
parent da49a89b28
commit 9aaabacf68
2 changed files with 38 additions and 41 deletions

View File

@ -1416,7 +1416,7 @@ Program.prototype.lrestoreCursor = function(key, hide) {
var key = key || 'local', pos;
if (!this._saved || !this._saved[key]) return;
pos = this._saved[key];
delete this._saved[key];
//delete this._saved[key];
this.cup(pos.y, pos.x);
if (hide && pos.hidden !== this.cursorHidden) {
if (pos.hidden) {
@ -1745,6 +1745,7 @@ Program.prototype.eraseInDisplay = function(param) {
};
Program.prototype.clear = function() {
this.x = this.y = 0;
if (this.tput) return this.put.clear();
return this.write('\x1b[H\x1b[J');
// return this.ed('all');
@ -3372,11 +3373,18 @@ Program.prototype.out = function(name) {
Program.prototype.sigtstp = function(callback) {
var self = this
, isAlt = this.isAlt
, currentMouse = this._currentMouse
, cursorHidden = this.cursorHidden;
, currentMouse = this._currentMouse;
this.lsaveCursor('sigtstp');
//this.csr(0, screen.height - 1);
if (isAlt) this.normalBuffer();
this.showCursor();
if (currentMouse) this.disableMouse();
var write = this.output.write;
this.output.write = function() {};
this.input.setRawMode(false);
this.input.pause();
process.once('SIGCONT', function() {
self.input.setRawMode(true);
@ -3384,21 +3392,13 @@ Program.prototype.sigtstp = function(callback) {
self.output.write = write;
if (isAlt) self.alternateBuffer();
if (cursorHidden) self.hideCursor();
//self.csr(0, screen.height - 1);
if (currentMouse) self.enableMouse();
self.cup(self.y, self.x);
self.lrestoreCursor('sigtstp', true);
if (callback) callback();
});
if (currentMouse) this.disableMouse();
if (cursorHidden) this.showCursor();
if (isAlt) this.normalBuffer();
this.input.setRawMode(false);
this.input.pause();
process.kill(process.pid, 'SIGTSTP');
};

View File

@ -1395,49 +1395,45 @@ Screen.prototype.spawn = function(file, args, options) {
args = [];
}
var options = options || {}
var screen = this
, program = screen.program
, options = options || {}
, spawn = require('child_process').spawn
, screen = this;
, mouse = program._currentMouse
, ps;
options.stdio = 'inherit';
screen.program.saveCursor();
screen.program.normalBuffer();
screen.program.showCursor();
program.lsaveCursor('spawn');
//program.csr(0, program.rows - 1);
program.normalBuffer();
program.showCursor();
if (mouse) program.disableMouse();
var listenedMouse = screen._listenedMouse;
if (listenedMouse) {
screen.program.disableMouse();
}
var write = screen.program.output.write;
screen.program.output.write = function() {};
screen.program.input.pause();
screen.program.input.setRawMode(false);
var write = program.output.write;
program.output.write = function() {};
program.input.pause();
program.input.setRawMode(false);
var resume = function() {
if (resume.done) return;
resume.done = true;
screen.program.input.setRawMode(true);
screen.program.input.resume();
screen.program.output.write = write;
program.input.setRawMode(true);
program.input.resume();
program.output.write = write;
screen.program.alternateBuffer();
// Restoring the cursor, or resetting to program.x/y - either works.
// Technically, restoring cursor might be more foolproof.
// screen.program.cup(screen.program.y, screen.program.x);
screen.program.restoreCursor();
screen.program.hideCursor();
if (listenedMouse) {
screen.program.enableMouse();
}
program.alternateBuffer();
//program.csr(0, program.rows - 1);
if (mouse) program.enableMouse();
screen.alloc();
screen.render();
screen.program.lrestoreCursor('spawn', true);
};
var ps = spawn(file, args, options);
ps = spawn(file, args, options);
ps.on('error', resume);
@ -1560,6 +1556,7 @@ Screen.prototype.sigtstp = function(callback) {
this.program.sigtstp(function() {
self.alloc();
self.render();
self.program.lrestoreCursor('sigtstp', true);
if (callback) callback();
});
};
@ -1662,7 +1659,7 @@ function Element(options) {
this.parseTags = options.parseTags || options.tags;
this.setContent(options.content || '');
this.setContent(options.content || '', true);
if (options.label) {
this.append(new Box({