Skip to main content

Dialog

Trait Dialog 

Source
pub trait Dialog {
    // Required methods
    fn title(&self) -> &str;
    fn render(&self, area: Rect, buf: &mut Buffer);
    fn handle_key(&mut self, key: KeyEvent) -> DialogOutcome;

    // Provided method
    fn preferred_size(&self, outer: Rect) -> Rect { ... }
}
Expand description

A full-screen or modal dialog rendered over the main TUI chrome.

Implementors typically hold their own local state (cursor, field values, …), draw themselves inside the provided area, and emit a DialogOutcome per key event to tell the surrounding ModalStack how to react.

Required Methods§

Source

fn title(&self) -> &str

Human-readable title, used for decoration.

Source

fn render(&self, area: Rect, buf: &mut Buffer)

Render the dialog into the given area.

Source

fn handle_key(&mut self, key: KeyEvent) -> DialogOutcome

Handle a key event and report back how the stack should react.

Provided Methods§

Source

fn preferred_size(&self, outer: Rect) -> Rect

Preferred size of the dialog when rendered inside outer.

The default implementation returns a 30x12 rectangle centred inside outer — enough for a typical seven-item menu. Dialogs with more fields (e.g. the serial-port setup dialog) override this to return a wider rect. The crate::app::TuiApp render loop consults this method to position the modal overlay.

Implementors§