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() {
|
||||
var self = this;
|
||||
var term = this.term =
|
||||
readline.createInterface(process.stdout, function (line) {
|
||||
readline.createInterface(process.stdin, process.stdout, function (line) {
|
||||
return self.complete(line);
|
||||
});
|
||||
var child;
|
||||
|
@ -578,9 +578,6 @@ function Interface() {
|
|||
});
|
||||
|
||||
this.stdin = process.openStdin();
|
||||
this.stdin.addListener('keypress', function(s, key) {
|
||||
term.write(s, key);
|
||||
});
|
||||
|
||||
term.setPrompt('debug> ');
|
||||
term.prompt();
|
||||
|
|
|
@ -13,16 +13,23 @@ var EventEmitter = require('events').EventEmitter;
|
|||
var tty = require('tty');
|
||||
|
||||
|
||||
exports.createInterface = function(output, completer) {
|
||||
return new Interface(output, completer);
|
||||
exports.createInterface = function(input, output, completer) {
|
||||
return new Interface(input, output, completer);
|
||||
};
|
||||
|
||||
|
||||
function Interface(output, completer) {
|
||||
if (!(this instanceof Interface)) return new Interface(output, completer);
|
||||
function Interface(input, output, completer) {
|
||||
if (!(this instanceof Interface)) {
|
||||
return new Interface(input, output, completer);
|
||||
}
|
||||
EventEmitter.call(this);
|
||||
|
||||
var self = this;
|
||||
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
input.resume();
|
||||
|
||||
this.completer = completer;
|
||||
|
||||
this.setPrompt('> ');
|
||||
|
@ -33,8 +40,17 @@ function Interface(output, completer) {
|
|||
this.enabled = false;
|
||||
}
|
||||
|
||||
if (this.enabled) {
|
||||
// input refers to stdin
|
||||
if (!this.enabled) {
|
||||
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
|
||||
this.line = '';
|
||||
|
|
|
@ -64,7 +64,7 @@ function REPLServer(prompt, stream) {
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
|
@ -90,10 +90,6 @@ function REPLServer(prompt, stream) {
|
|||
}
|
||||
});
|
||||
|
||||
self.inputStream.addListener('keypress', function(s, key) {
|
||||
rli.write(s, key);
|
||||
});
|
||||
|
||||
rli.addListener('line', function(cmd) {
|
||||
var skipCatchall = false;
|
||||
cmd = trimWhitespace(cmd);
|
||||
|
|
Загрузка…
Ссылка в новой задаче