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: 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.
grid: Option<GridState>The watchlist grid, while a watchlist runs or until its finished grid is closed (#47).
grid_shown: boolThe 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
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 set_vocab(&mut self, vocab: Vocab)
pub fn set_vocab(&mut self, vocab: Vocab)
Replaces the completion words, after the config was read again.
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 wheel(&mut self, rows: isize)
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.
Sourcepub fn scroll_lines(&mut self, rows: isize)
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.
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 open_wizard(&mut self, list: Watchlist, notes: Vec<String>)
pub fn open_wizard(&mut self, list: Watchlist, notes: Vec<String>)
Opens the monitor wizard over list, with the notes from the
arguments.
Sourcepub fn watch_running(&self) -> bool
pub fn watch_running(&self) -> bool
Whether a watchlist runs now.
Sourcepub fn start_watch(
&mut self,
list: Watchlist,
) -> (Output, Sink, Sender<GridMsg>)
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.
Sourcepub fn settings_reloaded(&mut self)
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.
Sourcepub fn poll_watch(&mut self)
pub fn poll_watch(&mut self)
Moves the run’s messages into the grid.
Sourcepub fn watch_finished(&mut self, res: Result<()>)
pub fn watch_finished(&mut self, res: Result<()>)
The run ended by itself: done, or failed with res’s error.
Sourcepub fn stop_watch(&mut self)
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.
Sourcepub fn close_grid(&mut self)
pub fn close_grid(&mut self)
Closes a finished grid: the scrollback gets the last snapshot, what the run wrote, and a summary.
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 poll_ask(&mut self)
pub fn poll_ask(&mut self)
Opens the question a running command put in the ask slot, when no question is open.
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 !UnwindSafe for TuiState
impl Forget for TuiState
impl Send for TuiState
impl Unpin for TuiState
impl UnsafeUnpin 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