Module userland.scripts.messages.editor_screen

Message compose/reply screen

Classes

class EditorScreen (*args,
content='',
reply_to: Message | None = None,
**kwargs)
Expand source code
class EditorScreen(ModalScreen):
    """Message compose/reply screen"""

    _content: str
    reply_to: Message | None

    def __init__(
        self, *args, content="", reply_to: Message | None = None, **kwargs
    ):
        self._content = content
        self.reply_to = reply_to
        super().__init__(*args, **kwargs)

    def compose(self):
        yield TextArea(text=self._content, show_line_numbers=True)

    async def key_escape(self, key: events.Key) -> None:
        if isinstance(self.app.screen_stack[-1], SaveModal):
            return

        await self.app.push_screen(SaveModal(reply_to=self.reply_to))

Message compose/reply screen

Initialize the screen.

Args

name
The name of the screen.
id
The ID of the screen in the DOM.
classes
The CSS classes for the screen.

Ancestors

  • textual.screen.ModalScreen
  • textual.screen.Screen
  • typing.Generic
  • textual.widget.Widget
  • textual.dom.DOMNode
  • textual.message_pump.MessagePump

Class variables

var can_focus
var can_focus_children
var reply_toMessage | None

Methods

def compose(self)
Expand source code
def compose(self):
    yield TextArea(text=self._content, show_line_numbers=True)

Called by Textual to create child widgets.

This method is called when a widget is mounted or by setting recompose=True when calling [refresh()][textual.widget.Widget.refresh].

Note that you don't typically need to explicitly call this method.

Example

def compose(self) -> ComposeResult:
    yield Header()
    yield Label("Press the button below:")
    yield Button()
    yield Footer()
async def key_escape(self, key: textual.events.Key) ‑> None
Expand source code
async def key_escape(self, key: events.Key) -> None:
    if isinstance(self.app.screen_stack[-1], SaveModal):
        return

    await self.app.push_screen(SaveModal(reply_to=self.reply_to))