]> git.lizzy.rs Git - micro.git/commitdiff
Disable true color by default
authorZachary Yedidia <zyedidia@gmail.com>
Wed, 1 Jan 2020 04:09:33 +0000 (23:09 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 1 Jan 2020 04:09:33 +0000 (23:09 -0500)
internal/screen/screen.go

index 1e149be7201311af328f3922456dd50efb2ddaab..ec3fbdd013d965e34ced6c51b29eed6f7eaabe88 100644 (file)
@@ -6,7 +6,6 @@ import (
        "sync"
 
        "github.com/zyedidia/micro/internal/config"
-       "github.com/zyedidia/micro/pkg/terminfo"
        "github.com/zyedidia/tcell"
 )
 
@@ -59,52 +58,24 @@ func Init() {
        // Should we enable true color?
        truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
 
-       tcelldb := os.Getenv("TCELLDB")
-       os.Setenv("TCELLDB", config.ConfigDir+"/.tcelldb")
-
-       // In order to enable true color, we have to set the TERM to `xterm-truecolor` when
-       // initializing tcell, but after that, we can set the TERM back to whatever it was
-       oldTerm := os.Getenv("TERM")
-       if truecolor {
-               os.Setenv("TERM", "xterm-truecolor")
+       if !truecolor {
+               os.Setenv("TCELL_TRUECOLOR", "disable")
        }
 
        // Initilize tcell
        var err error
        Screen, err = tcell.NewScreen()
        if err != nil {
-               if err == tcell.ErrTermNotFound {
-                       err = terminfo.WriteDB(config.ConfigDir + "/.tcelldb")
-                       if err != nil {
-                               fmt.Println(err)
-                               fmt.Println("Fatal: Micro could not create terminal database file", config.ConfigDir+"/.tcelldb")
-                               os.Exit(1)
-                       }
-                       Screen, err = tcell.NewScreen()
-                       if err != nil {
-                               fmt.Println(err)
-                               fmt.Println("Fatal: Micro could not initialize a Screen.")
-                               os.Exit(1)
-                       }
-               } else {
-                       fmt.Println(err)
-                       fmt.Println("Fatal: Micro could not initialize a Screen.")
-                       os.Exit(1)
-               }
+               fmt.Println(err)
+               fmt.Println("Fatal: Micro could not initialize a Screen.")
+               os.Exit(1)
        }
        if err = Screen.Init(); err != nil {
                fmt.Println(err)
                os.Exit(1)
        }
 
-       // Now we can put the TERM back to what it was before
-       if truecolor {
-               os.Setenv("TERM", oldTerm)
-       }
-
        if config.GetGlobalOption("mouse").(bool) {
                Screen.EnableMouse()
        }
-
-       os.Setenv("TCELLDB", tcelldb)
 }