Module: reefvision.widgets.textarea
Source: ./reefvision/widgets/textarea.reef
Overview
reefvision.widgets.textarea — multi-line editor (Wave 5)
object TextArea extends view.View. Lines stored separately; caret is
(row, col) where col is a UTF-8 code-point index (reef-lang#74b).
Horizontal scroll col_offset is in display columns; convert at
paint and mouse hit-test only. Mid-sequence caret positions are
impossible by construction.
MVP: ASCII printable insert; Enter splits; Backspace joins. Typing returns event_handled() (consumed, command 0). Insertion is Group.add.
Usage: let ed = new textarea.TextArea(cell.rect(0, 0, 48, 8), 128, 8, 100) ed.paste("hello\nworld") win.add(ed)
Objects
TextArea
Extends: view.View
Fields:
| Name | Type |
|---|---|
lines |
[string] |
max_lines |
int |
line_count |
int |
caret_row |
int |
caret_col |
int |
offset |
int |
col_offset |
int |
visible_rows |
int |
max_line_len |
int |
is_sb_dragging |
bool |
hsb_dragging |
bool |
sel_dragging |
bool |
syntax_lang |
int |
syntax_scheme |
syntax.SyntaxScheme |
show_gutter |
bool |
overwrite |
bool |
has_sel |
bool |
sel_row |
int |
sel_col |
int |
mark_mode |
bool |
proc init(bounds: cell.Rect, max_lines: int, visible_rows: int, max_line_len: int)
Methods:
exclusive proc set_syntax(lang: int)
exclusive proc set_syntax_scheme(sc: syntax.SyntaxScheme)
exclusive proc set_visible_rows(visible_rows: int)
exclusive proc set_line_numbers(on: bool)
exclusive proc toggle_overwrite()
exclusive fn gutter_w(): int
override shared fn wants_focus(): bool
override shared fn captures_mouse(): bool
override shared fn hit_bounds(): cell.Rect
exclusive fn vis_cols(): int
exclusive proc clamp_offset()
exclusive fn vis_rows(): int
exclusive fn content_width(): int
exclusive fn has_hscroll(): bool
shared fn line(row: int): option.Option[string]
0.9.2 C16: None for an out-of-range row.
An empty line is the single most ordinary thing in a text buffer, so "" could not distinguish "row past the end" from "this line is blank".
shared fn line_or(row: int, default: string): string
*_or twin: the line, or the caller default when the row is out of range. An empty line is a PRESENT value and is returned as-is.
shared fn has_scrollbar(): bool
exclusive proc clamp_caret()
exclusive proc ensure_visible()
exclusive proc ensure_hscroll()
exclusive proc clear_sel()
exclusive proc begin_sel()
exclusive proc start_mark()
exclusive proc end_mark()
exclusive proc toggle_mark()
exclusive fn sel_empty(): bool
exclusive fn pos_before(r0: int, c0: int, r1: int, c1: int): bool
exclusive fn in_sel(row: int, col: int): bool
exclusive fn selected_text(): option.Option[string]
The selected text, or None when there is NO SELECTION.
C16 / ROADMAP 8.2b: "" used to mean both "nothing is selected" and "the selection is empty", and a caller could not tell which. The inner returns below stay "" on purpose -- a zero-width selection genuinely IS the empty string, and that is a value, not an absence.
exclusive proc select_all()
exclusive proc delete_selection()
exclusive fn find_next(needle: string): bool
exclusive proc scroll_by(delta: int)
exclusive proc set_caret(row: int, col: int)
exclusive proc paste(text: string)
shared fn text(): string
exclusive proc set_text(text: string)
override exclusive proc draw(buf: cell.CellBuffer, abs: cell.Rect, clip: cell.Rect, focused: bool, th: theme.Theme)
exclusive proc shift_lines_down(from: int)
exclusive proc shift_lines_up(from: int)
exclusive proc split_line_at_caret()
exclusive proc join_with_prev()
override exclusive fn handle_event(e: event.Event): view.EventResult
exclusive proc set_offset_from_y(abs_bounds: cell.Rect, y: int)
exclusive fn h_track_len(abs_w: int, gw: int): int
exclusive proc set_col_from_x(abs_bounds: cell.Rect, x: int)
exclusive fn handle_mouse(e: event.Event): bool
Functions
fn max_lines_cap(): int
fn max_line_cap(): int
fn empty_line(): string
fn line_cp_count(line: string): int
fn cp_to_byte(line: string, cp_idx: int): int
Byte offset of the start of code-point index cp_idx (or length if past end).
fn byte_to_cp(line: string, byte_idx: int): int
Code-point index of the glyph that contains byte_idx (or count if at/after end).
fn cp_to_display(line: string, cp_idx: int): int
fn display_to_cp(line: string, dcol: int): int
Map a display column to the code-point index whose glyph starts at/before it. A click inside a wide glyph parks at that glyph (never mid-sequence).
fn clamp_col(line: string, col: int): int
fn replace_char_line(line: string, col: int, cp: int): string
fn insert_char_line(line: string, col: int, cp: int, max_len: int): string
fn delete_before_line(line: string, col: int): string
fn delete_at_line(line: string, col: int): string
Generated by reefc doc