[core/theme] Add inline named color support
Add named colors that can be specified directly in the "colors" array within a theme. fixes #556
This commit is contained in:
parent
5134ce3b5b
commit
0751b7c084
2 changed files with 16 additions and 5 deletions
|
@ -186,9 +186,14 @@ class Theme(object):
|
||||||
result[key] = colors[field][key]
|
result[key] = colors[field][key]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def color(self, color_name, default=None):
|
||||||
|
return self._colorset.get(color_name, default)
|
||||||
|
|
||||||
def _load_colors(self, name):
|
def _load_colors(self, name):
|
||||||
"""Load colors for a theme"""
|
"""Load colors for a theme"""
|
||||||
try:
|
try:
|
||||||
|
if isinstance(name, dict):
|
||||||
|
return name
|
||||||
if name.lower() == "wal":
|
if name.lower() == "wal":
|
||||||
return self._load_wal_colors()
|
return self._load_wal_colors()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -285,7 +290,7 @@ class Theme(object):
|
||||||
|
|
||||||
if isinstance(value, (dict, list)):
|
if isinstance(value, (dict, list)):
|
||||||
return value
|
return value
|
||||||
return self._colorset.get(value, value)
|
return self.color(value, value)
|
||||||
|
|
||||||
# algorithm copied from
|
# algorithm copied from
|
||||||
# http://blog.impressiver.com/post/31434674390/deep-merge-multiple-python-dicts
|
# http://blog.impressiver.com/post/31434674390/deep-merge-multiple-python-dicts
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
{
|
{
|
||||||
"icons": [ "paxy97", "awesome-fonts" ],
|
"icons": [ "paxy97", "awesome-fonts" ],
|
||||||
|
"colors": [{
|
||||||
|
"fg0": "#fbf1c7",
|
||||||
|
"bg0_h": "#1d2021",
|
||||||
|
"yellow": "#d79921",
|
||||||
|
"red": "#cc241d"
|
||||||
|
}],
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"warning": {
|
"warning": {
|
||||||
"fg": "#1d2021",
|
"fg": "bg0_h",
|
||||||
"bg": "#d79921"
|
"bg": "yellow"
|
||||||
},
|
},
|
||||||
"critical": {
|
"critical": {
|
||||||
"fg": "#fbf1c7",
|
"fg": "fg0",
|
||||||
"bg": "#cc241d"
|
"bg": "red"
|
||||||
},
|
},
|
||||||
"default-separators": false,
|
"default-separators": false,
|
||||||
"separator-block-width": 0
|
"separator-block-width": 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue