CommandHistoryBuffer class

An ordered, bounded set of history entries with the shell's add rules.

Entries are newest-last and capped at maxEntries (oldest dropped first). add skips blank lines and consecutive duplicates. The buffer holds no persistence concern — embedders load entries into it and persist entries after a mutation reports a change.

Constructors

CommandHistoryBuffer({List<String>? entries, int maxEntries = 1000})
Creates a buffer seeded with entries (capped to maxEntries).

Properties

entries List<String>
The entries, oldest first. The returned list is an unmodifiable copy.
no setter
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether the buffer holds no entries.
no setter
length int
The number of entries currently held.
no setter
maxEntries int
Upper bound on retained entries; oldest are dropped first.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(String entry) bool
Records entry unless it is blank or a consecutive duplicate of the most recent entry, capping to maxEntries. Returns whether the buffer changed, so callers can skip persisting on a no-op.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prepend(List<String> items) → void
Inserts items before the current entries (a migration splice), collapsing a duplicate that straddles the boundary (old tail == new head), then caps. A no-op when items is empty.
replaceAll(Iterable<String> entries) → void
Replaces all entries with entries (used when loading from storage), capping to maxEntries.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

sanitizeKey(String key) String
Maps an arbitrary key (e.g. <user>@<node>) to a safe, stable identifier component — usable as a filename (CLI) or a storage-key suffix (web).