Skip to content

Commit

Permalink
Some changes for handling invalid colors
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Mar 18, 2021
1 parent b9805f3 commit cd2838d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/color_scheme_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ def parse_scheme(self):
c.strip(), variables=self.variables
).convert("srgb").to_string(**HEX)
except Exception:
item['foreground'] = "none"
item['foreground'] = False
elif isinstance(color, str):
try:
item['foreground'] = Color(
color.strip(), variables=self.variables
).convert("srgb").to_string(**HEX)
except Exception:
item['foreground'] = "none"
item['foreground'] = False
# Background color
bgcolor = item.get('background', None)
if isinstance(bgcolor, str):
Expand Down Expand Up @@ -363,7 +363,7 @@ def add_entry(self, name, scope, color, bgcolor, fgadj, scolor, style):
if isinstance(color, list):
fg, fg_sim, color_gradient = self.process_color_gradient(color)
elif color is not None:
if color == "none":
if color is False:
fg, fg_sim = color, None
else:
fg, fg_sim = self.process_color(color)
Expand All @@ -374,7 +374,7 @@ def add_entry(self, name, scope, color, bgcolor, fgadj, scolor, style):
else:
bg, bg_sim = None, None
if scolor is not None:
if scolor == "none":
if scolor is False:
sfg, sfg_sim = scolor, None
else:
sfg, sfg_sim = self.process_color(
Expand Down Expand Up @@ -535,7 +535,7 @@ def guess_color(self, scope_key, selected=False, explicit_background=False, no_b
):
best_match_fg = match
color = self.colors[key]["color"]
if color == "none":
if color is False:
color = self.special_colors['foreground']['color']
color_sim = self.special_colors['foreground']['color_simulated']
else:
Expand All @@ -553,7 +553,7 @@ def guess_color(self, scope_key, selected=False, explicit_background=False, no_b
if self.colors[key]["selection_color"] is not None and match > best_match_sfg:
best_match_sfg = match
scolor = self.colors[key]["selection_color"]
if color == "none":
if color is False:
scolor = self.special_colors['selection_foreground']['color']
scolor_sim = self.special_colors['selection_foreground']['color_simulated']
else:
Expand Down

0 comments on commit cd2838d

Please sign in to comment.