mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 13:45:00 +08:00
webconfig: Stop translating named colors
If the theme says "brgreen", that's what we want the variable to say after. This used to translate it through our palette, so it ended up as 00ff00, which isn't the same. This still keeps the idea that colors that aren't in the palette are better, and it does it in a slightly roundabout way (translate color string to rgb string, see if the rgb string is a key in that translation dictionary), but it should work for now.
This commit is contained in:
parent
4b018a7608
commit
3daba1b070
|
@ -218,7 +218,7 @@ function interpret_color(str) {
|
|||
if (str == 'brpurple') return '#ff00ff';
|
||||
if (str == 'brcyan') return '#00ffff';
|
||||
if (str == 'brwhite') return '#ffffff';
|
||||
if (str == 'normal') return '';
|
||||
if (str == 'normal') return '#ffffff';
|
||||
if (str == 'reset') return '';
|
||||
return '#' + str
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ controllers.controller("colorsController", function($scope, $http) {
|
|||
|
||||
var cols = [];
|
||||
for (var i in data) {
|
||||
currentScheme[data[i].name] = data[i].color;
|
||||
currentScheme[data[i].name] = interpret_color(data[i].color).replace(/#/, '');
|
||||
// HACK: For some reason the colors array is cleared later
|
||||
// So we cheesily encode the actual objects as colordata-, so we can send them.
|
||||
// TODO: We should switch to keeping the objects, and also displaying them
|
||||
|
|
|
@ -191,7 +191,7 @@ def better_color(c1, c2):
|
|||
def parse_color(color_str):
|
||||
"""A basic function to parse a color string, for example, 'red' '--bold'."""
|
||||
comps = color_str.split(" ")
|
||||
color = "normal"
|
||||
color = ""
|
||||
background_color = ""
|
||||
bold, underline, italics, dim, reverse = False, False, False, False, False
|
||||
for comp in comps:
|
||||
|
@ -209,20 +209,26 @@ def parse_color(color_str):
|
|||
reverse = True
|
||||
elif comp.startswith("--background"):
|
||||
# Background color
|
||||
background_color = better_color(
|
||||
background_color, parse_one_color(comp[len("--background=") :])
|
||||
)
|
||||
c = comp[len("--background=") :]
|
||||
parsed_c = parse_one_color(c)
|
||||
# We prefer the unparsed version - if it says "brgreen", we use brgreen,
|
||||
# instead of 00ff00
|
||||
if better_color(background_color, parsed_c) == parsed_c:
|
||||
background_color = c
|
||||
elif comp.startswith("-b"):
|
||||
# Background color in short.
|
||||
skip = len("-b")
|
||||
if comp[len("-b=")] in ["=", " "]:
|
||||
skip += 1
|
||||
background_color = better_color(
|
||||
background_color, parse_one_color(comp[skip :])
|
||||
)
|
||||
c = comp[skip :]
|
||||
parsed_c = parse_one_color(c)
|
||||
if better_color(background_color, parsed_c) == parsed_c:
|
||||
background_color = c
|
||||
else:
|
||||
# Regular color
|
||||
color = better_color(color, parse_one_color(comp))
|
||||
parsed_c = parse_one_color(comp)
|
||||
if better_color(color, parsed_c) == parsed_c:
|
||||
color = comp
|
||||
|
||||
return {
|
||||
"color": color,
|
||||
|
|
Loading…
Reference in New Issue
Block a user