TextBoxWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
public sealed record TextBoxWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IStatefulWidget<TextBoxWidget, TextBoxState>, IEquatable<TextBoxWidget>Inheritance
Object → Hex1bWidget → TextBoxWidget
Implements
- IEquatable<Hex1bWidget>
- IStatefulWidget<TextBoxWidget, TextBoxState>
- IEquatable<TextBoxWidget>
Constructors
TextBoxWidget(string?)
Parameters:
Text(String):
public TextBoxWidget(string? Text = null)Properties
DefaultWidthHint
Text boxes default to filling their parent's available width — text input feels best when the editable surface is wide rather than hugging the content. Override with .ContentWidth(), .FixedWidth(n), or any explicit WidthHint.
Returns: Nullable<SizeHint>
protected override SizeHint? DefaultWidthHint { get; }MaxWidth
Maximum width of the text box in columns. When set, the text box will not exceed this width. Defaults to the same value as MinWidth if not explicitly set.
Returns: Nullable<Int32>
public int? MaxWidth { get; init; }MinWidth
Minimum width of the text box in columns. When set, the text box will measure at least this many columns wide regardless of content.
Returns: Nullable<Int32>
public int? MinWidth { get; init; }Text
Returns: String
public string? Text { get; init; }Methods
Height(int)
Sets the height of the text box in lines.
Parameters:
lines(Int32):
Returns: TextBoxWidget
public TextBoxWidget Height(int lines)Multiline()
Enables multi-line text editing. Enter inserts newlines, Up/Down arrows navigate between lines, and word wrapping can be enabled.
Returns: TextBoxWidget
public TextBoxWidget Multiline()Multiline(int)
Enables multi-line text editing with a maximum number of lines. Once the limit is reached, no more newlines can be inserted.
Parameters:
maxLines(Int32):
Returns: TextBoxWidget
public TextBoxWidget Multiline(int maxLines)OnPaste(Action<PasteEventArgs>)
Sets a synchronous handler called when paste data is received. Overrides the default behavior of inserting pasted text at the cursor position.
Parameters:
handler(Action<PasteEventArgs>):
Returns: TextBoxWidget
public TextBoxWidget OnPaste(Action<PasteEventArgs> handler)OnPaste(Func<PasteEventArgs, Task>)
Sets an asynchronous handler called when paste data is received. Overrides the default behavior of inserting pasted text at the cursor position.
Parameters:
handler(Func<PasteEventArgs, Task>):
Returns: TextBoxWidget
public TextBoxWidget OnPaste(Func<PasteEventArgs, Task> handler)OnSubmit(Action<TextSubmittedEventArgs>)
Sets a synchronous handler called when Enter is pressed in the text box.
Parameters:
handler(Action<TextSubmittedEventArgs>):
Returns: TextBoxWidget
public TextBoxWidget OnSubmit(Action<TextSubmittedEventArgs> handler)OnSubmit(Func<TextSubmittedEventArgs, Task>)
Sets an asynchronous handler called when Enter is pressed in the text box.
Parameters:
handler(Func<TextSubmittedEventArgs, Task>):
Returns: TextBoxWidget
public TextBoxWidget OnSubmit(Func<TextSubmittedEventArgs, Task> handler)OnTextChanged(Action<TextChangedEventArgs>)
Sets a synchronous handler called when the text content changes.
Parameters:
handler(Action<TextChangedEventArgs>):
Returns: TextBoxWidget
public TextBoxWidget OnTextChanged(Action<TextChangedEventArgs> handler)OnTextChanged(Func<TextChangedEventArgs, Task>)
Sets an asynchronous handler called when the text content changes.
Parameters:
handler(Func<TextChangedEventArgs, Task>):
Returns: TextBoxWidget
public TextBoxWidget OnTextChanged(Func<TextChangedEventArgs, Task> handler)Predict(Func<string, CancellationToken, Task<string?>>, TimeSpan)
Configures an inline predictive-completion provider with a debounce. The predictor is only invoked after the user pauses typing for debounce; intermediate keystrokes restart the timer and cancel any in-flight request. Use this when the predictor is expensive (e.g. an LLM round-trip).
Parameters:
predictor(Func<String, CancellationToken, String>>):debounce(TimeSpan):
Returns: TextBoxWidget
public TextBoxWidget Predict(Func<string, CancellationToken, Task<string?>> predictor, TimeSpan debounce)Predict(Func<string, CancellationToken, Task<string?>>)
Configures an inline predictive-completion provider. After the user types a character (and only when the cursor is at the end of the buffer), predictor is invoked with the current text. If it returns a non-null, non-empty string, that text is shown inline after the cursor in the prediction colors. The user accepts the suggestion with (Right Arrow by default) or dismisses it with (Escape by default). The cancellation token is signalled when the user types another character before the predictor returns, so an expensive predictor can short-circuit.
Parameters:
predictor(Func<String, CancellationToken, String>>):
Returns: TextBoxWidget
public TextBoxWidget Predict(Func<string, CancellationToken, Task<string?>> predictor)State(TextBoxState)
Returns a copy of the textbox bound to the supplied state instance. The textbox becomes a pure view of state: every reconcile assigns this exact instance to the underlying node, and the framework no longer drift-detects against the constructor argument.
Parameters:
state(TextBoxState):
Returns: TextBoxWidget
public TextBoxWidget State(TextBoxState state)WordWrap()
Enables word wrapping for multi-line text boxes. Long lines are visually broken at word boundaries to fit the available width.
Returns: TextBoxWidget
public TextBoxWidget WordWrap()Fields
AcceptPrediction
Rebindable action: Accept the inline prediction (default: Right Arrow at end of buffer).
Returns: ActionId
public static readonly ActionId AcceptPredictionDeleteBackward
Rebindable action: Delete character backward.
Returns: ActionId
public static readonly ActionId DeleteBackwardDeleteForward
Rebindable action: Delete character forward.
Returns: ActionId
public static readonly ActionId DeleteForwardDeleteWordBackward
Rebindable action: Delete previous word.
Returns: ActionId
public static readonly ActionId DeleteWordBackwardDeleteWordForward
Rebindable action: Delete next word.
Returns: ActionId
public static readonly ActionId DeleteWordForwardDismissPrediction
Rebindable action: Dismiss the inline prediction (default: Escape while a prediction is showing).
Returns: ActionId
public static readonly ActionId DismissPredictionInsertNewline
Rebindable action: Insert a newline (multiline only).
Returns: ActionId
public static readonly ActionId InsertNewlineInsertText
Rebindable action: Insert typed text.
Returns: ActionId
public static readonly ActionId InsertTextMoveDown
Rebindable action: Move cursor down one line (multiline only).
Returns: ActionId
public static readonly ActionId MoveDownMoveEnd
Rebindable action: Move cursor to end.
Returns: ActionId
public static readonly ActionId MoveEndMoveHome
Rebindable action: Move cursor to start.
Returns: ActionId
public static readonly ActionId MoveHomeMoveLeft
Rebindable action: Move cursor left.
Returns: ActionId
public static readonly ActionId MoveLeftMoveRight
Rebindable action: Move cursor right.
Returns: ActionId
public static readonly ActionId MoveRightMoveUp
Rebindable action: Move cursor up one line (multiline only).
Returns: ActionId
public static readonly ActionId MoveUpMoveWordLeft
Rebindable action: Move cursor to previous word.
Returns: ActionId
public static readonly ActionId MoveWordLeftMoveWordRight
Rebindable action: Move cursor to next word.
Returns: ActionId
public static readonly ActionId MoveWordRightSelectAll
Rebindable action: Select all text.
Returns: ActionId
public static readonly ActionId SelectAllSelectDown
Rebindable action: Extend selection down one line (multiline only).
Returns: ActionId
public static readonly ActionId SelectDownSelectLeft
Rebindable action: Extend selection left.
Returns: ActionId
public static readonly ActionId SelectLeftSelectRight
Rebindable action: Extend selection right.
Returns: ActionId
public static readonly ActionId SelectRightSelectToEnd
Rebindable action: Select to end.
Returns: ActionId
public static readonly ActionId SelectToEndSelectToStart
Rebindable action: Select to start.
Returns: ActionId
public static readonly ActionId SelectToStartSelectUp
Rebindable action: Extend selection up one line (multiline only).
Returns: ActionId
public static readonly ActionId SelectUpSelectWordLeft
Rebindable action: Extend selection to previous word.
Returns: ActionId
public static readonly ActionId SelectWordLeftSelectWordRight
Rebindable action: Extend selection to next word.
Returns: ActionId
public static readonly ActionId SelectWordRightSubmit
Rebindable action: Submit text.
Returns: ActionId
public static readonly ActionId Submit