Clean up and re-add attributed text widgets
This commit is contained in:
parent
5e10fcecac
commit
ba2f64762f
3 changed files with 11 additions and 20 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from .attributed_lines import *
|
from .attributed_lines import *
|
||||||
|
from .attributed_lines_widget import *
|
||||||
|
from .attributed_text_widget import *
|
||||||
from .cursor_rendering import *
|
from .cursor_rendering import *
|
||||||
from .element import *
|
from .element import *
|
||||||
from .element_supply import *
|
from .element_supply import *
|
||||||
|
|
@ -10,6 +12,8 @@ from .rendered_element_cache import *
|
||||||
__all__: List[str] = []
|
__all__: List[str] = []
|
||||||
|
|
||||||
__all__ += attributed_lines.__all__
|
__all__ += attributed_lines.__all__
|
||||||
|
__all__ += attributed_lines_widget.__all__
|
||||||
|
__all__ += attributed_text_widget.__all__
|
||||||
__all__ += cursor_rendering.__all__
|
__all__ += cursor_rendering.__all__
|
||||||
__all__ += element.__all__
|
__all__ += element.__all__
|
||||||
__all__ += element_supply.__all__
|
__all__ += element_supply.__all__
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,28 @@
|
||||||
# TODO send event on mouse click
|
# TODO send event on mouse click
|
||||||
|
|
||||||
from typing import Any, Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
from .attributed_lines import AttributedLines
|
from .attributed_lines import AttributedLines
|
||||||
from .attributed_text_widget import AttributedTextWidget
|
from .attributed_text_widget import AttributedTextWidget
|
||||||
from .markup import AT, AttributedText, Attributes
|
from .markup import AT
|
||||||
|
|
||||||
__all__ = ["AttributedLinesWidget"]
|
__all__ = ["AttributedLinesWidget"]
|
||||||
|
|
||||||
|
|
||||||
class AttributedLinesWidget(urwid.WidgetWrap):
|
class AttributedLinesWidget(urwid.WidgetWrap):
|
||||||
"""
|
"""
|
||||||
This widget draws lines of AttributedText with a horizontal and a vertical
|
This widget draws an AttributedLines with a horizontal and a vertical
|
||||||
offset. It can retrieve the attributes of any character by its (x, y)
|
offset.
|
||||||
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"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self, lines: Optional[AttributedLines] = None) -> None:
|
||||||
lines: Optional[AttributedLines] = None,
|
|
||||||
) -> None:
|
|
||||||
|
|
||||||
self._horizontal_offset = 0
|
|
||||||
|
|
||||||
self._text = AttributedTextWidget(AT())
|
self._text = AttributedTextWidget(AT())
|
||||||
self._filler = urwid.Filler(self._text, valign=urwid.TOP)
|
self._filler = urwid.Filler(self._text, valign=urwid.TOP)
|
||||||
super().__init__(self._filler)
|
super().__init__(self._filler)
|
||||||
|
|
||||||
|
self._horizontal_offset = 0
|
||||||
|
|
||||||
self.set_lines(lines or AttributedLines())
|
self.set_lines(lines or AttributedLines())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ from .markup import AttributedText
|
||||||
|
|
||||||
__all__ = ["AttributedTextWidget", "ATWidget"]
|
__all__ = ["AttributedTextWidget", "ATWidget"]
|
||||||
|
|
||||||
|
|
||||||
class AttributedTextWidget(urwid.Text):
|
class AttributedTextWidget(urwid.Text):
|
||||||
"""
|
"""
|
||||||
A widget that works like urwid.Text, but displays AttributedText.
|
A widget that works like urwid.Text, but displays AttributedText.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue