File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,25 @@ mergeInto(LibraryManager.library, {
96
96
}
97
97
return i ;
98
98
} ,
99
+ poll : function ( stream ) {
100
+ if ( ! stream . tty ) {
101
+ throw new FS . ErrnoError ( { { { cDefine ( 'EBADF' ) } } } ) ;
102
+ }
103
+ var ret = 0 ;
104
+ if ( Module . tty && Module . tty . poll_out ) {
105
+ if ( Module . tty . poll_out ( stream . tty ) ) {
106
+ ret |= { { { cDefine ( 'POLLOUT' ) } } } ;
107
+ }
108
+ } else {
109
+ ret |= { { { cDefine ( 'POLLOUT' ) } } } ;
110
+ }
111
+ if ( stream . tty . input . length ) {
112
+ ret |= { { { cDefine ( 'POLLIN' ) } } } ;
113
+ } else if ( Module . tty && Module . tty . poll_in && Module . tty . poll_in ( stream . tty ) ) {
114
+ ret |= { { { cDefine ( 'POLLIN' ) } } } ;
115
+ }
116
+ return ret ;
117
+ } ,
99
118
ioctl: function ( stream , op , argp ) {
100
119
if ( ! stream . tty ) {
101
120
throw new FS . ErrnoError ( { { { cDefine ( 'ENOTTY' ) } } } ) ;
Original file line number Diff line number Diff line change 88
88
< script type ='text/javascript '>
89
89
const term = new Terminal ( { convertEol : true , scrollback : 0 } ) ;
90
90
const fitAddon = new FitAddon . FitAddon ( ) ;
91
+ var inputBuf = [ ] ;
91
92
term . loadAddon ( fitAddon ) ;
92
93
term . open ( document . getElementById ( 'output' ) ) ;
93
94
fitAddon . fit ( ) ;
94
95
window . addEventListener ( 'resize' , ( ) => fitAddon . fit ( ) ) ;
96
+ term . onData ( data => inputBuf = inputBuf . concat ( intArrayFromString ( data ) ) ) ;
95
97
function write ( text ) {
96
98
if ( arguments . length > 1 ) text = Array . prototype . slice . call ( arguments ) . join ( ' ' ) ;
97
99
// These replacements are necessary if you render to raw HTML
109
111
term . write ( val ) ;
110
112
} ,
111
113
get_char : function ( tty ) {
112
- return undefined ;
114
+ if ( ! inputBuf . length ) return undefined ;
115
+ return inputBuf . shift ( ) ;
116
+ } ,
117
+ poll_in : function ( tty ) {
118
+ return inputBuf . length > 0 ;
113
119
} ,
114
120
get_winsize : function ( tty , winsize ) {
115
121
winsize . ws_row = term . rows ;
You can’t perform that action at this time.
0 commit comments