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: StringThe input line.
history: Vec<String>Submitted lines, oldest first.
ctx: SessionContextThe 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
impl TuiState
Sourcepub fn new(ctx: SessionContext, journal: Journal, vocab: Vocab) -> Self
pub fn new(ctx: SessionContext, journal: Journal, vocab: Vocab) -> Self
Creates the state with a context and a history.
Sourcepub fn handle_key(&mut self, key: KeyEvent) -> Action
pub fn handle_key(&mut self, key: KeyEvent) -> Action
Applies one key event.
Sourcepub fn paste(&mut self, text: &str)
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.
Sourcepub fn scrollback_text(&self) -> String
pub fn scrollback_text(&self) -> String
The scrollback as plain text, one line per row. For tests and logs.
Sourcepub fn submit(&mut self, line: &str, config: &Config) -> Plan
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.
Sourcepub fn copied(&mut self, lines: usize, result: Result<()>)
pub fn copied(&mut self, lines: usize, result: Result<()>)
Notes and journals the result of writing the copy sequence.
Sourcepub fn start(&mut self, input: &str, inv: &Invocation) -> Output
pub fn start(&mut self, input: &str, inv: &Invocation) -> Output
Starts a pane command. Returns the output its handler must write to.
Sourcepub fn finish(&mut self, ending: Ending)
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.
Sourcepub fn show_outside(&mut self, copy: &Captured, ending: &Ending)
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.
Sourcepub fn record_suspended(
&mut self,
input: &str,
inv_argv: &[String],
duration: Duration,
started_at: String,
ending: &Ending,
)
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).
Sourcepub fn record_signal(
&mut self,
name: &str,
route: &'static str,
input: &str,
argv: &[String],
)
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).
Sourcepub fn pane_width(&self) -> Option<usize>
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.
Auto Trait Implementations§
impl !Freeze for TuiState
impl !RefUnwindSafe for TuiState
impl !Sync for TuiState
impl Send for TuiState
impl Unpin for TuiState
impl UnsafeUnpin for TuiState
impl UnwindSafe for TuiState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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