Skip to content

ui/consoleTokens

Interfaces

InputToken

Defined in: ui/consoleTokens.ts:10

Pure helpers for locating the cursor inside console input, extracted from Console so the token/argument math is testable without a DOM. Separators are whitespace and commas (CRE uses the comma form).

Properties

text
text: string;

Defined in: ui/consoleTokens.ts:11

start
start: number;

Defined in: ui/consoleTokens.ts:12

end
end: number;

Defined in: ui/consoleTokens.ts:13


ArgAtCursor

Defined in: ui/consoleTokens.ts:16

Properties

currentArgIndex
currentArgIndex: number;

Defined in: ui/consoleTokens.ts:21

0-based index into the command's parameter list: the command token itself is conceptually at index -1, the first real argument is 0.

partialText
partialText: string;

Defined in: ui/consoleTokens.ts:23

Text of the token under the cursor; '' when on a separator run.

tokenStart
tokenStart: number;

Defined in: ui/consoleTokens.ts:24

tokenEnd
tokenEnd: number;

Defined in: ui/consoleTokens.ts:25

parts
parts: string[];

Defined in: ui/consoleTokens.ts:27

All token texts, command first.


AcidContext

Defined in: ui/consoleTokens.ts:30

Properties

partialAcid
partialAcid: string;

Defined in: ui/consoleTokens.ts:31

isCreCommand
isCreCommand: boolean;

Defined in: ui/consoleTokens.ts:32

acidArgIndex
acidArgIndex: number;

Defined in: ui/consoleTokens.ts:33

isMidInput
isMidInput: boolean;

Defined in: ui/consoleTokens.ts:39

True when the cursor sits on a token followed by more command content - the user is editing an earlier slot rather than typing at the end. Used to keep the dropdown open even on an exact match.


TokenReplacement

Defined in: ui/consoleTokens.ts:105

Properties

value
value: string;

Defined in: ui/consoleTokens.ts:106

cursor
cursor: number;

Defined in: ui/consoleTokens.ts:107


PanContext

Defined in: ui/consoleTokens.ts:179

Properties

partialQuery
partialQuery: string;

Defined in: ui/consoleTokens.ts:181

What the user has typed in PAN's first argument slot so far.

isMidInput
isMidInput: boolean;

Defined in: ui/consoleTokens.ts:183

See AcidContext.isMidInput.

Functions

tokenizeInput()

function tokenizeInput(value): InputToken[];

Defined in: ui/consoleTokens.ts:47

Split console input into tokens, keeping the character range each token occupies so callers can locate the token under the cursor without re-scanning the string.

Parameters

value

string

Returns

InputToken[]


getArgAtCursor()

function getArgAtCursor(value, cursorPos): ArgAtCursor;

Defined in: ui/consoleTokens.ts:68

Find which argument slot the cursor currently sits on, so dropdowns can react to the actual cursor position rather than assuming the cursor is at the end of the input. When the cursor is inside a separator run, partialText is empty and currentArgIndex is the slot that would be filled next.

Parameters

value

string

cursorPos

number

Returns

ArgAtCursor


replaceToken()

function replaceToken(
   value, 
   tokenStart, 
   tokenEnd, 
   replacement): TokenReplacement;

Defined in: ui/consoleTokens.ts:116

Replace the token spanning [tokenStart, tokenEnd) with replacement. At end-of-input a trailing space is appended so the user can keep typing the next argument; mid-input the tail is left untouched. The returned cursor sits right after the inserted text.

Parameters

value

string

tokenStart

number

tokenEnd

number

replacement

string

Returns

TokenReplacement


argStartIndex()

function argStartIndex(value, argIndex): number;

Defined in: ui/consoleTokens.ts:137

Find the character index in value where the argument at position argIndex begins (the command token is at conceptual index -1). Returns value.length when that argument hasn't been typed yet, so callers can truncate-and-append in one step.

Parameters

value

string

argIndex

number

Returns

number


findAcidContext()

function findAcidContext(
   value, 
   cursorPos, 
   cmddict): AcidContext | null;

Defined in: ui/consoleTokens.ts:148

Check whether the cursor sits on an aircraft-ID parameter of the current command (per the cmddict signature). Returns the context for the ACID autocomplete dropdown, or null when the slot is not an acid parameter.

Parameters

value

string

cursorPos

number

cmddict

CommandDict | null

Returns

AcidContext | null


findPanContext()

function findPanContext(value, cursorPos): PanContext | null;

Defined in: ui/consoleTokens.ts:192

Check whether the cursor sits on the first argument of a PAN command - the slot that accepts an aircraft ID, airport/waypoint ident, direction, or latitude. Returns null when the user appears to be typing coordinates (a purely numeric token) so the suggestion dropdown stays out of the way.

Parameters

value

string

cursorPos

number

Returns

PanContext | null