| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e638475 commit f924f2c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,10 +31,17 @@ | |||
| 31 | 31 | from xdg import BaseDirectory | |
| 32 | 32 | ||
| 33 | 33 | from .autocomplete import AutocompleteModes | |
| 34 | + from .curtsiesfrontend.parse import CNAMES | ||
| 34 | 35 | ||
| 35 | 36 | default_completion = AutocompleteModes.SIMPLE | |
| 36 | 37 | ||
| 37 | 38 | ||
| 39 | + class UnknownColorCode(Exception): | ||
| 40 | + def __init__(self, key, color): | ||
| 41 | + self.key = key | ||
| 42 | + self.color = color | ||
| 43 | + | ||
| 44 | + | ||
| 38 | 45 | class Struct: | |
| 39 | 46 | """Simple class for instantiating objects we can add arbitrary attributes | |
| 40 | 47 | to and use for various arbitrary things.""" | |
@@ -324,6 +331,11 @@ def get_key_no_doublebind(command): | |||
| 324 | 331 | f"Could not load theme '{color_scheme_name}' from {path}.\n" | |
| 325 | 332 | ) | |
| 326 | 333 | sys.exit(1) | |
| 334 | + except UnknownColorCode as ucc: | ||
| 335 | + sys.stderr.write( | ||
| 336 | + f"Theme '{color_scheme_name}' contains invalid color: {ucc.key} = {ucc.color}.\n" | ||
| 337 | + ) | ||
| 338 | + sys.exit(1) | ||
| 327 | 339 | ||
| 328 | 340 | # expand path of history file | |
| 329 | 341 | struct.hist_file = Path(struct.hist_file).expanduser() | |
@@ -362,6 +374,8 @@ def load_theme(struct, path, colors, default_colors): | |||
| 362 | 374 | colors[k] = theme.get("syntax", k) | |
| 363 | 375 | else: | |
| 364 | 376 | colors[k] = theme.get("interface", k) | |
| 377 | + if colors[k].lower() not in CNAMES: | ||
| 378 | + raise UnknownColorCode(k, colors[k]) | ||
| 365 | 379 | ||
| 366 | 380 | # Check against default theme to see if all values are defined | |
| 367 | 381 | for k, v in default_colors.items(): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments