Skip to main content

TuiApp

Struct TuiApp 

Source
pub struct TuiApp { /* private fields */ }
Expand description

Owns the TUI render state and input dispatcher.

Tracks the serial data pane, the configuration-menu open/closed state, and a lightweight device summary shown on the top bar. Input handling lives in TuiApp::handle_key, which routes keyboard events through an internal CommandKeyParser whenever the menu is closed.

Implementations§

Source§

impl TuiApp

Source

pub fn new(bus: EventBus) -> Self

Construct a new TuiApp bound to the given event bus.

Starts with a 24x80 serial pane and a default SerialConfig; the pane is resized to the terminal body on every call to TuiApp::render, and the config is overwritten by TuiApp::set_serial_config once the runner knows the real link parameters.

Source

pub fn set_wheel_scroll_lines(&mut self, n: u16)

Override the mouse-wheel scroll speed (lines per notch).

Values less than 1 are clamped to 1 so the wheel never turns into a no-op — a wheel event that moves nothing visibly suggests rtcom is broken even when the underlying config is “intentionally disabled”. Users who want to pin the view can simply not scroll.

Source

pub fn set_cli_overrides(&mut self, fields: Vec<&'static str>)

Record which CLI flags overrode a profile value at startup.

Each element is a short, user-facing flag label (-b, -d, --omap/--imap/--emap, …). The crate::menu::SerialPortSetupDialog shows a “N field(s) overridden by CLI” hint at the bottom when this list is non-empty; empty disables the hint entirely.

Source

pub fn push_toast(&mut self, message: impl Into<String>, level: ToastLevel)

Push a new toast onto the queue. Consumed by the runner’s bus-event handler for profile IO + error events.

Source

pub const fn toasts_mut(&mut self) -> &mut ToastQueue

Mutable access to the toast queue. Mainly used by tests and the main-loop tick to advance expiration.

Source

pub const fn toasts(&self) -> &ToastQueue

Immutable borrow of the toast queue (read-only introspection).

Source

pub const fn set_serial_config(&mut self, cfg: SerialConfig)

Update the cached SerialConfig that new RootMenu pushes pass down to sub-dialogs.

Call this whenever the live session’s config changes (T17 wires this into Event::ConfigChanged).

Source

pub const fn set_line_endings(&mut self, le: LineEndingConfig)

Update the cached LineEndingConfig that new RootMenu pushes pass down to the T13 crate::menu::LineEndingsDialog.

Call this whenever the live session’s mapper configuration changes (T17 wires this into the ApplyLineEndingsLive path).

Source

pub const fn set_modem_lines(&mut self, snapshot: ModemLineSnapshot)

Update the cached ModemLineSnapshot that new RootMenu pushes pass down to the T14 crate::menu::ModemControlDialog.

Call this whenever the live session’s modem output lines change (T17 wires this into the SetDtr / SetRts paths).

Source

pub const fn set_modal_style(&mut self, style: ModalStyle)

Update the cached ModalStyle that new RootMenu pushes pass down to the T15 crate::menu::ScreenOptionsDialog.

Call this whenever the live modal-style preference changes (T17 wires this into the ApplyModalStyleLive / AndSave paths).

Source

pub const fn is_menu_open(&self) -> bool

Whether the configuration menu is currently open.

Source

pub fn set_device_summary( &mut self, device_path: impl Into<String>, config_summary: impl Into<String>, )

Update the device path + config summary shown on the top bar.

Accepts any type convertible to String so call sites can pass either borrowed or owned strings.

Source

pub fn set_config_summary(&mut self, config_summary: impl Into<String>)

Update just the config-summary portion of the top bar, leaving the device path untouched.

Used by the bus subscriber to refresh the status line after an Event::ConfigChanged without having to know the device path.

Source

pub const fn serial_pane_mut(&mut self) -> &mut SerialPane

Mutable access to the serial data pane.

Primarily used by the serial-reader subscriber to ingest incoming bytes; tests also use it to seed a known screen state.

Source

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

Route a key event.

When the menu is closed, the event is converted to bytes via crate::input::key_to_bytes and fed one byte at a time to the internal CommandKeyParser:

When the menu is open, the event is handed to the topmost crate::modal::Dialog on the ModalStack. The stack auto-manages Close / Push outcomes; this function only needs to detect the root dialog closing (stack becomes empty) to publish Event::MenuClosed and flip menu_open back. Action outcomes bubble up as Dispatch::Action for the runner to apply.

Source

pub fn handle_mouse(&mut self, ev: MouseEvent) -> Dispatch

Route a mouse event.

v0.2 handles only wheel scroll: MouseEventKind::ScrollUp and MouseEventKind::ScrollDown move the serial pane’s scrollback view by TuiApp::set_wheel_scroll_lines lines per notch. Click / drag / move events are ignored until v0.2.1 lands selection + copy. Menu-open mouse events are also ignored — the menu is keyboard-only for now.

Source

pub fn render(&mut self, f: &mut Frame<'_>)

Render the main screen into f.

Layout: 1-row top bar (“rtcom {version} | {device} | {config}”), body (serial pane rendered via tui_term), 1-row bottom bar with command-key hints. The serial pane is resized to the body size every frame so it follows terminal resizes.

When the configuration menu is open, the body is drawn according to the current ModalStyle (set via TuiApp::set_modal_style):

  • ModalStyle::Overlay: serial pane drawn normally; the modal dialog is painted over it at its preferred size.
  • ModalStyle::DimmedOverlay: serial pane drawn normally, then every body cell has Modifier::DIM OR-ed into its style so the stream fades behind the modal. The modal is then painted on top at full brightness.
  • ModalStyle::Fullscreen: the serial pane is not drawn at all; the modal fills the entire body area. The top/bottom chrome bars remain visible.

Auto Trait Implementations§

§

impl Freeze for TuiApp

§

impl !RefUnwindSafe for TuiApp

§

impl Send for TuiApp

§

impl !Sync for TuiApp

§

impl Unpin for TuiApp

§

impl UnsafeUnpin for TuiApp

§

impl !UnwindSafe for TuiApp

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more