Skip to main content

TuiState

Struct TuiState 

Source
pub struct TuiState {
    pub input: String,
    pub history: Vec<String>,
    pub ctx: SessionContext,
    pub running: Option<Running>,
    pub overlay: Option<Overlay>,
    pub grid: Option<GridState>,
    pub grid_shown: bool,
    pub wizard: Option<WizardState>,
    pub start: Option<Commands>,
    /* private fields */
}
Expand description

The complete TUI state.

Fields§

§input: String

The input line.

§history: Vec<String>

Submitted lines, oldest first.

§ctx: SessionContext

The session context.

§running: Option<Running>

The command that runs in the pane now.

§overlay: Option<Overlay>

The open completion menu, palette or search, if any.

§grid: Option<GridState>

The watchlist grid, while a watchlist runs or until its finished grid is closed (#47).

§grid_shown: bool

The grid is on screen (in place of the output pane).

§wizard: Option<WizardState>

The monitor wizard, while it is open (#47).

§start: Option<Commands>

A command to run when the loop starts: scope monitor <args> opens the TUI with its wizard (#47).

Implementations§

Source§

impl TuiState

Source

pub fn new(ctx: SessionContext, journal: Journal, vocab: Vocab) -> Self

Creates the state with a context and a history.

Source

pub fn journal(&self) -> &Journal

The journal, for saving the history on exit.

Source

pub fn set_vocab(&mut self, vocab: Vocab)

Replaces the completion words, after the config was read again.

Source

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

Applies one key event.

Source

pub fn paste(&mut self, text: &str)

Inserts pasted text at the cursor as one line. A paste never runs the line, also when it ends in a newline. Line breaks become spaces, a tab becomes a space, and other control characters are dropped, so a paste cannot put an escape sequence in the input.

Source

pub fn wheel(&mut self, rows: isize)

The mouse wheel: scrolls the output rows up (negative: down), unless the grid or a list has the screen.

Source

pub fn scroll_lines(&mut self, rows: isize)

Scrolls the output rows up (negative: down), within what the last draw showed: Shift-↑/↓ and the mouse wheel.

Source

pub fn push_ansi(&mut self, text: &str)

Appends text that may hold ANSI color codes.

Source

pub fn push_note(&mut self, note: &str)

Appends a note line: the ℹ glyph, then the dim text.

Source

pub fn scrollback_text(&self) -> String

The scrollback as plain text, one line per row. For tests and logs.

Source

pub fn open_wizard(&mut self, list: Watchlist, notes: Vec<String>)

Opens the monitor wizard over list, with the notes from the arguments.

Source

pub fn watch_running(&self) -> bool

Whether a watchlist runs now.

Source

pub fn start_watch( &mut self, list: Watchlist, ) -> (Output, Sink, Sender<GridMsg>)

Starts the grid for list. Returns the output the run writes to (it asks its questions in the TUI), the sink for its library warnings, and the sender for its messages.

Source

pub fn settings_reloaded(&mut self)

setup saved new settings. A running watchlist keeps the ones it started with; the grid says to restart it.

Source

pub fn poll_watch(&mut self)

Moves the run’s messages into the grid.

Source

pub fn take_bell(&mut self) -> bool

Takes the bell the grid asks for (a breach started).

Source

pub fn watch_finished(&mut self, res: Result<()>)

The run ended by itself: done, or failed with res’s error.

Source

pub fn stop_watch(&mut self)

The user stopped the run: the grid keeps its last tick, and the report is written from it when the watchlist has a report path.

Source

pub fn close_grid(&mut self)

Closes a finished grid: the scrollback gets the last snapshot, what the run wrote, and a summary.

Source

pub fn show_grid(&mut self)

Shows the grid, or says there is none.

Source

pub fn submit(&mut self, line: &str, config: &Config) -> Plan

Plans a submitted line. Session commands and errors finish here; a CLI command comes back for the event loop to run.

Source

pub fn copied(&mut self, lines: usize, result: Result<()>)

Notes and journals the result of writing the copy sequence.

Source

pub fn start(&mut self, input: &str, inv: &Invocation) -> Output

Starts a pane command. Returns the output its handler must write to.

Source

pub fn finish(&mut self, ending: Ending)

Ends the pane command: moves its output into the scrollback, shows the error if it failed, and logs the event.

Source

pub fn poll_ask(&mut self)

Opens the question a running command put in the ask slot, when no question is open.

Source

pub fn show_outside(&mut self, copy: &Captured, ending: &Ending)

Shows the output of a command that ran outside the TUI (suspend mode), and keeps its data as finish does for a pane command. Call it before TuiState::record_suspended, so the text comes above the note.

Source

pub fn record_suspended( &mut self, input: &str, inv_argv: &[String], duration: Duration, started_at: String, ending: &Ending, )

Records a command that ran outside the TUI (suspend mode), with a note such as Ran outside the TUI: crawl USDC (cancelled, 3.2s).

Source

pub fn record_signal( &mut self, name: &str, route: &'static str, input: &str, argv: &[String], )

Records that signal name (for example TERM) ended the TUI. route is session, or suspend with the suspend-mode command that was running (input, argv).

Source

pub fn pane_width(&self) -> Option<usize>

The inner width of the output pane at the last draw, or None before the first draw. Command output is fitted to it.

Source

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

Draws the screen: output pane, input line, status line.

Auto Trait Implementations§

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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