diff --git a/cheuph/__init__.py b/cheuph/__init__.py index 9404128..efa48dc 100644 --- a/cheuph/__init__.py +++ b/cheuph/__init__.py @@ -7,10 +7,10 @@ from .config import * from .exceptions import * from .markup import * from .message import * -from .message_cache import * from .message_editor_widget import * from .message_supply import * from .message_tree_widget import * +from .rendered_message_cache import * from .user_list_widget import * __all__: List[str] = [] @@ -22,8 +22,8 @@ __all__ += config.__all__ __all__ += exceptions.__all__ __all__ += markup.__all__ __all__ += message.__all__ -__all__ += message_cache.__all__ __all__ += message_editor_widget.__all__ __all__ += message_supply.__all__ __all__ += message_tree_widget.__all__ +__all__ += rendered_message_cache.__all__ __all__ += user_list_widget.__all__ diff --git a/cheuph/attributed_lines_widget.py b/cheuph/attributed_lines_widget.py index aec81d9..1d1123c 100644 --- a/cheuph/attributed_lines_widget.py +++ b/cheuph/attributed_lines_widget.py @@ -1,4 +1,4 @@ -__all__ = ["AttributedLinesWidget", "ALWidget"] +__all__ = ["AttributedLinesWidget"] class AttributedLinesWidget: @@ -12,5 +12,3 @@ class AttributedLinesWidget: """ pass - -ALWidget = AttributedLinesWidget diff --git a/cheuph/message.py b/cheuph/message.py index 9e407a4..e5a1634 100644 --- a/cheuph/message.py +++ b/cheuph/message.py @@ -1,4 +1,9 @@ -__all__ = ["Message", "RenderedMessage"] +from typing import Hashable + +__all__ = ["Id", "Message", "RenderedMessage"] + + +Id = Hashable class Message: diff --git a/cheuph/message_tree_widget.py b/cheuph/message_tree_widget.py index 547e31f..73dd0fc 100644 --- a/cheuph/message_tree_widget.py +++ b/cheuph/message_tree_widget.py @@ -1,7 +1,17 @@ +from typing import Optional, Set + +import urwid +import yaboli + +from .attributed_lines_widget import AttributedLinesWidget +from .message import Id +from .message_supply import MessageSupply +from .rendered_message_cache import RenderedMessageCache + __all__ = ["MessageTreeWidget"] -class MessageTreeWidget: +class MessageTreeWidget(urwid.WidgetWrap): """ This widget displays an ElementSupply, including user interface like a cursor or folding markers. It usually is part of a RoomWidget. It also @@ -24,4 +34,35 @@ class MessageTreeWidget: finishes editing it. """ - pass + ROOM_IS_EMPTY = "" + + def __init__(self, + room: yaboli.Room, + supply: MessageSupply, + ) -> None: + + self.room = room + self.supply = supply + self.rendered = RenderedMessageCache() + self.lines = AttributedLinesWidget() + self.placeholder = urwid.Filler(urwid.Text(self.ROOM_IS_EMPTY, + align=urwid.CENTER)) + + # If the anchor is None, but the cursor isn't, the cursor is used as + # the anchor. + self.cursor: Optional[Id] = None + self.anchor: Optional[Id] = None + self.anchor_offset = 0 + + self.folds: Set[Id] = set() + + super().__init__(self.placeholder) + + def invalidate_message(self, message_id: Id) -> None: + pass + + def invalidate_all_messages(self) -> None: + pass + + def redraw(self) -> None: + pass diff --git a/cheuph/message_cache.py b/cheuph/rendered_message_cache.py similarity index 100% rename from cheuph/message_cache.py rename to cheuph/rendered_message_cache.py