Clean up and re-add attributed text widgets

This commit is contained in:
Joscha 2019-06-07 04:49:45 +00:00
parent 5e10fcecac
commit ba2f64762f
3 changed files with 11 additions and 20 deletions

View file

@ -1,6 +1,8 @@
from typing import List
from .attributed_lines import *
from .attributed_lines_widget import *
from .attributed_text_widget import *
from .cursor_rendering import *
from .element import *
from .element_supply import *
@ -10,6 +12,8 @@ from .rendered_element_cache import *
__all__: List[str] = []
__all__ += attributed_lines.__all__
__all__ += attributed_lines_widget.__all__
__all__ += attributed_text_widget.__all__
__all__ += cursor_rendering.__all__
__all__ += element.__all__
__all__ += element_supply.__all__

View file

@ -1,40 +1,28 @@
# TODO send event on mouse click
from typing import Any, Optional, Tuple
from typing import Optional, Tuple
import urwid
from .attributed_lines import AttributedLines
from .attributed_text_widget import AttributedTextWidget
from .markup import AT, AttributedText, Attributes
from .markup import AT
__all__ = ["AttributedLinesWidget"]
class AttributedLinesWidget(urwid.WidgetWrap):
"""
This widget draws lines of AttributedText with a horizontal and a vertical
offset. It can retrieve the attributes of any character by its (x, y)
coordinates. Line-wide attributes may be specified.
When clicked, it sends an event containing the attributes of the character
that was just clicked.
Uses the following config values:
- "filler_symbol"
- "overflow_symbol"
This widget draws an AttributedLines with a horizontal and a vertical
offset.
"""
def __init__(self,
lines: Optional[AttributedLines] = None,
) -> None:
self._horizontal_offset = 0
def __init__(self, lines: Optional[AttributedLines] = None) -> None:
self._text = AttributedTextWidget(AT())
self._filler = urwid.Filler(self._text, valign=urwid.TOP)
super().__init__(self._filler)
self._horizontal_offset = 0
self.set_lines(lines or AttributedLines())
@property

View file

@ -6,7 +6,6 @@ from .markup import AttributedText
__all__ = ["AttributedTextWidget", "ATWidget"]
class AttributedTextWidget(urwid.Text):
"""
A widget that works like urwid.Text, but displays AttributedText.