]> git.lizzy.rs Git - micro.git/commitdiff
Add true color support with MICRO_TRUECOLOR environment var
authorZachary Yedidia <zyedidia@gmail.com>
Tue, 22 Mar 2016 14:31:08 +0000 (10:31 -0400)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 23 Mar 2016 00:15:17 +0000 (20:15 -0400)
src/colorscheme.go
src/micro.go

index 996b2b563ab1884a6a0c2a1e5b9e129115fb48c4..1c32cd975092b2e16ab2fe5a871c1dbab3509cce 100644 (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
index 580cb5842334b905f4c85658582def1294089c5a..f4b0190b55e39df03449f4c4450b57b068da5339 100644 (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()