class

Egui::TextArea

Inherits Egui::Widget < Reference < Object

Constants

ANCHOR_SALT = 24301_u64
BAR_SALT = 2978_u64
BAR_W = 8.0
BIG_TEXT_BYTES = 1 << 19

Above this size (bytes) the textarea goes virtual — see the file header. 512 KiB still full-wraps in ~100 ms once; past it, the open-time wrap and the per-edit re-wrap stop being pocket change.

SCROLL_SALT = 23616_u64
VEL_SALT = 2017_u64
VIRTUAL_CACHE_MAX = 16

Constructors

new(text : String, hint : String | Nil = nil, rows : Int32 = 8, frame : Bool = true, focus_id : String | Nil = nil)
Source

Class methods

line_char_starts(text : String) : Array(Int32)

Character offset of every line start (size = line count + 1: the last entry is the phantom line after a trailing newline). One byte scan: UTF-8 lead bytes count a character, 0x0A closes a line. O(bytesize), once per buffer identity.

Source
line_of(starts : Array(Int32), char : Int32) : Int32

Line index containing a character offset (binary search; rows are lines in virtual mode, so unlike the wrapped galley there is no boundary ambiguity — a line start belongs to its own line).

Source
virtual_state(id : Id, text : String) : VirtualState
Source
virtual_window(st : VirtualState, offset : Float64, view_h : Float64, line_h : Float64, fonts : Fonts, font_size : Float64)

Build (or reuse) the window of laid-out rows around the viewport. The window spans one screen of margin rows on each side, so caret moves, page steps and smooth scrolling resolve against built rows; it rebuilds only when the viewport leaves it. Rows carry GLOBAL y (line index * line_h) — painting, culling and the scroll math all keep their absolute-offset meaning, and row_starts stays a slice of the global line starts so caret and selection indexes need no translation.

Source

Instance methods

ui(ui : Ui) : Response
Source

Nested types