mirror of
https://github.com/docker/compose.git
synced 2025-07-21 12:44:54 +02:00
don't use ansi espace sequence when disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
ff20b641c7
commit
d71d8bce24
@ -22,36 +22,65 @@ import (
|
|||||||
"github.com/acarl005/stripansi"
|
"github.com/acarl005/stripansi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var disableAnsi bool
|
||||||
|
|
||||||
func ansi(code string) string {
|
func ansi(code string) string {
|
||||||
return fmt.Sprintf("\033%s", code)
|
return fmt.Sprintf("\033%s", code)
|
||||||
}
|
}
|
||||||
func SaveCursor() {
|
func SaveCursor() {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Print(ansi("7"))
|
fmt.Print(ansi("7"))
|
||||||
}
|
}
|
||||||
func RestoreCursor() {
|
func RestoreCursor() {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Print(ansi("8"))
|
fmt.Print(ansi("8"))
|
||||||
}
|
}
|
||||||
func HideCursor() {
|
func HideCursor() {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Print(ansi("[?25l"))
|
fmt.Print(ansi("[?25l"))
|
||||||
}
|
}
|
||||||
func ShowCursor() {
|
func ShowCursor() {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Print(ansi("[?25h"))
|
fmt.Print(ansi("[?25h"))
|
||||||
}
|
}
|
||||||
func MoveCursor(y, x int) {
|
func MoveCursor(y, x int) {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%d;%dH", y, x)))
|
fmt.Print(ansi(fmt.Sprintf("[%d;%dH", y, x)))
|
||||||
}
|
}
|
||||||
func MoveCursorX(pos int) {
|
func MoveCursorX(pos int) {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%dG", pos)))
|
fmt.Print(ansi(fmt.Sprintf("[%dG", pos)))
|
||||||
}
|
}
|
||||||
func ClearLine() {
|
func ClearLine() {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
// Does not move cursor from its current position
|
// Does not move cursor from its current position
|
||||||
fmt.Print(ansi("[2K"))
|
fmt.Print(ansi("[2K"))
|
||||||
}
|
}
|
||||||
func MoveCursorUp(lines int) {
|
func MoveCursorUp(lines int) {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
// Does not add new lines
|
// Does not add new lines
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%dA", lines)))
|
fmt.Print(ansi(fmt.Sprintf("[%dA", lines)))
|
||||||
}
|
}
|
||||||
func MoveCursorDown(lines int) {
|
func MoveCursorDown(lines int) {
|
||||||
|
if disableAnsi {
|
||||||
|
return
|
||||||
|
}
|
||||||
// Does not add new lines
|
// Does not add new lines
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%dB", lines)))
|
fmt.Print(ansi(fmt.Sprintf("[%dB", lines)))
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ func SetANSIMode(streams api.Streams, ansi string) {
|
|||||||
nextColor = func() colorFunc {
|
nextColor = func() colorFunc {
|
||||||
return monochrome
|
return monochrome
|
||||||
}
|
}
|
||||||
|
disableAnsi = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user