mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-24 17:50:15 +09:00
options: Add truecolor to control the usage (#2867)
- `auto`: enable usage of true color if it is supported, otherwise disable it - `on`: force usage of true color - `off`: disable true color usage Co-authored-by: Dmytro Maluka <dmitrymaluka@gmail.com>
This commit is contained in:
@@ -36,6 +36,7 @@ var optionValidators = map[string]optionValidator{
|
||||
"scrollmargin": validateNonNegativeValue,
|
||||
"scrollspeed": validateNonNegativeValue,
|
||||
"tabsize": validatePositiveValue,
|
||||
"truecolor": validateChoice,
|
||||
}
|
||||
|
||||
// a list of settings with pre-defined choices
|
||||
@@ -46,6 +47,7 @@ var OptionChoices = map[string][]string{
|
||||
"matchbracestyle": {"underline", "highlight"},
|
||||
"multiopen": {"tab", "hsplit", "vsplit"},
|
||||
"reload": {"prompt", "auto", "disabled"},
|
||||
"truecolor": {"auto", "on", "off"},
|
||||
}
|
||||
|
||||
// a list of settings that can be globally and locally modified and their
|
||||
@@ -99,6 +101,7 @@ var defaultCommonSettings = map[string]interface{}{
|
||||
"tabmovement": false,
|
||||
"tabsize": float64(4),
|
||||
"tabstospaces": false,
|
||||
"truecolor": "auto",
|
||||
"useprimary": true,
|
||||
"wordwrap": false,
|
||||
}
|
||||
|
||||
@@ -184,10 +184,13 @@ func Init() error {
|
||||
drawChan = make(chan bool, 8)
|
||||
|
||||
// Should we enable true color?
|
||||
truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
|
||||
|
||||
if !truecolor {
|
||||
truecolor := config.GetGlobalOption("truecolor").(string)
|
||||
if truecolor == "on" || (truecolor == "auto" && os.Getenv("MICRO_TRUECOLOR") == "1") {
|
||||
os.Setenv("TCELL_TRUECOLOR", "enable")
|
||||
} else if truecolor == "off" {
|
||||
os.Setenv("TCELL_TRUECOLOR", "disable")
|
||||
} else {
|
||||
// For "auto", tcell already autodetects truecolor by default
|
||||
}
|
||||
|
||||
var oldTerm string
|
||||
|
||||
Reference in New Issue
Block a user