mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg/jsonmessage: Encode ANSI ESC directly as \x1b rather than via fmt as %c
This seems clearer to me and avoids a miniscule amount of string formatting. I have deliberately not changed the tests here to avoid the possibility of changing both wrongly. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
parent
f02221a794
commit
3c233b13a0
1 changed files with 4 additions and 4 deletions
|
@ -127,13 +127,13 @@ func clearLine(out io.Writer, ti termInfo) {
|
|||
if attr, err := ti.Parse("el1"); err == nil {
|
||||
fmt.Fprintf(out, "%s", attr)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%c[1K", 27)
|
||||
fmt.Fprintf(out, "\x1b[1K")
|
||||
}
|
||||
// Then clear line from cursor to end
|
||||
if attr, err := ti.Parse("el"); err == nil {
|
||||
fmt.Fprintf(out, "%s", attr)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%c[K", 27)
|
||||
fmt.Fprintf(out, "\x1b[K")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ func cursorUp(out io.Writer, ti termInfo, l int) {
|
|||
if attr, err := ti.Parse("cuu", l); err == nil {
|
||||
fmt.Fprintf(out, "%s", attr)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%c[%dA", 27, l)
|
||||
fmt.Fprintf(out, "\x1b[%dA", l)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ func cursorDown(out io.Writer, ti termInfo, l int) {
|
|||
if attr, err := ti.Parse("cud", l); err == nil {
|
||||
fmt.Fprintf(out, "%s", attr)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%c[%dB", 27, l)
|
||||
fmt.Fprintf(out, "\x1b[%dB", l)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue