@@ -13,16 +13,23 @@ var EventEmitter = require('events').EventEmitter;
1313var tty = require ( 'tty' ) ;
1414
1515
16- exports . createInterface = function ( output , completer ) {
17- return new Interface ( output , completer ) ;
16+ exports . createInterface = function ( input , output , completer ) {
17+ return new Interface ( input , output , completer ) ;
1818} ;
1919
2020
21- function Interface ( output , completer ) {
22- if ( ! ( this instanceof Interface ) ) return new Interface ( output , completer ) ;
21+ function Interface ( input , output , completer ) {
22+ if ( ! ( this instanceof Interface ) ) {
23+ return new Interface ( input , output , completer ) ;
24+ }
2325 EventEmitter . call ( this ) ;
2426
27+ var self = this ;
28+
2529 this . output = output ;
30+ this . input = input ;
31+ input . resume ( ) ;
32+
2633 this . completer = completer ;
2734
2835 this . setPrompt ( '> ' ) ;
@@ -33,8 +40,17 @@ function Interface(output, completer) {
3340 this . enabled = false ;
3441 }
3542
36- if ( this . enabled ) {
37- // input refers to stdin
43+ if ( ! this . enabled ) {
44+ input . on ( 'data' , function ( data ) {
45+ self . _normalWrite ( data ) ;
46+ } ) ;
47+
48+ } else {
49+
50+ // input usually refers to stdin
51+ input . on ( 'keypress' , function ( s , key ) {
52+ self . _ttyWrite ( s , key ) ;
53+ } ) ;
3854
3955 // Current line
4056 this . line = '' ;
0 commit comments