7 "github.com/zyedidia/micro/cmd/micro/config"
8 "github.com/zyedidia/micro/cmd/micro/terminfo"
9 "github.com/zyedidia/tcell"
12 var Screen tcell.Screen
14 // Init creates and initializes the tcell screen
16 // Should we enable true color?
17 truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
19 tcelldb := os.Getenv("TCELLDB")
20 os.Setenv("TCELLDB", config.ConfigDir+"/.tcelldb")
22 // In order to enable true color, we have to set the TERM to `xterm-truecolor` when
23 // initializing tcell, but after that, we can set the TERM back to whatever it was
24 oldTerm := os.Getenv("TERM")
26 os.Setenv("TERM", "xterm-truecolor")
31 Screen, err = tcell.NewScreen()
33 if err == tcell.ErrTermNotFound {
34 err = terminfo.WriteDB(config.ConfigDir + "/.tcelldb")
37 fmt.Println("Fatal: Micro could not create terminal database file", config.ConfigDir+"/.tcelldb")
40 Screen, err = tcell.NewScreen()
43 fmt.Println("Fatal: Micro could not initialize a screen.")
48 fmt.Println("Fatal: Micro could not initialize a screen.")
52 if err = Screen.Init(); err != nil {
57 // Now we can put the TERM back to what it was before
59 os.Setenv("TERM", oldTerm)
62 if config.GetGlobalOption("mouse").(bool) {
66 os.Setenv("TCELLDB", tcelldb)