]> git.lizzy.rs Git - micro.git/commitdiff
Add 'xterm' option
authorZachary Yedidia <zyedidia@gmail.com>
Sat, 15 Feb 2020 17:53:17 +0000 (12:53 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Sat, 15 Feb 2020 17:53:17 +0000 (12:53 -0500)
Ref #1489

internal/config/settings.go
internal/screen/screen.go
runtime/help/options.md

index f99ac527b8d97fd082e0fa091d54880158573a88..81c431d896157323cd98f5ee8911c5705f6955b4 100644 (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
index 19f9bd8c62ab35825cd08bcd3bcba6bf89eff805..e0c3a6ab2e12bbb9ccbd3022f923a060f00aab28 100644 (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()
        }
index 12703b257949921ee19938b2563e2226c0587bf6..6ce5f4be592da475ec5669dbb210e44f8a628424 100644 (file)
@@ -296,6 +296,13 @@ Here are the available options:
 
        default value: `true`
 
+* `xterm`: micro will assume that the terminal it is running in conforms to
+  `xterm-256color` regardless of what the `$TERM` variable actually contains.
+   Enabling this option may cause unwanted effects if your terminal in fact
+   does not conform to the `xterm-256color` standard.
+
+    Default value: `false`
+
 ---
 
 Plugin options: all plugins come with a special option to enable or disable