From: Dmitry Maluka Date: Tue, 28 Sep 2021 20:30:29 +0000 (+0200) Subject: Fix some issues with default colors in colorschemes (#2225) X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=9ad4437a98893504445fd44ad8b0300bedfeeb54;p=micro.git Fix some issues with default colors in colorschemes (#2225) * Fix default colors for unconfigured syntax groups When GetColor is called for a syntax group not specified in the colorscheme, it should fallback not to the terminal's default colors (tcell.DefaultColor) but to the colorscheme's defaults (DefStyle) which may be different from tcell.DefaultColor. For example, if we are using micro's default colorscheme in a terminal which uses a black-on-white theme, then dots and commas in Go files ("symbol" syntax group in go.yaml) are displayed black on a dark background, i.e. barely visible. * Avoid using terminal's default colors directly If a syntax group color is set to "default" (which we have for some syntax groups in some colorschemes), it defaults to the terminal's default colors (tcell.DefaultColor), which is fine for 16-color colorschemes but not quite fine for truecolor and 256-color colorschemes which should not depend on the terminal colors. It should default to the colorscheme's default (DefStyle) instead. For example, if we are using micro's default colorscheme in a terminal which uses a black-on-white theme, then "bool" type in C files ("type.extended" syntax group in c.yaml) is displayed black on a dark background, i.e. barely visible. --- diff --git a/internal/config/colorscheme.go b/internal/config/colorscheme.go index 5222cd54..4a2ef2f4 100644 --- a/internal/config/colorscheme.go +++ b/internal/config/colorscheme.go @@ -35,8 +35,6 @@ func GetColor(color string) tcell.Style { } } else if style, ok := Colorscheme[color]; ok { st = style - } else { - st = StringToStyle(color) } return st @@ -131,12 +129,12 @@ func StringToStyle(str string) tcell.Style { bg = strings.TrimSpace(bg) var fgColor, bgColor tcell.Color - if fg == "" { + if fg == "" || fg == "default" { fgColor, _, _ = DefStyle.Decompose() } else { fgColor = StringToColor(fg) } - if bg == "" { + if bg == "" || bg == "default" { _, bgColor, _ = DefStyle.Decompose() } else { bgColor = StringToColor(bg)