mirror of
https://github.com/powerline/powerline.git
synced 2025-07-26 07:16:31 +02:00
Change wording: separator -> divider
This commit is contained in:
parent
b461ab1358
commit
f47dc4bffd
58
lib/core.py
58
lib/core.py
@ -22,7 +22,7 @@ class Segment:
|
|||||||
|
|
||||||
print(powerline.render(TerminalSegmentRenderer))
|
print(powerline.render(TerminalSegmentRenderer))
|
||||||
'''
|
'''
|
||||||
separators = {
|
dividers = {
|
||||||
'l': {
|
'l': {
|
||||||
'hard': '⮀',
|
'hard': '⮀',
|
||||||
'soft': '⮁',
|
'soft': '⮁',
|
||||||
@ -37,11 +37,11 @@ class Segment:
|
|||||||
ATTR_ITALIC = 2
|
ATTR_ITALIC = 2
|
||||||
ATTR_UNDERLINE = 4
|
ATTR_UNDERLINE = 4
|
||||||
|
|
||||||
def __init__(self, content='', fg=None, bg=None, attr=None, side=None, padding=None, separate=None):
|
def __init__(self, content='', fg=None, bg=None, attr=None, side=None, padding=None, divide=None):
|
||||||
'''Create a new segment.
|
'''Create a new segment.
|
||||||
|
|
||||||
No arguments are required when creating new segments, as
|
No arguments are required when creating new segments, as
|
||||||
empty/colorless segments can be used e.g. as left/right separators.
|
empty/colorless segments can be used e.g. as left/right dividers.
|
||||||
'''
|
'''
|
||||||
self.content = content
|
self.content = content
|
||||||
self.parent = None
|
self.parent = None
|
||||||
@ -67,7 +67,7 @@ class Segment:
|
|||||||
self._attr = attr
|
self._attr = attr
|
||||||
self._side = side
|
self._side = side
|
||||||
self._padding = padding
|
self._padding = padding
|
||||||
self._separate = separate
|
self._divide = divide
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fg(self):
|
def fg(self):
|
||||||
@ -122,7 +122,7 @@ class Segment:
|
|||||||
'''Segment padding property.
|
'''Segment padding property.
|
||||||
|
|
||||||
Return which string is used to pad the segment before and after the
|
Return which string is used to pad the segment before and after the
|
||||||
separator symbol.
|
divider symbol.
|
||||||
|
|
||||||
Recursively searches for the property or the parent segments' property
|
Recursively searches for the property or the parent segments' property
|
||||||
until one is found. If this property is not defined anywhere in the
|
until one is found. If this property is not defined anywhere in the
|
||||||
@ -133,35 +133,35 @@ class Segment:
|
|||||||
return self._padding if self._padding is not None else ' '
|
return self._padding if self._padding is not None else ' '
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def separate(self):
|
def divide(self):
|
||||||
'''Segment separation property.
|
'''Segment divider property.
|
||||||
|
|
||||||
Returns whether a separator symbol should be drawn before/after the
|
Returns whether a divider symbol should be drawn before/after the
|
||||||
segment.
|
segment.
|
||||||
|
|
||||||
Recursively searches for the property or the parent segments' property
|
Recursively searches for the property or the parent segments' property
|
||||||
until one is found. If this property is not defined anywhere in the
|
until one is found. If this property is not defined anywhere in the
|
||||||
tree, then separators will be drawn around all segments.
|
tree, then dividers will be drawn around all segments.
|
||||||
'''
|
'''
|
||||||
if self.parent and self._separate is None:
|
if self.parent and self._divide is None:
|
||||||
return self.parent.separate
|
return self.parent.divide
|
||||||
return self._separate if self._separate is not None else True
|
return self._divide if self._divide is not None else True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def separator(self):
|
def divider(self):
|
||||||
'''Segment separator property.
|
'''Segment divider property.
|
||||||
|
|
||||||
Returns the separator symbol to be used, depending on which side this
|
Returns the divider symbol to be used, depending on which side this
|
||||||
segment is on.
|
segment is on.
|
||||||
'''
|
'''
|
||||||
return self.separators[self.side]
|
return self.dividers[self.side]
|
||||||
|
|
||||||
def render(self, renderer):
|
def render(self, renderer):
|
||||||
'''Render the segment and all child segments.
|
'''Render the segment and all child segments.
|
||||||
|
|
||||||
This method flattens the segment and all its child segments into
|
This method flattens the segment and all its child segments into
|
||||||
a one-dimensional array. It then loops through this array and compares
|
a one-dimensional array. It then loops through this array and compares
|
||||||
the foreground/background colors and separator/padding properties and
|
the foreground/background colors and divider/padding properties and
|
||||||
returns the rendered statusline as a string.
|
returns the rendered statusline as a string.
|
||||||
'''
|
'''
|
||||||
def flatten(segment):
|
def flatten(segment):
|
||||||
@ -183,7 +183,7 @@ class Segment:
|
|||||||
output = ''
|
output = ''
|
||||||
|
|
||||||
# Loop through the segment array and create the segments, colors and
|
# Loop through the segment array and create the segments, colors and
|
||||||
# separators
|
# dividers
|
||||||
#
|
#
|
||||||
# TODO Make this prettier
|
# TODO Make this prettier
|
||||||
for idx, segment in enumerate(segments):
|
for idx, segment in enumerate(segments):
|
||||||
@ -200,32 +200,32 @@ class Segment:
|
|||||||
output += renderer.hl(attr=False)
|
output += renderer.hl(attr=False)
|
||||||
if segment.content:
|
if segment.content:
|
||||||
if segment.next.bg == segment.bg:
|
if segment.next.bg == segment.bg:
|
||||||
if segment.next.content and segment.separate:
|
if segment.next.content and segment.divide:
|
||||||
output += segment.padding
|
output += segment.padding
|
||||||
if segment.next.side == segment.side:
|
if segment.next.side == segment.side:
|
||||||
# Only draw the soft separator if this segment is on the same side
|
# Only draw the soft divider if this segment is on the same side
|
||||||
# No need to draw the soft separator if there's e.g. a vim divider in the next segment
|
# No need to draw the soft divider if there's e.g. a vim separation point in the next segment
|
||||||
output += segment.separator['soft']
|
output += segment.divider['soft']
|
||||||
# Don't draw a hard separator if the next segment is on
|
# Don't draw a hard divider if the next segment is on
|
||||||
# the opposite side, it screws up the coloring
|
# the opposite side, it screws up the coloring
|
||||||
elif segment.next.side == segment.side:
|
elif segment.next.side == segment.side:
|
||||||
output += segment.padding
|
output += segment.padding
|
||||||
output += renderer.hl(segment.bg, segment.next.bg)
|
output += renderer.hl(segment.bg, segment.next.bg)
|
||||||
output += segment.separator['hard']
|
output += segment.divider['hard']
|
||||||
else:
|
else:
|
||||||
pad_pre = False
|
pad_pre = False
|
||||||
if segment.content:
|
if segment.content:
|
||||||
if segment.prev.bg == segment.bg:
|
if segment.prev.bg == segment.bg:
|
||||||
if segment.prev.content and segment.separate:
|
if segment.prev.content and segment.divide:
|
||||||
pad_pre = True
|
pad_pre = True
|
||||||
if segment.prev.side == segment.side:
|
if segment.prev.side == segment.side:
|
||||||
# Only draw the soft separator if this segment is on the same side
|
# Only draw the soft divider if this segment is on the same side
|
||||||
# No need to draw the soft separator if there's e.g. a vim divider in the previous segment
|
# No need to draw the soft divider if there's e.g. a vim separation point in the previous segment
|
||||||
output += segment.separator['soft']
|
output += segment.divider['soft']
|
||||||
else:
|
else:
|
||||||
pad_pre = True
|
pad_pre = True
|
||||||
output += renderer.hl(segment.bg, segment.prev.bg)
|
output += renderer.hl(segment.bg, segment.prev.bg)
|
||||||
output += segment.separator['hard']
|
output += segment.divider['hard']
|
||||||
output += renderer.hl(segment.fg, segment.bg, segment.attr)
|
output += renderer.hl(segment.fg, segment.bg, segment.attr)
|
||||||
if pad_pre:
|
if pad_pre:
|
||||||
output += segment.padding
|
output += segment.padding
|
||||||
|
@ -11,7 +11,7 @@ powerline = Segment([
|
|||||||
Segment([
|
Segment([
|
||||||
Segment(' ~/projects/powerline/lib/'),
|
Segment(' ~/projects/powerline/lib/'),
|
||||||
Segment('core.py ', 231, attr=Segment.ATTR_BOLD),
|
Segment('core.py ', 231, attr=Segment.ATTR_BOLD),
|
||||||
], 250, 240, separate=False, padding=''),
|
], 250, 240, divide=False, padding=''),
|
||||||
Segment('%<%='),
|
Segment('%<%='),
|
||||||
Segment([
|
Segment([
|
||||||
Segment('unix'),
|
Segment('unix'),
|
||||||
@ -22,7 +22,7 @@ powerline = Segment([
|
|||||||
Segment(' ⭡ ', 239),
|
Segment(' ⭡ ', 239),
|
||||||
Segment('23', attr=Segment.ATTR_BOLD),
|
Segment('23', attr=Segment.ATTR_BOLD),
|
||||||
Segment(':1 ', 244),
|
Segment(':1 ', 244),
|
||||||
], 235, 252, separate=False, padding=''),
|
], 235, 252, divide=False, padding=''),
|
||||||
], 245, side='r'),
|
], 245, side='r'),
|
||||||
], bg=236)
|
], bg=236)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user