From 0add289317bf4acca0992f9cf2df71e937227873 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 8 Jan 2017 22:49:59 +0100 Subject: Less magic --- tek.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tek.go b/tek.go index 95773a9..38ee8d9 100644 --- a/tek.go +++ b/tek.go @@ -5,6 +5,12 @@ import ( "os" ) +const ( + FF = 12 + ESC = 27 + GS = 29 +) + type Out struct { io.Writer hx, hy, lx, ly, eb byte @@ -13,7 +19,7 @@ type Out struct { } func (o *Out) escString(s string) { - o.Write([]byte{27}) + o.Write([]byte{ESC}) o.Write([]byte(s)) } @@ -33,24 +39,25 @@ func NewOut(w io.Writer) *Out { func (o Out) Enable() { if o.xterm { o.escString("[?38h") - o.writeByte(27, 12) // Tek Page + o.writeByte(ESC, FF) // Tek Page + o.writeByte(ESC, '`') // solid lines } } func (o Out) Disable() { if o.xterm { //o.escString("[?38l") - o.writeByte(31) // Text mode - o.writeByte(27, 3) // VT Page + o.writeByte(31) // Text mode + o.writeByte(ESC, 3) // VT Page } } func (o Out) PenUp() { - o.writeByte(29, 7) + o.writeByte(GS, 7) } func (o Out) PenDown() { - o.writeByte(29) + o.writeByte(GS) } func limit(val, max int) int { -- cgit v1.2.3