Transfer data gathering responsibility to readline
Fixes non-raw REPL/Debugger on Posix.
This commit is contained in:
Родитель
d4127717ac
Коммит
ba80d4d8a9
|
@ -566,7 +566,7 @@ function SourceInfo(body) {
|
||||||
function Interface() {
|
function Interface() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var term = this.term =
|
var term = this.term =
|
||||||
readline.createInterface(process.stdout, function (line) {
|
readline.createInterface(process.stdin, process.stdout, function (line) {
|
||||||
return self.complete(line);
|
return self.complete(line);
|
||||||
});
|
});
|
||||||
var child;
|
var child;
|
||||||
|
@ -578,9 +578,6 @@ function Interface() {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stdin = process.openStdin();
|
this.stdin = process.openStdin();
|
||||||
this.stdin.addListener('keypress', function(s, key) {
|
|
||||||
term.write(s, key);
|
|
||||||
});
|
|
||||||
|
|
||||||
term.setPrompt('debug> ');
|
term.setPrompt('debug> ');
|
||||||
term.prompt();
|
term.prompt();
|
||||||
|
|
|
@ -13,16 +13,23 @@ var EventEmitter = require('events').EventEmitter;
|
||||||
var tty = require('tty');
|
var tty = require('tty');
|
||||||
|
|
||||||
|
|
||||||
exports.createInterface = function(output, completer) {
|
exports.createInterface = function(input, output, completer) {
|
||||||
return new Interface(output, completer);
|
return new Interface(input, output, completer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function Interface(output, completer) {
|
function Interface(input, output, completer) {
|
||||||
if (!(this instanceof Interface)) return new Interface(output, completer);
|
if (!(this instanceof Interface)) {
|
||||||
|
return new Interface(input, output, completer);
|
||||||
|
}
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
this.input = input;
|
||||||
|
input.resume();
|
||||||
|
|
||||||
this.completer = completer;
|
this.completer = completer;
|
||||||
|
|
||||||
this.setPrompt('> ');
|
this.setPrompt('> ');
|
||||||
|
@ -33,8 +40,17 @@ function Interface(output, completer) {
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.enabled) {
|
if (!this.enabled) {
|
||||||
// input refers to stdin
|
input.on('data', function(data) {
|
||||||
|
self._normalWrite(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// input usually refers to stdin
|
||||||
|
input.on('keypress', function(s, key) {
|
||||||
|
self._ttyWrite(s, key);
|
||||||
|
});
|
||||||
|
|
||||||
// Current line
|
// Current line
|
||||||
this.line = '';
|
this.line = '';
|
||||||
|
|
|
@ -64,7 +64,7 @@ function REPLServer(prompt, stream) {
|
||||||
|
|
||||||
self.prompt = prompt || '> ';
|
self.prompt = prompt || '> ';
|
||||||
|
|
||||||
var rli = self.rli = rl.createInterface(self.outputStream, function(text) {
|
var rli = self.rli = rl.createInterface(self.inputStream, self.outputStream, function(text) {
|
||||||
return self.complete(text);
|
return self.complete(text);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -90,10 +90,6 @@ function REPLServer(prompt, stream) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.inputStream.addListener('keypress', function(s, key) {
|
|
||||||
rli.write(s, key);
|
|
||||||
});
|
|
||||||
|
|
||||||
rli.addListener('line', function(cmd) {
|
rli.addListener('line', function(cmd) {
|
||||||
var skipCatchall = false;
|
var skipCatchall = false;
|
||||||
cmd = trimWhitespace(cmd);
|
cmd = trimWhitespace(cmd);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче