TextInput

Text input field.

@safe
class TextInput : InputNode!Node, FluidScrollable {}

Constructors

this
this(string placeholder, void delegate() @(trusted) submitted)

Create a text input.

Members

Aliases

selectionEnd
alias selectionEnd = caretIndex

Point where selection ends. Corresponds to caret position.

Classes

ContentLabel
class ContentLabel
Undocumented in source.

Functions

backspace
void backspace()

Remove a character before the caret. Same as chop.

backspaceWord
void backspaceWord()

Remove a word before the caret.

breakLine
bool breakLine()

Start a new line

buffer
inout(char)[] buffer()

Get the current buffer.

canScroll
bool canScroll(Vector2 value)
caretIndex
ptrdiff_t caretIndex()
ptrdiff_t caretIndex(ptrdiff_t index)

Index of the character, byte-wise.

caretLine
Rope caretLine()

Get the current line

caretLine
const(char)[] caretLine(const(char)[] newValue)
Rope caretLine(Rope newValue)

Change the current line. Moves the cursor to the end of the newly created line.

caretPosition
Vector2 caretPosition()

Visual position of the caret, relative to the top-left corner of the input.

caretPositionImpl
Vector2 caretPositionImpl(float textWidth, bool preferNextLine)
Undocumented in source. Be warned that the author may not have intended to support it.
caretTo
void caretTo(Vector2 position)

Move the caret to the given screen position (viewport space).

caretToEnd
void caretToEnd()

Move the caret to the end of the input

caretToLineEnd
void caretToLineEnd()

Move the caret to the end of the line.

caretToLineStart
void caretToLineStart()

Move the caret to the beginning of the line. This function perceives the line visually, so if the text wraps, it will go to the beginning of the visible line, instead of the hard line break.

caretToMouse
void caretToMouse()

Move the caret to mouse position.

caretToStart
void caretToStart()

Move the caret to the beginning of the input

chop
void chop(bool forward)

Erase any character preceding the caret, or the next one.

chopWord
void chopWord(bool forward)

Erase last word before the caret, or the first word after.

clear
void clear()

Clear the value of this input field, making it empty.

clearHistory
void clearHistory()

Clear the undo/redo action history.

clearSelection
void clearSelection()
column
ptrdiff_t column(ptrdiff_t index)
ptrdiff_t column()

Get the column the given index (or the cursor, if omitted) is on.

copy
void copy()

Copy selected text to clipboard.

cut
void cut()

Cut selected text to clipboard, clearing the selection.

deleteChar
void deleteChar()

Delete one character in front of the cursor.

deleteWord
void deleteWord()

Delete a word in front of the caret.

drawCaret
void drawCaret(Rectangle inner)
Undocumented in source. Be warned that the author may not have intended to support it.
drawContents
void drawContents(Rectangle inner, Rectangle scrolledInner)
Undocumented in source. Be warned that the author may not have intended to support it.
drawImpl
void drawImpl(Rectangle outer, Rectangle inner)
Undocumented in source. Be warned that the author may not have intended to support it.
drawSelection
void drawSelection(Rectangle inner)

Draw selection, if applicable.

eachLineByIndex
auto eachLineByIndex(ptrdiff_t start, ptrdiff_t end)

Iterate on each line in an interval.

eachSelectedLine
auto eachSelectedLine()

Return each line containing the selection.

focusBoxImpl
Rectangle focusBoxImpl(Rectangle inner)
Undocumented in source. Be warned that the author may not have intended to support it.
forcePushSnapshot
void forcePushSnapshot(HistoryEntry entry)

Push the given state snapshot (value, caret & selection) into the undo stack. Refuses to push if the current state can be merged with it, unless forcePushSnapshot is used.

freeBuffer
inout(char)[] freeBuffer()

Get the empty part of the buffer.

isEmpty
bool isEmpty()

If true, this input is currently empty.

isSelecting
bool isSelecting()

If true, there's an active selection.

keyboardImpl
bool keyboardImpl()
Undocumented in source. Be warned that the author may not have intended to support it.
lineByIndex
Rope lineByIndex(size_t index)

Get line in the input by a byte index.

lineByIndex
const(char)[] lineByIndex(size_t index, const(char)[] value)
Rope lineByIndex(size_t index, Rope newValue)

Update a line with given byte index.

lineEndByIndex
size_t lineEndByIndex(size_t index)

Get the index of the start or end of the line — from index of any character on the same line.

lineStartByIndex
size_t lineStartByIndex(size_t index)

Get the index of the start or end of the line — from index of any character on the same line.

mouseImpl
void mouseImpl()
Undocumented in source. Be warned that the author may not have intended to support it.
moveOrClearSelection
void moveOrClearSelection()

Clear selection if selection movement is disabled.

multiline
bool multiline()
bool multiline(bool value)

If true, this input accepts multiple inputs in the input; pressing "enter" will start a new line.

nearestCharacter
size_t nearestCharacter(Vector2 needle)

Find the closest index to the given position.

newBuffer
void newBuffer(size_t minimumSize)

Request a new or a larger buffer.

openContextMenu
void openContextMenu()

Open the input's context menu.

paste
void paste()

Paste text from clipboard.

pickLabelStyle
Style pickLabelStyle(Style style)

Get the current style for the label.

pickLabelStyle
Style pickLabelStyle()
Undocumented in source. Be warned that the author may not have intended to support it.
previousOrNextChar
void previousOrNextChar(FluidInputAction action)

Move caret to the previous or next character.

