File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -22,36 +22,65 @@ import (
22
22
"github.com/acarl005/stripansi"
23
23
)
24
24
25
+ var disableAnsi bool
26
+
25
27
func ansi (code string ) string {
26
28
return fmt .Sprintf ("\033 %s" , code )
27
29
}
28
30
func SaveCursor () {
31
+ if disableAnsi {
32
+ return
33
+ }
29
34
fmt .Print (ansi ("7" ))
30
35
}
31
36
func RestoreCursor () {
37
+ if disableAnsi {
38
+ return
39
+ }
32
40
fmt .Print (ansi ("8" ))
33
41
}
34
42
func HideCursor () {
43
+ if disableAnsi {
44
+ return
45
+ }
35
46
fmt .Print (ansi ("[?25l" ))
36
47
}
37
48
func ShowCursor () {
49
+ if disableAnsi {
50
+ return
51
+ }
38
52
fmt .Print (ansi ("[?25h" ))
39
53
}
40
54
func MoveCursor (y , x int ) {
55
+ if disableAnsi {
56
+ return
57
+ }
41
58
fmt .Print (ansi (fmt .Sprintf ("[%d;%dH" , y , x )))
42
59
}
43
60
func MoveCursorX (pos int ) {
61
+ if disableAnsi {
62
+ return
63
+ }
44
64
fmt .Print (ansi (fmt .Sprintf ("[%dG" , pos )))
45
65
}
46
66
func ClearLine () {
67
+ if disableAnsi {
68
+ return
69
+ }
47
70
// Does not move cursor from its current position
48
71
fmt .Print (ansi ("[2K" ))
49
72
}
50
73
func MoveCursorUp (lines int ) {
74
+ if disableAnsi {
75
+ return
76
+ }
51
77
// Does not add new lines
52
78
fmt .Print (ansi (fmt .Sprintf ("[%dA" , lines )))
53
79
}
54
80
func MoveCursorDown (lines int ) {
81
+ if disableAnsi {
82
+ return
83
+ }
55
84
// Does not add new lines
56
85
fmt .Print (ansi (fmt .Sprintf ("[%dB" , lines )))
57
86
}
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ func SetANSIMode(streams api.Streams, ansi string) {
64
64
nextColor = func () colorFunc {
65
65
return monochrome
66
66
}
67
+ disableAnsi = true
67
68
}
68
69
}
69
70
You can’t perform that action at this time.
0 commit comments