Add 'xterm' option

Ref #1489
This commit is contained in:
Zachary Yedidia
2020-02-15 12:53:17 -05:00
parent db32b84cd1
commit 087e7207f7
3 changed files with 19 additions and 0 deletions

View File

@@ -256,6 +256,7 @@ var DefaultGlobalOnlySettings = map[string]interface{}{
"sucmd": "sudo",
"pluginchannels": []string{"https://raw.githubusercontent.com/micro-editor/plugin-channel/master/channel.json"},
"pluginrepos": []string{},
"xterm": false,
}
// a list of settings that should never be globally modified

View File

@@ -136,6 +136,12 @@ func Init() {
os.Setenv("TCELL_TRUECOLOR", "disable")
}
var oldTerm string
if config.GetGlobalOption("xterm").(bool) {
oldTerm = os.Getenv("TERM")
os.Setenv("TERM", "xterm-256color")
}
// Initilize tcell
var err error
Screen, err = tcell.NewScreen()
@@ -149,6 +155,11 @@ func Init() {
os.Exit(1)
}
// restore TERM
if config.GetGlobalOption("xterm").(bool) {
os.Setenv("TERM", oldTerm)
}
if config.GetGlobalOption("mouse").(bool) {
Screen.EnableMouse()
}