8 "github.com/zyedidia/micro/cmd/micro/config"
9 "github.com/zyedidia/micro/cmd/micro/terminfo"
10 "github.com/zyedidia/tcell"
13 var Screen tcell.Screen
27 screenWasNil := Screen == nil
43 // Init creates and initializes the tcell screen
45 // Should we enable true color?
46 truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
48 tcelldb := os.Getenv("TCELLDB")
49 os.Setenv("TCELLDB", config.ConfigDir+"/.tcelldb")
51 // In order to enable true color, we have to set the TERM to `xterm-truecolor` when
52 // initializing tcell, but after that, we can set the TERM back to whatever it was
53 oldTerm := os.Getenv("TERM")
55 os.Setenv("TERM", "xterm-truecolor")
60 Screen, err = tcell.NewScreen()
62 if err == tcell.ErrTermNotFound {
63 err = terminfo.WriteDB(config.ConfigDir + "/.tcelldb")
66 fmt.Println("Fatal: Micro could not create terminal database file", config.ConfigDir+"/.tcelldb")
69 Screen, err = tcell.NewScreen()
72 fmt.Println("Fatal: Micro could not initialize a Screen.")
77 fmt.Println("Fatal: Micro could not initialize a Screen.")
81 if err = Screen.Init(); err != nil {
86 // Now we can put the TERM back to what it was before
88 os.Setenv("TERM", oldTerm)
91 if config.GetGlobalOption("mouse").(bool) {
95 os.Setenv("TCELLDB", tcelldb)