trait TypedValue

Properties

protected string $typedValue

The value that has been typed.

protected int $cursorPosition

The position of the virtual cursor.

Methods

void
trackTypedValue(string $default = '', bool $submit = true, callable|null $ignore = null, bool $allowNewLine = false)

Track the value as the user types.

string
value()

Get the value of the prompt.

string
addCursor(string $value, int $cursorPosition, int|null $maxWidth = null)

Add a virtual cursor to the value and truncate if necessary.

void
deleteWordBackward()

Delete from the start of the current word (before cursor) through the cursor.

int
findWordStartBeforeCursor()

Character offset of the word boundary immediately before the cursor (Intl + punctuation).

int
findLastWordStartByLettersAndNumbers(string $before)

Start (character offset) of the last run of letters/numbers in string (punctuation breaks words).

Details

at line 25
protected void trackTypedValue(string $default = '', bool $submit = true, callable|null $ignore = null, bool $allowNewLine = false)

Track the value as the user types.

Parameters

string $default
bool $submit
callable|null $ignore
bool $allowNewLine

Return Value

void

at line 89
string value()

Get the value of the prompt.

Return Value

string

at line 97
protected string addCursor(string $value, int $cursorPosition, int|null $maxWidth = null)

Add a virtual cursor to the value and truncate if necessary.

Parameters

string $value
int $cursorPosition
int|null $maxWidth

Return Value

string

at line 138
protected void deleteWordBackward()

Delete from the start of the current word (before cursor) through the cursor.

Return Value

void

at line 153
protected int findWordStartBeforeCursor()

Character offset of the word boundary immediately before the cursor (Intl + punctuation).

Punctuation (e.g. . - _) is treated as a word boundary so "word.word" deletes in two steps.

Return Value

int

at line 184
protected int findLastWordStartByLettersAndNumbers(string $before)

Start (character offset) of the last run of letters/numbers in string (punctuation breaks words).

Parameters

string $before

Return Value

int