Fix various rendering issues
Another rendering pass is necessary before calculating the filler segment's lengths, because center segments may lose their separators after removing low-priority segments. Some unicode and variable assignment issues has been resolved so everything renders correctly.
This commit is contained in:
parent
1d3c259070
commit
addb7ccf73
|
@ -2,7 +2,6 @@
|
|||
|
||||
import vim
|
||||
import os
|
||||
import re
|
||||
|
||||
from lib.core import Powerline, mksegment
|
||||
from lib.renderers import VimSegmentRenderer
|
||||
|
@ -29,7 +28,7 @@ modes = {
|
|||
}
|
||||
|
||||
# We need to replace this private use glyph with a double-percent later
|
||||
percent_placeholder = ''.decode('utf-8')
|
||||
percent_placeholder = u''
|
||||
|
||||
if hasattr(vim, 'bindeval'):
|
||||
# This branch is used to avoid invoking vim parser as much as possible
|
||||
|
@ -100,7 +99,7 @@ def statusline(winnr):
|
|||
except TypeError:
|
||||
branch = ''
|
||||
if branch:
|
||||
branch = '⭠ ' + branch
|
||||
branch = u'⭠ ' + branch
|
||||
|
||||
# Fun gradient colored percent segment
|
||||
line_percent_gradient = [160, 166, 172, 178, 184, 190]
|
||||
|
@ -156,9 +155,9 @@ def statusline(winnr):
|
|||
powerline = Powerline([
|
||||
mksegment(mode, 22, 148, attr=Powerline.ATTR_BOLD),
|
||||
mksegment(windata['paste'], 231, 166, attr=Powerline.ATTR_BOLD),
|
||||
mksegment(windata['branch'], 250, 240, priority=10),
|
||||
mksegment(windata['branch'], 250, 240, priority=60),
|
||||
mksegment(windata['readonly'], 196, 240, draw_divider=False),
|
||||
mksegment(windata['filepath'], 250, 240, draw_divider=False, priority=5),
|
||||
mksegment(windata['filepath'], 250, 240, draw_divider=False, priority=40),
|
||||
mksegment(windata['filename'], windata['filename_color'], 240, attr=Powerline.ATTR_BOLD, draw_divider=not len(windata['modified'])),
|
||||
mksegment(windata['modified'], 220, 240, attr=Powerline.ATTR_BOLD),
|
||||
mksegment(windata['currenttag'], 246, 236, draw_divider=False, priority=100),
|
||||
|
|
|
@ -57,6 +57,7 @@ class Powerline(object):
|
|||
prev = segments[idx - 1] if idx > 0 else empty_segment
|
||||
next = segments[idx + 1] if idx < segments_len - 1 else empty_segment
|
||||
|
||||
segment['rendered_raw'] = u''
|
||||
compare = next if segment['side'] == 'l' else prev
|
||||
outer_padding = ' ' if idx == 0 or idx == segments_len - 1 else ''
|
||||
divider_type = 'soft' if compare['bg'] == segment['bg'] else 'hard'
|
||||
|
@ -117,6 +118,9 @@ class Powerline(object):
|
|||
self.segments.remove(segments_priority[0])
|
||||
segments_priority.pop(0)
|
||||
|
||||
# Do another render pass so we can calculate the correct amount of filler space
|
||||
render_segments(self.segments)
|
||||
|
||||
# Distribute the remaining space on the filler segments
|
||||
segments_fillers = [segment for segment in self.segments if segment['filler'] is True]
|
||||
if segments_fillers:
|
||||
|
@ -155,5 +159,4 @@ def mksegment(contents=None, cterm_fg=False, cterm_bg=False, attr=False, hex_fg=
|
|||
'draw_divider': False if filler else draw_divider,
|
||||
'priority': priority,
|
||||
'filler': filler,
|
||||
'rendered_raw': u'',
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue