Skip to content

Commit bb32a6b

Browse files
save file
1 parent a6eb09c commit bb32a6b

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

utils/misc/nodejs-terminal/v2.0/nodejs-terminal-v2.0.html

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@
767767
brightMagenta : '\x1b[1;35m',
768768
brightCyan : '\x1b[1;36m',
769769
brightWhite : '\x1b[1;37m',
770-
// Custom Mahogany (RGB: 150, 40, 20)
770+
// Custom Mahogany (RGB:150,40,20)
771771
mahogany : '\x1b[38;2;150;40;20m',
772772

773773
// Utility
@@ -778,7 +778,7 @@
778778

779779
const cursor = {
780780

781-
to : (x,y)=>term.write(`\x1b[${y};${x}H`),
781+
to : (x,y)=>term.write(`\x1b[${y+1};${x+1}H`),
782782
up : (n=1)=>term.write(`\x1b[${n}A`),
783783
down : (n=1)=>term.write(`\x1b[${n}B`),
784784
home : ()=>term.write('\x1b[H'),
@@ -878,12 +878,10 @@
878878

879879
}//resume
880880
term.write.xy = (x,y,txt)=>{
881-
// Save cursor
881+
882882
cursor.save();
883-
// Jump to x,y
884883
cursor.to(x,y);
885884
term.write(txt);
886-
// restore cursor
887885
cursor.restore();
888886

889887
}//xy
@@ -960,16 +958,21 @@
960958
s.stop();
961959
term.writeln.green('ok.'); //24
962960

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+
964968
var phase = {};
965969
phase.ct = 1;
966970
phase.p1 = result=>{
967971

972+
s1.stop();
968973
var str = '??';
969974
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)
973976
phase.ct = 2
974977
phase.p2()
975978

@@ -979,25 +982,26 @@
979982
if(result)phase.p2.result = result;
980983
if(phase.ct!=2)return;
981984
if(!phase.p2.result)return;
985+
s2.stop();
982986
var str = '??';
983987
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);
987989
phase.ct = 3;
988990
phase.p3();
989991

990992
}//p2
991-
phase.p3 = result=>{console.log('phase.p3',!!result);
992-
993+
phase.p3 = result=>{
994+
//console.log('phase.p3',!!result);
993995
if(result)shell = result;
994996
if(phase.ct!=3)return;
995997
if(!shell)return;
998+
s3.stop();
999+
term.write.xy(14,1,`${colors.green}ok.${colors.reset}`);
9961000
shell.output.pipeTo(output);
9971001
input = shell.input.getWriter();
9981002
term.onData(data=>input.write(data));
9991003
//term.resize();
1000-
term.focus();
1004+
setTimeout(()=>term.focus(),50);
10011005

10021006
}//p3
10031007

@@ -1161,7 +1165,7 @@
11611165

11621166

11631167
async function prompt(){
1164-
1168+
console.log('prompt');
11651169
//await input.write('\u0003'); // Sends Ctrl+C to clear any junk
11661170
await input.write('\n'); // Sends Enter to get a clean prompt
11671171

@@ -1197,7 +1201,7 @@
11971201
spinner.timer = setInterval(()=>{
11981202
// \r moves to start of line, colors.cyan makes it pop
11991203
cursor.save();
1200-
cursor.to(x+1,y);
1204+
cursor.to(x,y);
12011205
term.write(`${colors.cyan}${frames[i]}${colors.reset}`);
12021206
cursor.restore();
12031207
i = (i+1)%frames.length;
@@ -1215,7 +1219,7 @@
12151219
// Clear the line, show cursor, and print final message
12161220
// \x1b[K clears from cursor to end of line
12171221
cursor.save();
1218-
cursor.to(x+1,y);
1222+
cursor.to(x,y);
12191223
term.write(' ');
12201224
cursor.restore();
12211225
// Show cursor

0 commit comments

Comments
 (0)