summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-01-08 10:39:46 +0100
committerDimitri Sokolyuk <demon@dim13.org>2017-01-08 10:39:46 +0100
commit1434ec266961fd9acc795af39e4d490f1fe19301 (patch)
treee892fd94bc39ed86e787df1b1fd43e9fbfff6a64
parent895ff08d9db93b42ab5e1613f75f6fc22fad71c5 (diff)
Detect xterm
-rw-r--r--tek.go23
1 files 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() {