mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-18 06:45:40 -04: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:
parent
bf255b6c35
commit
cd0dc9a701
@ -47,7 +47,7 @@ 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.
|
||||
- Copy and paste with the system clipboard.
|
||||
- Small and simple.
|
||||
- Easily configurable.
|
||||
|
@ -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
|
||||
|
@ -47,10 +47,7 @@ color support comes in three flavors.
|
||||
displaying any colorscheme, but it should be noted that the user-configured
|
||||
16-color palette is ignored when using true-color mode (this means the
|
||||
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`).
|
||||
terminals support true color but at this point most do (see below).
|
||||
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
|
||||
@ -84,11 +81,12 @@ These may vary widely based on the 16 colors selected for your terminal.
|
||||
|
||||
### True color
|
||||
|
||||
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.
|
||||
Micro enables true color support by default as long as it detects that the
|
||||
terminal supports it (which is usually indicated by the environment variable
|
||||
`COLORTERM` being set to `truecolor`, `24bit` or `24-bit`). You can also force
|
||||
enabling it unconditionally by setting the option `truecolor` to `on` (or
|
||||
alternatively by setting the environment variable `MICRO_TRUECOLOR` to 1, which
|
||||
is supported for backward compatibility).
|
||||
|
||||
* `solarized-tc`: this is the solarized colorscheme for true color.
|
||||
* `atom-dark`: this colorscheme is based off of Atom's "dark" colorscheme.
|
||||
|
@ -462,6 +462,19 @@ Here are the available options:
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `truecolor`: controls whether micro will use true colors (24-bit colors) when
|
||||
using a colorscheme with true colors, such as `solarized-tc` or `atom-dark`.
|
||||
* `auto`: enable usage of true color if micro detects that it is supported by
|
||||
the terminal, otherwise disable it.
|
||||
* `on`: force usage of true color even if micro does not detect its support
|
||||
by the terminal (of course this is not guaranteed to work well unless the
|
||||
terminal actually supports true color).
|
||||
* `off`: disable true color usage.
|
||||
|
||||
Note: The change will take effect after the next start of `micro`.
|
||||
|
||||
default value: `auto`
|
||||
|
||||
* `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 New Issue
Block a user