|
767 | 767 | brightMagenta : '\x1b[1;35m', |
768 | 768 | brightCyan : '\x1b[1;36m', |
769 | 769 | brightWhite : '\x1b[1;37m', |
770 | | - // Custom Mahogany (RGB: 150, 40, 20) |
| 770 | + // Custom Mahogany (RGB:150,40,20) |
771 | 771 | mahogany : '\x1b[38;2;150;40;20m', |
772 | 772 |
|
773 | 773 | // Utility |
|
778 | 778 |
|
779 | 779 | const cursor = { |
780 | 780 |
|
781 | | - to : (x,y)=>term.write(`\x1b[${y};${x}H`), |
| 781 | + to : (x,y)=>term.write(`\x1b[${y+1};${x+1}H`), |
782 | 782 | up : (n=1)=>term.write(`\x1b[${n}A`), |
783 | 783 | down : (n=1)=>term.write(`\x1b[${n}B`), |
784 | 784 | home : ()=>term.write('\x1b[H'), |
|
878 | 878 |
|
879 | 879 | }//resume |
880 | 880 | term.write.xy = (x,y,txt)=>{ |
881 | | - // Save cursor |
| 881 | + |
882 | 882 | cursor.save(); |
883 | | - // Jump to x,y |
884 | 883 | cursor.to(x,y); |
885 | 884 | term.write(txt); |
886 | | - // restore cursor |
887 | 885 | cursor.restore(); |
888 | 886 |
|
889 | 887 | }//xy |
|
960 | 958 | s.stop(); |
961 | 959 | term.writeln.green('ok.'); //24 |
962 | 960 |
|
963 | | - |
| 961 | + term.write.xy(30,0,'node'); |
| 962 | + var s1 = spinner({x:35,y:0}); |
| 963 | + term.write.xy(45,0,'npm'); |
| 964 | + var s2 = spinner({x:49,y:0}); |
| 965 | + term.writeln('spawn jsh ... '); |
| 966 | + var s3 = spinner({x:14,y:1}); |
| 967 | + |
964 | 968 | var phase = {}; |
965 | 969 | phase.ct = 1; |
966 | 970 | phase.p1 = result=>{ |
967 | 971 |
|
| 972 | + s1.stop(); |
968 | 973 | var str = '??'; |
969 | 974 | if(result.code==0)str = result.output; |
970 | | - var x = term.end_of_text(1); |
971 | | - x+=2; |
972 | | - term.write.xy(x,1,'node '+str) |
| 975 | + term.write.xy(35,0,str) |
973 | 976 | phase.ct = 2 |
974 | 977 | phase.p2() |
975 | 978 |
|
|
979 | 982 | if(result)phase.p2.result = result; |
980 | 983 | if(phase.ct!=2)return; |
981 | 984 | if(!phase.p2.result)return; |
| 985 | + s2.stop(); |
982 | 986 | var str = '??'; |
983 | 987 | if(phase.p2.result.code==0)str = phase.p2.result.output; |
984 | | - var x = term.end_of_text(1); |
985 | | - x+=2; |
986 | | - term.write.xy(x,1,'npm '+str); |
| 988 | + term.write.xy(49,0,str); |
987 | 989 | phase.ct = 3; |
988 | 990 | phase.p3(); |
989 | 991 |
|
990 | 992 | }//p2 |
991 | | - phase.p3 = result=>{console.log('phase.p3',!!result); |
992 | | - |
| 993 | + phase.p3 = result=>{ |
| 994 | + //console.log('phase.p3',!!result); |
993 | 995 | if(result)shell = result; |
994 | 996 | if(phase.ct!=3)return; |
995 | 997 | if(!shell)return; |
| 998 | + s3.stop(); |
| 999 | + term.write.xy(14,1,`${colors.green}ok.${colors.reset}`); |
996 | 1000 | shell.output.pipeTo(output); |
997 | 1001 | input = shell.input.getWriter(); |
998 | 1002 | term.onData(data=>input.write(data)); |
999 | 1003 | //term.resize(); |
1000 | | - term.focus(); |
| 1004 | + setTimeout(()=>term.focus(),50); |
1001 | 1005 |
|
1002 | 1006 | }//p3 |
1003 | 1007 |
|
|
1161 | 1165 |
|
1162 | 1166 |
|
1163 | 1167 | async function prompt(){ |
1164 | | - |
| 1168 | + console.log('prompt'); |
1165 | 1169 | //await input.write('\u0003'); // Sends Ctrl+C to clear any junk |
1166 | 1170 | await input.write('\n'); // Sends Enter to get a clean prompt |
1167 | 1171 |
|
|
1197 | 1201 | spinner.timer = setInterval(()=>{ |
1198 | 1202 | // \r moves to start of line, colors.cyan makes it pop |
1199 | 1203 | cursor.save(); |
1200 | | - cursor.to(x+1,y); |
| 1204 | + cursor.to(x,y); |
1201 | 1205 | term.write(`${colors.cyan}${frames[i]}${colors.reset}`); |
1202 | 1206 | cursor.restore(); |
1203 | 1207 | i = (i+1)%frames.length; |
|
1215 | 1219 | // Clear the line, show cursor, and print final message |
1216 | 1220 | // \x1b[K clears from cursor to end of line |
1217 | 1221 | cursor.save(); |
1218 | | - cursor.to(x+1,y); |
| 1222 | + cursor.to(x,y); |
1219 | 1223 | term.write(' '); |
1220 | 1224 | cursor.restore(); |
1221 | 1225 | // Show cursor |
|
0 commit comments