mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 22:07:09 +09:00
Add true color support with MICRO_TRUECOLOR environment var
This commit is contained in:
@@ -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
|
||||
|
||||
17
src/micro.go
17
src/micro.go
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user