[core/themes] Add separator customization
Add customized separators: * The default separators are automatically disabled if custom separators are used (to "just" disable the default, use empty custom separators) * Use previous background color as their background color and the current background color as foreground color * Allow the separator-block-width to be configured see #23
This commit is contained in:
parent
527489e0de
commit
c1f1e1a939
6 changed files with 66 additions and 5 deletions
|
@ -36,6 +36,7 @@ class Theme(object):
|
|||
self._cycle = self._cycles[0] if len(self._cycles) > 0 else {}
|
||||
self._cycle_idx = 0
|
||||
self._widget = None
|
||||
self._prevbg = None
|
||||
|
||||
def prefix(self, widget):
|
||||
"""Return the theme prefix for a widget's full text"""
|
||||
|
@ -57,6 +58,20 @@ class Theme(object):
|
|||
"""Return the background color for this widget"""
|
||||
return self._get(widget, "bg", None)
|
||||
|
||||
def separator(self, widget):
|
||||
"""Return the separator between widgets"""
|
||||
return self._get(widget, "separator", None)
|
||||
|
||||
def separator_fg(self, widget):
|
||||
return self.bg(widget)
|
||||
|
||||
def separator_bg(self, widget):
|
||||
return self._prevbg
|
||||
|
||||
def separator_block_width(self, widget):
|
||||
"""Return the SBW"""
|
||||
return self._get(widget, "separator-block-width", None)
|
||||
|
||||
def loads(self, data):
|
||||
"""Initialize the theme from a JSON string"""
|
||||
theme = json.loads(data)
|
||||
|
@ -87,9 +102,11 @@ class Theme(object):
|
|||
self._widget = widget
|
||||
|
||||
if self._widget != widget:
|
||||
self._prevbg = self.bg(self._widget)
|
||||
self._widget = widget
|
||||
self._cycle_idx = (self._cycle_idx + 1) % len(self._cycles)
|
||||
self._cycle = self._cycles[self._cycle_idx]
|
||||
if len(self._cycles) > 0:
|
||||
self._cycle_idx = (self._cycle_idx + 1) % len(self._cycles)
|
||||
self._cycle = self._cycles[self._cycle_idx]
|
||||
|
||||
module_theme = self._theme.get(widget.module, {})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue