misc. add sigtstp method.

This commit is contained in:
Christopher Jeffrey 2013-07-14 10:06:28 -05:00
parent 990fb0d796
commit 6a44fd9a35
4 changed files with 59 additions and 22 deletions

View File

@ -2145,6 +2145,7 @@ Program.prototype.showCursor = function() {
Program.prototype.alternate =
Program.prototype.smcup =
Program.prototype.alternateBuffer = function() {
this.isAlt = true;
if (this.tput) return this.put.smcup();
if (this.term('vt') || this.term('linux')) return;
//return this.setMode('?47');
@ -2259,6 +2260,7 @@ Program.prototype.hideCursor = function() {
Program.prototype.rmcup =
Program.prototype.normalBuffer = function() {
this.isAlt = false;
//return this.resetMode('?47');
//return this.resetMode('?1047');
if (this.tput) return this.put.rmcup();
@ -3071,6 +3073,39 @@ Program.prototype.out = function(name) {
return this._odata;
};
Program.prototype.sigtstp = function(callback) {
var self = this
, isAlt = this.isAlt
, currentMouse = this._currentMouse
, cursorHidden = this.cursorHidden;
var write = this.output.write;
this.output.write = function() {};
process.once('SIGCONT', function() {
self.input.setRawMode(true);
self.input.resume();
self.output.write = write;
if (isAlt) self.alternateBuffer();
if (cursorHidden) self.hideCursor();
if (currentMouse) self.enableMouse();
self.cup(self.y, self.x);
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');
};
/**
* Expose
*/

View File

@ -2147,7 +2147,7 @@ Tput.strings = [
// DEC Special Character and Line Drawing Set.
// Taken from tty.js.
Tput.acsc = { // (0
Tput.acsc = { // (0
'`': '\u25c6', // '◆'
'a': '\u2592', // '▒'
'b': '\u0009', // '\t'
@ -2181,10 +2181,6 @@ Tput.acsc = { // (0
'~': '\u00b7' // '·'
};
// ['b', 'c', 'd', 'e', 'h', 'i'].forEach(function(ch) {
// delete Tput.acsc[ch];
// });
/**
* Expose
*/

View File

@ -929,30 +929,23 @@ Screen.prototype.spawn = function(file, args, options) {
screen.program.normalBuffer();
screen.program.showCursor();
var _listenedMouse = screen._listenedMouse;
if (_listenedMouse) {
var listenedMouse = screen._listenedMouse;
if (listenedMouse) {
screen.program.disableMouse();
}
var write = process.stdout.write;
process.stdout.write = function() {};
try {
process.stdin.pause();
} catch (e) {
;
}
var write = screen.program.output.write;
screen.program.output.write = function() {};
screen.program.input.pause();
screen.program.input.setRawMode(false);
var resume = function() {
if (resume.done) return;
resume.done = true;
try {
process.stdin.resume();
} catch (e) {
;
}
process.stdout.write = write;
screen.program.input.setRawMode(true);
screen.program.input.resume();
screen.program.output.write = write;
screen.program.alternateBuffer();
// Restoring the cursor, or resetting to program.x/y - either works.
@ -960,7 +953,7 @@ Screen.prototype.spawn = function(file, args, options) {
// screen.program.cup(screen.program.y, screen.program.x);
screen.program.restoreCursor();
screen.program.hideCursor();
if (_listenedMouse) {
if (listenedMouse) {
screen.program.enableMouse();
}
@ -1086,6 +1079,15 @@ Screen.prototype.setEffects = function(el, fel, over, out, effects, temp) {
});
};
Screen.prototype.sigtstp = function(callback) {
var self = this;
this.program.sigtstp(function() {
self.alloc();
self.render();
if (callback) callback();
});
};
/**
* Element
*/

View File

@ -248,6 +248,10 @@ screen.on('keypress', function(ch, key) {
}
});
screen.key('C-z', function() {
screen.sigtstp();
});
list.focus();
//screen.on('element click', function(el) {