Make spaces around the divider configurable

Fixes #225
This commit is contained in:
ZyX 2013-02-16 01:47:41 +04:00 committed by Kim Silkebækken
parent 6fc7d6acc9
commit 2a3911dbe6
3 changed files with 13 additions and 9 deletions

View File

@ -3,14 +3,15 @@
"term_24bit_colors": false,
"dividers": {
"left": {
"hard": "",
"soft": ""
"hard": " ",
"soft": " "
},
"right": {
"hard": "",
"soft": ""
"hard": " ",
"soft": " "
}
}
},
"spaces": 1
},
"ext": {
"ipython": {

View File

@ -104,6 +104,7 @@ class Renderer(object):
divider_type = 'soft' if compare_segment['highlight'][mode]['bg'] == segment['highlight'][mode]['bg'] else 'hard'
divider_raw = theme.get_divider(segment['side'], divider_type)
divider_spaces = theme.get_spaces()
divider_highlighted = ''
contents_raw = segment['contents']
contents_highlighted = ''
@ -111,11 +112,9 @@ class Renderer(object):
# Pad segments first
if segment['draw_divider'] or (divider_type == 'hard' and segment['width'] != 'auto'):
if segment['side'] == 'left':
contents_raw = outer_padding + (segment['_space_left'] * ' ') + contents_raw + (segment['_space_right'] * ' ') + ' '
divider_raw = divider_raw + ' '
contents_raw = outer_padding + (segment['_space_left'] * ' ') + contents_raw + ((divider_spaces + segment['_space_right']) * ' ')
else:
contents_raw = ' ' + (segment['_space_left'] * ' ') + contents_raw + (segment['_space_right'] * ' ') + outer_padding
divider_raw = ' ' + divider_raw
contents_raw = ((divider_spaces + segment['_space_left']) * ' ') + contents_raw + (segment['_space_right'] * ' ') + outer_padding
else:
if segment['side'] == 'left':
contents_raw = outer_padding + (segment['_space_left'] * ' ') + contents_raw + (segment['_space_right'] * ' ')

View File

@ -20,6 +20,7 @@ class Theme(object):
def __init__(self, ext, colorscheme, theme_config, common_config, segment_info=None):
self.colorscheme = colorscheme
self.dividers = theme_config.get('dividers', common_config['dividers'])
self.spaces = theme_config.get('spaces', common_config['spaces'])
self.segments = {
'left': [],
'right': [],
@ -37,6 +38,9 @@ class Theme(object):
'''Return segment divider.'''
return self.dividers[side][type]
def get_spaces(self):
return self.spaces
def add_highlight(self, segment):
segment['highlight'] = self.colorscheme.get_group_highlighting(segment['highlight_group'])
if segment['divider_highlight_group']: