return sourceText + '\n' + underline;
}
+
function SourceInfo(body) {
var result = '';
self.killChild();
});
- var stdin = process.openStdin();
- stdin.addListener('data', function(chunk) {
+ this.stdin = process.openStdin();
+ this.stdin.addListener('data', function(chunk) {
term.write(chunk);
});
this.quitTried = false;
+ process.on('SIGINT', function () {
+ self.handleSIGINT();
+ });
term.on('SIGINT', function () {
- self.tryQuit();
+ self.handleSIGINT();
});
-
term.on('close', function () {
self.tryQuit();
});
}
+Interface.prototype.handleSIGINT = function() {
+ if (this.paused) {
+ this.child.kill('SIGINT');
+ } else {
+ this.tryQuit();
+ }
+};
+
+
Interface.prototype.tryQuit = function() {
if (this.quitTried) return;
this.quitTried = true;
};
+Interface.prototype.pause = function() {
+ this.paused = true;
+ this.stdin.pause();
+ this.term.pause();
+};
+
+
+Interface.prototype.resume = function() {
+ if (!this.paused) return false
+ this.paused = false;
+ this.stdin.resume();
+ this.term.resume();
+ this.term.prompt();
+ return true;
+};
+
+
Interface.prototype.handleBreak = function(r) {
var result = '';
if (r.breakpoints) {
console.log(result);
- this.term.prompt();
+ if(!this.resume()) this.term.prompt();
};
self.printNotConnected();
return;
}
- client.reqContinue();
+
+ self.pause();
+ client.reqContinue(function () {
+ self.resume();
+ });
} else if (/^k(ill)?/.test(cmd)) {
if (!client) {
this.client.destroy();
this.client = null;
}
+
+ this.resume();
};
Interface.prototype.trySpawn = function(cb) {
+ var self = this;
+
this.killChild();
this.child = spawn(process.execPath, args, { customFds: [0, 1, 2] });
- var self = this;
+
+ this.pause();
+
setTimeout(function () {
process.stdout.write("connecting...");
var client = self.client = new Client();
// since we did debug-brk, we're hitting a break point immediately
// continue before anything else.
- client.reqContinue();
-
- if (cb) cb();
+ client.reqContinue(function () {
+ if (cb) cb();
+ });
});
client.on('close', function () {
console.log("\nprogram terminated");
self.client = null;
self.killChild();
+ self.term.prompt();
});
client.on('unhandledResponse', function (res) {