File tree Expand file tree Collapse file tree
utils/misc/nodejs-terminal/v2.0 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 903903
904904 term . write ( 'booting container ... ' )
905905 webcontainer = await WebContainer . boot ( ) ;
906- term . writeln . green ( 'ok' ) ; //24
907-
908906 mod . stack . complete ;
909-
910-
907+ term . write . green ( 'ok' ) ; //24
908+ term . writeln ( ', ' ) ;
909+
910+
911911 var phase = { } ;
912912 phase . ct = 1 ;
913913 phase . p1 = result => {
914914
915915 var str = '??' ;
916916 if ( result . code == 0 ) str = result . output ;
917- term . write . xy ( 30 , 1 , 'node ' + str )
917+ var x = end_of_text ( 1 ) ;
918+ x ++ ;
919+ term . write . xy ( x , 1 , 'node ' + str + ' ,' )
918920 phase . ct = 2
919921 phase . p2 ( )
920922
926928 if ( ! phase . p2 . result ) return ;
927929 var str = '??' ;
928930 if ( phase . p2 . result . code == 0 ) str = phase . p2 . result . output ;
929- term . write . xy ( 50 , 1 , 'npm ' + str ) ;
931+ var x = end_of_text ( 1 ) ;
932+ x ++ ;
933+ term . write . xy ( x , 1 , 'npm ' + str ) ;
930934 phase . ct = 3 ;
931935 phase . p3 ( ) ;
932936
11451149 } //stop
11461150
11471151
1152+ function end_of_text ( y ) {
1153+ // xterm.js uses 0-based indexing for the buffer,
1154+ // but 1-based for ANSI
1155+ var line = term . buffer . active . getLine ( y - 1 ) ;
1156+ if ( ! line ) {
1157+ return 1 ;
1158+ }
1159+
1160+ var last = 0 ;
1161+ for ( var i = term . cols - 1 ; i >= 0 ; i -- ) {
1162+
1163+ var cell = line . getCell ( i ) ;
1164+ // Check if the cell is not empty/whitespace
1165+ if ( cell && cell . getChars ( ) . trim ( ) !== '' ) {
1166+ last = i + 1 ;
1167+ break ;
1168+ }
1169+
1170+ } //for
1171+ return last + 1 ;
1172+
1173+ } //end_of_text
1174+
1175+
11481176 //:
11491177
11501178
You can’t perform that action at this time.
0 commit comments