Skip to content

Commit 1c582cd

Browse files
save file
1 parent 5c776ae commit 1c582cd

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@
730730

731731
};
732732

733-
var chr = {
733+
const chr = {
734734

735735
warn : '\u26A0',
736736
cross : '\u274C',
@@ -743,7 +743,7 @@
743743

744744
};
745745

746-
var colors = {
746+
const colors = {
747747

748748
black : '\x1b[30m',
749749
red : '\x1b[31m',
@@ -771,14 +771,16 @@
771771
};
772772

773773

774-
var cursor = {
774+
const cursor = {
775775

776-
to : (row,col)=>`\x1b[${row};${col}H`,
776+
to : (x,y)=>`\x1b[${y};${x}H`,
777777
up : (n=1)=>`\x1b[${n}A`,
778778
down : (n=1)=>`\x1b[${n}B`,
779779
home : '\x1b[H',
780780
save : '\x1b[s',
781-
restore : '\x1b[u'
781+
restore : '\x1b[u',
782+
hide : '\x1b[?25l',
783+
show : '\x1b[?25h',
782784

783785
};
784786

@@ -861,12 +863,12 @@
861863
}//resume
862864
term.write.xy = (x,y,txt)=>{
863865
// Save cursor
864-
term.write('\x1b[s');
866+
term.write(cursor.save);
865867
// Jump to x,y
866-
term.write(`\x1b[${y};${x}H`);
868+
term.write(cursor.to(x,y));
867869
term.write(txt);
868870
// restore cursor
869-
term.write('\x1b[u');
871+
term.write(cursor.restore);
870872

871873
}//xy
872874

@@ -947,7 +949,7 @@
947949

948950
var str = '??';
949951
if(result.code==0)str = result.output;
950-
var x = end_of_text(1);
952+
var x = term.end_of_text(1);
951953
x+=2;
952954
term.write.xy(x,1,'node '+str)
953955
phase.ct = 2
@@ -961,7 +963,7 @@
961963
if(!phase.p2.result)return;
962964
var str = '??';
963965
if(phase.p2.result.code==0)str = phase.p2.result.output;
964-
var x = end_of_text(1);
966+
var x = term.end_of_text(1);
965967
x+=2;
966968
term.write.xy(x,1,'npm '+str);
967969
phase.ct = 3;
@@ -1156,7 +1158,7 @@
11561158
let i = 0;
11571159

11581160
// Hide the cursor so it doesn't flicker
1159-
term.write('\x1b[?25l');
1161+
term.write(cursor.hide);
11601162

11611163
spinner.timer = setInterval(() => {
11621164
// \r moves to start of line, colors.cyan makes it pop
@@ -1178,7 +1180,7 @@
11781180
// \x1b[K clears from cursor to end of line
11791181
term.write(`\r\x1b[K${colors.green}${colors.reset} ${finalMsg}\r`);
11801182
// Show cursor
1181-
term.write('\x1b[?25h');
1183+
term.write(cursor.show);
11821184

11831185
}//stop
11841186

0 commit comments

Comments
 (0)