From 4e45b185f6b6fa1b3e2391de722e4c1c2f02026c Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Fri, 11 Nov 2016 10:59:40 +0000 Subject: [PATCH] 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 Upstream-commit: 3c233b13a01b9f44e31a158768a06b97a775f095 Component: engine --- components/engine/pkg/jsonmessage/jsonmessage.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/engine/pkg/jsonmessage/jsonmessage.go b/components/engine/pkg/jsonmessage/jsonmessage.go index 91d280564e..c6ad345ce4 100644 --- a/components/engine/pkg/jsonmessage/jsonmessage.go +++ b/components/engine/pkg/jsonmessage/jsonmessage.go @@ -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) } }