Only drop segments whose contents are None
This commit is contained in:
parent
11ee10851c
commit
636f1719fb
|
@ -5,10 +5,10 @@ class Powerline(object):
|
||||||
def __init__(self, segments):
|
def __init__(self, segments):
|
||||||
'''Create a new Powerline.
|
'''Create a new Powerline.
|
||||||
|
|
||||||
Segments that have empty contents and aren't filler segments are
|
Segments that aren't filler segments and whose contents aren't None are
|
||||||
dropped from the segment array.
|
dropped from the segment array.
|
||||||
'''
|
'''
|
||||||
self.segments = [segment for segment in segments if segment['contents'] or segment['filler']]
|
self.segments = [segment for segment in segments if segment['contents'] is not None or segment['filler']]
|
||||||
|
|
||||||
def render(self, renderer, width=None):
|
def render(self, renderer, width=None):
|
||||||
r = renderer(self.segments)
|
r = renderer(self.segments)
|
||||||
|
|
|
@ -6,6 +6,7 @@ from colorscheme import cterm_to_hex
|
||||||
def mksegment(contents=None, cterm_fg=False, cterm_bg=False, attr=False, hex_fg=False, hex_bg=False, side='l', draw_divider=True, priority=-1, filler=False):
|
def mksegment(contents=None, cterm_fg=False, cterm_bg=False, attr=False, hex_fg=False, hex_bg=False, side='l', draw_divider=True, priority=-1, filler=False):
|
||||||
'''Convenience wrapper for segment generation.
|
'''Convenience wrapper for segment generation.
|
||||||
'''
|
'''
|
||||||
|
if contents is not None or filler:
|
||||||
try:
|
try:
|
||||||
contents = unicode(contents or u'')
|
contents = unicode(contents or u'')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
|
|
Loading…
Reference in New Issue