[core/decorators] Add more tests

This commit is contained in:
Tobias Witek 2020-02-27 21:39:04 +01:00
parent 162398c6b6
commit b99ac07ef0
3 changed files with 27 additions and 8 deletions

View file

@ -13,21 +13,21 @@ def scrollable(func):
bounce = util.format.asbool(module.parameter('scrolling.bounce', True))
scroll_speed = util.format.asint(module.parameter('scrolling.speed', 1))
start = widget.get('scrolling.start', -1)
direction = widget.get('scrolling.direction', 'right')
start += scroll_speed if direction == 'right' else -(scroll_speed)
start = widget.get('scrolling.start', 0)
if width + start > len(text) + (scroll_speed - 1):
if start + width > len(text):
if bounce:
widget.set('scrolling.direction', 'left')
start -= scroll_speed*2
else:
start = 0
elif start <= 0:
elif start < 0:
if bounce:
widget.set('scrolling.direction', 'right')
else:
start = len(text)
widget.set('scrolling.start', start)
direction = widget.get('scrolling.direction', 'right')
if direction == 'left':
scroll_speed = -scroll_speed
widget.set('scrolling.start', start + scroll_speed)
text = text[start:width+start]
return text

View file

@ -80,6 +80,7 @@ class i3(object):
'full_text': self.__decorate(module, widget, text),
'color': self._theme.fg(widget),
'background': self._theme.bg(widget),
'min_width': widget.get('theme.minwidth'),
})
return [attr]