Add true color support with MICRO_TRUECOLOR environment var

This commit is contained in:
Zachary Yedidia
2016-03-22 10:31:08 -04:00
parent 60858417f7
commit e47d645486
2 changed files with 17 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ import (
"strings"
)
const colorschemeName = "solarized"
const colorschemeName = "default"
// Colorscheme is a map from string to style -- it represents a colorscheme
type Colorscheme map[string]tcell.Style

View File

@@ -41,7 +41,14 @@ func main() {
LoadSyntaxFiles()
s, e := tcell.NewScreen()
truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
oldTerm := os.Getenv("TERM")
if truecolor {
os.Setenv("TERM", "xterm-truecolor")
}
s, e := tcell.NewTerminfoScreen()
if e != nil {
fmt.Fprintf(os.Stderr, "%v\n", e)
os.Exit(1)
@@ -51,6 +58,10 @@ func main() {
os.Exit(1)
}
if truecolor {
os.Setenv("TERM", oldTerm)
}
defer func() {
if err := recover(); err != nil {
s.Fini()
@@ -64,6 +75,10 @@ func main() {
Background(tcell.ColorDefault).
Foreground(tcell.ColorDefault)
if _, ok := colorscheme["default"]; ok {
defStyle = colorscheme["default"]
}
s.SetStyle(defStyle)
s.EnableMouse()