pub struct TerminalSnapshot {Show 20 fields
pub size: TerminalSize,
pub active_screen: ActiveScreen,
pub title: Option<String>,
pub cwd_uri: Option<String>,
pub cursor: TerminalSnapshotCursor,
pub modes: TerminalModes,
pub scrollback_len: usize,
pub scrollback_limit: usize,
pub scrollback_total_pushed: u64,
pub damage_full: bool,
pub dirty_lines: Vec<usize>,
pub lines: Vec<TerminalSnapshotLine>,
pub latest_output_lines: Vec<String>,
pub shell: TerminalShellSnapshot,
pub commands: Vec<CommandSummary>,
pub diagnostics: Vec<TerminalDiagnostic>,
pub warnings: Vec<TerminalWarning>,
pub event_log: Vec<TerminalEventRecord>,
pub hyperlinks: usize,
pub truncated: bool,
}Expand description
Owned, bounded observation of a TerminalState.
The selected line and command collections retain their newest entries, whereas diagnostics and warnings retain their oldest entries. Title, CWD, line text/cells, latest output, and shell command/CWD text are passed through the configured redaction policy. Diagnostics and warnings are copied verbatim, so their messages, paths, and other fields can still contain sensitive data. Dirty-line indices are also copied without a size limit.
Public fields and deserialization can construct internally inconsistent observations; this type deliberately performs no validation on deserialize.
§Examples
use ailloli_ui_terminal_core::{TerminalSnapshot, TerminalSnapshotConfig, TerminalState};
let mut state = TerminalState::new();
state.write_str("hello");
let snapshot = TerminalSnapshot::from_state(&state, TerminalSnapshotConfig::default());
assert_eq!(snapshot.active_screen, state.active_screen);
assert!(snapshot.lines.iter().any(|line| line.text.contains("hello")));Fields§
§size: TerminalSizeActive screen size in rows and columns.
active_screen: ActiveScreenScreen whose lines were captured.
title: Option<String>Redacted terminal title, or None when the state has none.
cwd_uri: Option<String>Redacted current-working-directory URI, or None when unknown.
cursor: TerminalSnapshotCursorCursor observation, including a normal-screen global line when available.
modes: TerminalModesCopy of current terminal modes.
scrollback_len: usizeTotal number of lines currently retained in normal-screen scrollback.
scrollback_limit: usizeConfigured scrollback retention limit; 0 retains no history.
scrollback_total_pushed: u64Saturating count of all lines ever pushed to scrollback.
damage_full: boolWhether the state’s damage tracker requests a full repaint.
dirty_lines: Vec<usize>Unbounded copy of the state’s dirty row indices.
lines: Vec<TerminalSnapshotLine>Newest captured visual lines in original visual order.
latest_output_lines: Vec<String>Newest captured full-line texts in original visual order.
This limit is independent of Self::lines and its cell limit.
shell: TerminalShellSnapshotRedacted shell/process/command snapshot.
commands: Vec<CommandSummary>Newest bounded command summaries, including the current command last.
diagnostics: Vec<TerminalDiagnostic>Oldest bounded diagnostics, copied without redaction.
warnings: Vec<TerminalWarning>Oldest bounded warnings, copied without redaction.
event_log: Vec<TerminalEventRecord>Newest bounded event records, or empty when no log was supplied.
hyperlinks: usizeNumber of registered hyperlinks; targets are not included.
truncated: boolWhether selected top-level state collections were omitted.
This is set for omitted visual lines, diagnostics, warnings, or command history according to the implementation’s history-versus-summary count. It does not report cell truncation, latest-output omission, event-log omission, byte/text truncation, redaction, or every possible command omission. Inspect nested flags and configured limits as well.
Implementations§
Source§impl TerminalSnapshot
impl TerminalSnapshot
Sourcepub fn from_state(state: &TerminalState, config: TerminalSnapshotConfig) -> Self
pub fn from_state(state: &TerminalState, config: TerminalSnapshotConfig) -> Self
Captures state without attaching an event log.
This does not mutate state. Self::event_log is empty even if events
were recorded elsewhere, because no log is accepted by this method.
§Examples
use ailloli_ui_terminal_core::{TerminalSnapshot, TerminalSnapshotConfig, TerminalState};
let snapshot = TerminalSnapshot::from_state(
&TerminalState::new(),
TerminalSnapshotConfig { max_lines: 1, ..Default::default() },
);
assert!(snapshot.lines.len() <= 1);
assert!(snapshot.event_log.is_empty());Sourcepub fn from_state_with_event_log(
state: &TerminalState,
config: TerminalSnapshotConfig,
event_log: Option<&TerminalEventLog>,
) -> Self
pub fn from_state_with_event_log( state: &TerminalState, config: TerminalSnapshotConfig, event_log: Option<&TerminalEventLog>, ) -> Self
Captures state and the newest configured records from an optional log.
None and an empty log both produce an empty event collection. Event
records are copied as already sanitized at record time; changing the
snapshot’s redaction policy does not re-sanitize existing records.
Line visual_index values refer to the full pre-limit visual sequence,
not the returned vector. On the normal screen that sequence is scrollback
followed by visible screen rows; on the alternate screen it contains only
alternate-screen rows.
§Examples
use ailloli_ui_terminal_core::{
TerminalEventLog, TerminalSnapshot, TerminalSnapshotConfig, TerminalState,
};
let config = TerminalSnapshotConfig::unredacted_for_tests();
let mut log = TerminalEventLog::new(2);
assert_eq!(log.record_output(b"ok", &config), 1);
let snapshot = TerminalSnapshot::from_state_with_event_log(
&TerminalState::new(), config, Some(&log),
);
assert_eq!(snapshot.event_log.len(), 1);Trait Implementations§
Source§impl Clone for TerminalSnapshot
impl Clone for TerminalSnapshot
Source§fn clone(&self) -> TerminalSnapshot
fn clone(&self) -> TerminalSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more