MCPcopy Create free account
hub / github.com/npkgz/cli-progress / Terminal

Class Terminal

lib/terminal.js:4–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2
3// low-level terminal interactions
4class Terminal{
5
6 constructor(outputStream){
7 this.stream = outputStream;
8
9 // default: line wrapping enabled
10 this.linewrap = true;
11
12 // current, relative y position
13 this.dy = 0;
14 }
15
16 // save cursor position + settings
17 cursorSave(){
18 if (!this.stream.isTTY){
19 return;
20 }
21
22 // save position
23 this.stream.write('\x1B7');
24 }
25
26 // restore last cursor position + settings
27 cursorRestore(){
28 if (!this.stream.isTTY){
29 return;
30 }
31
32 // restore cursor
33 this.stream.write('\x1B8');
34 }
35
36 // show/hide cursor
37 cursor(enabled){
38 if (!this.stream.isTTY){
39 return;
40 }
41
42 if (enabled){
43 this.stream.write('\x1B[?25h');
44 }else{
45 this.stream.write('\x1B[?25l');
46 }
47 }
48
49 // change cursor positionn
50 cursorTo(x=null, y=null){
51 if (!this.stream.isTTY){
52 return;
53 }
54
55 // move cursor absolute
56 _readline.cursorTo(this.stream, x, y);
57 }
58
59 // change relative cursor position
60 cursorRelative(dx=null, dy=null){
61 if (!this.stream.isTTY){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…