Text editor -- multi-line editable text area.
The renderer manages an internal text_editor::Content cache keyed by
node ID. The content prop seeds the initial content.
Props
content(string) -- initial text content (used to seed the editor cache).placeholder(string) -- placeholder text shown when editor is empty.width(number) -- editor width in pixels (note: takes pixels, not length).height(length) -- editor height. Default: shrink. SeeToddy.Iced.Length.min_height(number) -- minimum height in pixels.max_height(number) -- maximum height in pixels.font(string | map) -- font specification. SeeToddy.Iced.Font.size(number) -- font size in pixels.line_height(number | map) -- line height.padding(number) -- uniform padding in pixels.wrapping-- text wrapping mode. SeeToddy.Iced.Wrapping.ime_purpose(string) -- IME input purpose hint:"normal","secure","terminal". Default:"normal".highlight_syntax(string) -- language extension for syntax highlighting (e.g. "rs", "py", "ex").highlight_theme(string) -- highlighter theme. One of"solarized_dark","base16_mocha","base16_ocean","base16_eighties","inspired_github". Defaults to"solarized_dark".style--:defaultorStyleMap.t()for custom styling. SeeToddy.Iced.StyleMap.key_bindings(list of maps) -- declarative key binding rules for the editor. Each rule is a map with optionalkey(character),named(named key string),modifiers(list of modifier strings), andbinding(the action to take). Seekey_bindings/2for details.placeholder_color(color) -- placeholder text color. SeeToddy.Iced.Color.selection_color(color) -- text selection highlight color. SeeToddy.Iced.Color.a11y(map) -- accessibility overrides. SeeToddy.Iced.A11y.
Events
The editor emits text action events handled internally by the renderer. Content changes are reported back to Elixir via the protocol.
Summary
Functions
Sets accessibility annotations.
Converts this text editor struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the initial text content.
Sets the font.
Sets the editor height.
Sets the syntax language for highlighting (e.g. "rs", "py", "ex").
Sets the highlighter color theme.
Sets the IME input purpose hint.
Sets declarative key binding rules for the editor.
Sets the line height.
Sets the maximum height in pixels.
Sets the minimum height in pixels.
Creates a new text editor struct with the given id and optional keyword opts.
Sets the uniform padding in pixels.
Sets the placeholder text.
Sets the placeholder text color. Accepts any form Color.cast/1 supports.
Sets the text selection highlight color. Accepts any form Color.cast/1 supports.
Sets the font size in pixels.
Sets the text editor style.
Sets the editor width in pixels.
Applies keyword options to an existing text editor struct.
Sets the text wrapping mode.
Types
@type option() :: {:content, String.t()} | {:placeholder, String.t()} | {:width, number()} | {:height, Toddy.Iced.Length.t()} | {:min_height, number()} | {:max_height, number()} | {:font, Toddy.Iced.Font.t()} | {:size, number()} | {:line_height, number() | map()} | {:padding, number()} | {:wrapping, Toddy.Iced.Wrapping.t()} | {:ime_purpose, String.t()} | {:highlight_syntax, String.t()} | {:highlight_theme, String.t()} | {:style, style()} | {:key_bindings, [map()]} | {:placeholder_color, Toddy.Iced.Color.input()} | {:selection_color, Toddy.Iced.Color.input()} | {:a11y, Toddy.Iced.A11y.t()}
@type style() :: :default | Toddy.Iced.StyleMap.t()
@type t() :: %Toddy.Iced.Widget.TextEditor{ a11y: Toddy.Iced.A11y.t() | nil, content: String.t() | nil, font: Toddy.Iced.Font.t() | nil, height: Toddy.Iced.Length.t() | nil, highlight_syntax: String.t() | nil, highlight_theme: String.t() | nil, id: String.t(), ime_purpose: String.t() | nil, key_bindings: [map()] | nil, line_height: number() | map() | nil, max_height: number() | nil, min_height: number() | nil, padding: number() | nil, placeholder: String.t() | nil, placeholder_color: Toddy.Iced.Color.t() | nil, selection_color: Toddy.Iced.Color.t() | nil, size: number() | nil, style: style() | nil, width: number() | nil, wrapping: Toddy.Iced.Wrapping.t() | nil }
Functions
@spec a11y(text_editor :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
Sets accessibility annotations.
@spec build(text_editor :: t()) :: Toddy.Iced.ui_node()
Converts this text editor struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets the initial text content.
@spec font(text_editor :: t(), font :: Toddy.Iced.Font.t()) :: t()
Sets the font.
@spec height(text_editor :: t(), height :: Toddy.Iced.Length.t()) :: t()
Sets the editor height.
Sets the syntax language for highlighting (e.g. "rs", "py", "ex").
Sets the highlighter color theme.
Sets the IME input purpose hint.
Sets declarative key binding rules for the editor.
Each rule is a map with:
"key"(string) -- a character to match (layout-independent viato_latin)."named"(string) -- a named key like"Enter","Escape","Tab", etc."modifiers"(list of strings) -- required modifiers:"shift","ctrl","alt","logo","command","jump"."binding"-- the action: a string like"copy","cut","paste","enter","backspace","delete","unfocus","select_all","select_word","select_line","default", or a map for complex actions like%{"move" => "left"},%{"select" => "word_right"},%{"insert" => "x"},%{"custom" => "my_tag"},%{"sequence" => [binding1, binding2, ...]}.
Rules are matched in order. The first matching rule wins. If no rule matches,
the key press is ignored (no binding). Use "default" as the binding to
delegate to iced's built-in key handler.
Sets the line height.
Sets the maximum height in pixels.
Sets the minimum height in pixels.
Creates a new text editor struct with the given id and optional keyword opts.
Sets the uniform padding in pixels.
Sets the placeholder text.
@spec placeholder_color(text_editor :: t(), color :: Toddy.Iced.Color.input()) :: t()
Sets the placeholder text color. Accepts any form Color.cast/1 supports.
@spec selection_color(text_editor :: t(), color :: Toddy.Iced.Color.input()) :: t()
Sets the text selection highlight color. Accepts any form Color.cast/1 supports.
Sets the font size in pixels.
Sets the text editor style.
Sets the editor width in pixels.
Applies keyword options to an existing text editor struct.
@spec wrapping(text_editor :: t(), wrapping :: Toddy.Iced.Wrapping.t()) :: t()
Sets the text wrapping mode.