From 1434ec266961fd9acc795af39e4d490f1fe19301 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 8 Jan 2017 10:39:46 +0100 Subject: Detect xterm --- tek.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tek.go b/tek.go index d07ab84..f94eb3b 100644 --- a/tek.go +++ b/tek.go @@ -3,6 +3,7 @@ package main import ( "bufio" "io" + "os" ) const ( @@ -13,22 +14,30 @@ const ( type Out struct { *bufio.Writer hix, hiy, lox, loy, eb int + xterm bool } func NewOut(w io.Writer) *Out { - return &Out{Writer: bufio.NewWriter(w)} + return &Out{ + Writer: bufio.NewWriter(w), + xterm: os.Getenv("TERM") == "xterm", + } } func (o Out) Enable() { - o.WriteByte(0x1b) - o.WriteString("[?38h") - o.Flush() + if o.xterm { + o.WriteByte(0x1b) + o.WriteString("[?38h") + o.Flush() + } } func (o Out) Disable() { - o.WriteByte(0x1b) - o.WriteByte(0x03) - o.Flush() + if o.xterm { + o.WriteByte(0x1b) + o.WriteByte(0x03) + o.Flush() + } } func (o Out) Clear() { -- cgit v1.2.3