Handle segment exclude/include modes

This commit is contained in:
Kim Silkebækken 2012-12-10 19:46:54 +01:00
parent 19248503ef
commit 42d8353db6
2 changed files with 5 additions and 2 deletions

View File

@ -19,7 +19,7 @@ class Renderer(object):
provided they will fill the remaining space until the desired width is
reached.
'''
self.segments = self.theme.get_segments()
self.segments = self.theme.get_segments(mode)
rendered_highlighted = self._render_segments(mode)
if not width:

View File

@ -51,7 +51,7 @@ class Theme(object):
'''
return self.dividers[side][type]
def get_segments(self):
def get_segments(self, mode):
'''Return all segments.
Function segments are called, and all segments get their before/after
@ -59,6 +59,9 @@ class Theme(object):
'''
return_segments = []
for segment in self.segments:
if mode in segment['exclude_modes'] or (segment['include_modes'] and segment not in segment['include_modes']):
continue
if segment['type'] == 'function':
contents_func_ret = segment['contents_func'](**segment['args'])