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>,
    /* 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.

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 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 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 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 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