previousOrNextLine
void previousOrNextLine(FluidInputAction action)

Move the caret to the previous or next line.

previousOrNextWord
void previousOrNextWord(FluidInputAction action)

Move caret to the previous or next word.

push
void push(dchar character)
void push(const(char)[] ch)
void push(Rope text)

Push a character or string to the input.

pushSnapshot
void pushSnapshot(HistoryEntry entry)

Push the given state snapshot (value, caret & selection) into the undo stack. Refuses to push if the current state can be merged with it, unless forcePushSnapshot is used.

redo
void redo()

Perform the last undone action again.

resizeImpl
void resizeImpl(Vector2 area)
Undocumented in source. Be warned that the author may not have intended to support it.
scroll
float scroll()

Current horizontal visual offset of the label.

scroll
float scroll(float value)

Set scroll value.

scrollImpl
void scrollImpl(Vector2 value)
Undocumented in source. Be warned that the author may not have intended to support it.
scrollIntoView
ScrollIntoViewAction scrollIntoView(bool alignToTop)

Scroll ancestors so the text input becomes visible.

select
void select(FluidInputAction action)

Begin or continue selection using given movement action.

selectAll
void selectAll()

Select all text

selectLine
void selectLine()

Select the whole line the cursor is.

selectSlice
void selectSlice(size_t start, size_t end)

Select a part of text. This is preferred to setting selectionStart & selectionEnd directly, since the two properties are synchronized together and a change might be ignored.

selectWord
void selectWord()

Select the word surrounding the cursor. If selection is active, expands selection to cover words.

selectedValue
Rope selectedValue()
Rope selectedValue(Rope newValue)
Rope selectedValue(const(char)[] newValue)

Get or set currently selected text.

selectionHighIndex
ptrdiff_t selectionHighIndex()

High index of the selection, right boundary, second index.

selectionLowIndex
ptrdiff_t selectionLowIndex()

Low index of the selection, left boundary, first index.

selectionStart
ptrdiff_t selectionStart()
ptrdiff_t selectionStart(ptrdiff_t value)

Point where selection begins. Caret is the other end of the selection.

shallowScrollTo
Rectangle shallowScrollTo(const(Node) child, Rectangle parentBox, Rectangle childBox)
Undocumented in source. Be warned that the author may not have intended to support it.
showCaret
bool showCaret()
Undocumented in source. Be warned that the author may not have intended to support it.
snapshot
HistoryEntry snapshot(HistoryEntry entry)

Restore state from snapshot

snapshot
HistoryEntry snapshot()

Produce a snapshot for the current state. Returns the snapshot.

submit
void submit()

Submit the input.

textRuler
TextRuler textRuler()

Get an appropriate text ruler for this input.

touch
void touch()

Mark the text input as modified.

touchText
void touchText()

Mark the text input as modified and fire the "changed" event.

undo
void undo()

Restore the last value in history.

updateCaretPosition
void updateCaretPosition(bool preferNextLine)

Update the caret position to match the caret index.

usedBuffer
inout(char)[] usedBuffer()

Get the filled part of the buffer.

usedBufferSize
inout(size_t) usedBufferSize()

Get the used size of the buffer.

value
inout(Rope) value()
Rope value(Rope newValue)
Rope value(const(char)[] value)

Value written in the input.

valueAfterCaret
Rope valueAfterCaret()
Rope valueAfterCaret(Rope newValue)
Rope valueAfterCaret(const(char)[] value)

Get or set text following the caret.

valueBeforeCaret
Rope valueBeforeCaret()
Rope valueBeforeCaret(Rope newValue)
Rope valueBeforeCaret(const(char)[] newValue)

Get or set text preceding the caret.

Mixins

__anonymous
mixin enableInputActions
Undocumented in source.

Structs

HistoryEntry
struct HistoryEntry
Undocumented in source.

Variables

_inner
Rectangle _inner;

Last padding box assigned to this node, with scroll applied.

_isContinuous
bool _isContinuous;

If true, the caret index has not changed since last pushSnapshot.

_redoStack
DList!HistoryEntry _redoStack;

Current action history, expressed as two stacks, indicating undoable and redoable actions, controllable via snapshot, pushSnapshot, undo and redo.

_undoStack
DList!HistoryEntry _undoStack;

Current action history, expressed as two stacks, indicating undoable and redoable actions, controllable via snapshot, pushSnapshot, undo and redo.

contentLabel
ContentLabel contentLabel;

Underlying label controlling the content.

contextMenu
PopupFrame contextMenu;

Context menu for this input.

horizontalAnchor
float horizontalAnchor;

Reference horizontal (X) position for vertical movement. Relative to the input's top-left corner.

lastTouch
SysTime lastTouch;

Time of the last interaction with the input.

maxHistorySize
int maxHistorySize;

Maximum entries in the history.

placeholder
Rope placeholder;

A placeholder text for the field, displayed when the field is empty. Style using emptyStyle.

selectionMovement
bool selectionMovement;

If true, current movement action is performed while selecting.

size
auto size;

Size of the field.

Inherited Members

From FluidScrollable

canScroll
bool canScroll(Vector2 value)

Returns true if the node can react to given scroll.

scrollImpl
void scrollImpl(Vector2 value)

React to scroll wheel input.

shallowScrollTo
Rectangle shallowScrollTo(Node child, Rectangle parentBox, Rectangle childBox)

Scroll to given child node.

scroll
float scroll()

Get current scroll value.

scroll
float scroll(float value)

Set scroll value.

Meta