mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-19 07:15:34 -04:00
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.
This commit is contained in:
parent
a21a720941
commit
9ad4437a98
@ -35,8 +35,6 @@ func GetColor(color string) tcell.Style {
|
|||||||
}
|
}
|
||||||
} else if style, ok := Colorscheme[color]; ok {
|
} else if style, ok := Colorscheme[color]; ok {
|
||||||
st = style
|
st = style
|
||||||
} else {
|
|
||||||
st = StringToStyle(color)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return st
|
return st
|
||||||
@ -131,12 +129,12 @@ func StringToStyle(str string) tcell.Style {
|
|||||||
bg = strings.TrimSpace(bg)
|
bg = strings.TrimSpace(bg)
|
||||||
|
|
||||||
var fgColor, bgColor tcell.Color
|
var fgColor, bgColor tcell.Color
|
||||||
if fg == "" {
|
if fg == "" || fg == "default" {
|
||||||
fgColor, _, _ = DefStyle.Decompose()
|
fgColor, _, _ = DefStyle.Decompose()
|
||||||
} else {
|
} else {
|
||||||
fgColor = StringToColor(fg)
|
fgColor = StringToColor(fg)
|
||||||
}
|
}
|
||||||
if bg == "" {
|
if bg == "" || bg == "default" {
|
||||||
_, bgColor, _ = DefStyle.Decompose()
|
_, bgColor, _ = DefStyle.Decompose()
|
||||||
} else {
|
} else {
|
||||||
bgColor = StringToColor(bg)
|
bgColor = StringToColor(bg)
|
||||||
|
Loading…
Reference in New Issue
Block a user