options: Add truecolor
to control the mode
- `auto`: leaves the detection to `tcell` - `on`: forced usage, same as `$MICRO_TRUECOLOR` set to 1 - `off`: default, can be overriden by `$MICRO_TRUECOLOR`
This commit is contained in:
parent
8724709cf9
commit
d06cf54dd4
5 changed files with 39 additions and 8 deletions
|
@ -63,7 +63,10 @@ You can also check out the website for Micro at https://micro-editor.github.io.
|
|||
- Syntax highlighting for over [130 languages](runtime/syntax).
|
||||
- Color scheme support.
|
||||
- By default, micro comes with 16, 256, and true color themes.
|
||||
- True color support (set the `MICRO_TRUECOLOR` environment variable to 1 to enable it).
|
||||
- True color support
|
||||
- set the option `truecolor` to `auto` or `on` ..
|
||||
- set the `MICRO_TRUECOLOR` environment variable to 1 to enable it
|
||||
- both ways do only work in case the terminal supports true color mode
|
||||
- Copy and paste with the system clipboard.
|
||||
- Small and simple.
|
||||
- Easily configurable.
|
||||
|
|
|
@ -35,6 +35,7 @@ var optionValidators = map[string]optionValidator{
|
|||
"scrollmargin": validateNonNegativeValue,
|
||||
"scrollspeed": validateNonNegativeValue,
|
||||
"tabsize": validatePositiveValue,
|
||||
"truecolor": validateChoice,
|
||||
}
|
||||
|
||||
// a list of settings with pre-defined choices
|
||||
|
@ -44,6 +45,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
|
||||
|
@ -95,6 +97,7 @@ var defaultCommonSettings = map[string]interface{}{
|
|||
"tabmovement": false,
|
||||
"tabsize": float64(4),
|
||||
"tabstospaces": false,
|
||||
"truecolor": "off",
|
||||
"useprimary": true,
|
||||
"wordwrap": false,
|
||||
}
|
||||
|
|
|
@ -150,9 +150,16 @@ func Init() error {
|
|||
drawChan = make(chan bool, 8)
|
||||
|
||||
// Should we enable true color?
|
||||
truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"
|
||||
truecolor := (config.GetGlobalOption("truecolor").(string) == "auto") ||
|
||||
(config.GetGlobalOption("truecolor").(string) == "on") ||
|
||||
(os.Getenv("MICRO_TRUECOLOR") == "1")
|
||||
|
||||
if !truecolor {
|
||||
if truecolor {
|
||||
if (config.GetGlobalOption("truecolor").(string) == "on") ||
|
||||
(os.Getenv("MICRO_TRUECOLOR") == "1") {
|
||||
os.Setenv("COLORTERM", "truecolor")
|
||||
}
|
||||
} else {
|
||||
os.Setenv("TCELL_TRUECOLOR", "disable")
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,12 @@ color support comes in three flavors.
|
|||
colors while using the terminal emulator will be slightly off). Not all
|
||||
terminals support true color but at this point most do. True color
|
||||
support in micro is off by default but can be enabled by setting the
|
||||
environment variable `MICRO_TRUECOLOR` to 1. In addition your terminal
|
||||
must support it (usually indicated by setting `$COLORTERM` to `truecolor`).
|
||||
the option `truecolor` to `on` or the environment variable `MICRO_TRUECOLOR`
|
||||
to 1 to force the usage of true color mode.
|
||||
In addition your terminal must support it (usually indicated by setting
|
||||
`COLORTERM` to `truecolor`).
|
||||
Furthermore it can be enabled by setting the option `truecolor` to `auto` then
|
||||
the availability will be determined by `$COLORTERM`.
|
||||
True-color colorschemes in micro typically end with `-tc`, such as
|
||||
`solarized-tc`, `atom-dark`, `material-tc`, etc... If true color is not
|
||||
enabled but a true color colorscheme is used, micro will do its best to
|
||||
|
@ -86,9 +90,10 @@ These may vary widely based on the 16 colors selected for your terminal.
|
|||
|
||||
True color requires your terminal to support it. This means that the
|
||||
environment variable `COLORTERM` should have the value `truecolor`, `24bit`,
|
||||
or `24-bit`. In addition, to enable true color in micro, the environment
|
||||
variable `MICRO_TRUECOLOR` must be set to 1. Note that you have to create
|
||||
and set this variable yourself.
|
||||
or `24-bit`. In case the currently used terminal doesn't "support" true color
|
||||
within the mentioned `COLORTERM` then the usage can be forced by setting the
|
||||
option `truecolor` to `on` or the environment variable `MICRO_TRUECOLOR` to 1.
|
||||
Note that you have to create and set this environment variable yourself.
|
||||
|
||||
* `solarized-tc`: this is the solarized colorscheme for true color.
|
||||
* `atom-dark`: this colorscheme is based off of Atom's "dark" colorscheme.
|
||||
|
|
|
@ -442,6 +442,19 @@ Here are the available options:
|
|||
|
||||
default value: `false`
|
||||
|
||||
* `truecolor`: controls the usage of the true color support/mode.
|
||||
* `auto`: Leaves the true color support detection to `tcell`, which evaluates
|
||||
the `$COLORTERM` environment variable. This option can be overriden by
|
||||
setting `$MICRO_TRUECOLOR` to `1` too.
|
||||
* `on`: Will force the usage of true color, but will need terminal support
|
||||
to work properly. This option will override `$MICRO_TRUECOLOR` set to `0`.
|
||||
* `off`: true color support disabled, but can be overriden with the
|
||||
`$MICRO_TRUECOLOR` environment variable set to `1`.
|
||||
|
||||
Note: The change will take effect after the next start of `micro`.
|
||||
|
||||
default value: `off`
|
||||
|
||||
* `useprimary` (only useful on unix): defines whether or not micro will use the
|
||||
primary clipboard to copy selections in the background. This does not affect
|
||||
the normal clipboard using Ctrl-c and Ctrl-v.
|
||||
|
|
Loading…
Reference in a new issue