Skip to content

ui/CommandHistory

Classes

CommandHistory

Defined in: ui/CommandHistory.ts:14

CommandHistory - the console's persisted command history with up/down-arrow navigation, extracted from Console so the navigation semantics are testable without a DOM.

Navigation model: a null index means "fresh input line". previous() walks toward older commands and sticks at the oldest (no cycling); next() walks toward newer commands and finally returns to the fresh line (empty string).

Constructors

Constructor
new CommandHistory(storageKey?, maxEntries?): CommandHistory;

Defined in: ui/CommandHistory.ts:18

Parameters
storageKey?

string = 'console-command-history'

maxEntries?

number = 100

Returns

CommandHistory

Accessors

entries
Get Signature
get entries(): readonly string[];

Defined in: ui/CommandHistory.ts:87

Returns

readonly string[]

Methods

load()
load(): void;

Defined in: ui/CommandHistory.ts:24

Load persisted history from localStorage.

Returns

void

add()
add(command): void;

Defined in: ui/CommandHistory.ts:33

Append a command (newest last), cap the size, and persist.

Parameters
command

string

Returns

void

previous()
previous(): string | null;

Defined in: ui/CommandHistory.ts:47

Step to the previous (older) command. Returns the command to show, or null when there is no history to navigate.

Returns

string | null

next()
next(): string | null;

Defined in: ui/CommandHistory.ts:67

Step to the next (newer) command. Returns the command to show, '' when stepping past the newest back to the fresh input line, or null when not currently navigating.

Returns

string | null

resetNavigation()
resetNavigation(): void;

Defined in: ui/CommandHistory.ts:83

Return to the fresh-input state (e.g. after submitting a command).

Returns

void