Module: reefvision.widgets.table

Source: ./reefvision/widgets/table.reef


Overview

reefvision.widgets.table — columns, header row, row selection (Wave 5)

object Table extends view.View. Layout: one header row + body rows. Selection is a single body row. Vertical scroll when row_count > visible_rows. No horizontal scroll (v1). Insertion is Group.add.

Usage: let t = new table.Table(cell.rect(0, 8, 48, 6), 3, 32, 4) t.set_header(0, "Name") let _ = t.add_row() t.set_cell(0, 0, "main.reef") win.add(t)


Objects

Table

Extends: view.View

Fields:

Name Type
headers [string]
col_widths [int]
col_count int
cells [string]
max_rows int
row_count int
selected int
offset int
activated bool
last_click_idx int
last_click_sec int
last_click_ms int
visible_rows int

proc init(bounds: cell.Rect, col_count: int, max_rows: int, visible_rows: int)

Methods:

override shared fn wants_focus(): bool

shared fn has_scrollbar(): bool

exclusive proc set_header(col: int, title: string)

exclusive proc set_visible_rows(visible_rows: int)

exclusive proc set_offset(offset: int)

exclusive proc clamp_offset()

exclusive proc set_col_width(col: int, width: int)

shared fn header(col: int): option.Option[string]

0.9.2 C16: None for an out-of-range column.

"" is a legal column heading (an unlabeled column), so "no such column" and "that column has no title" were the same answer. col_width() keeps a bare int on purpose: set_col_width clamps to >= 1, so 0 cannot be a real width and does not collide.

shared fn header_or(col: int, default: string): string

*_or twin: the cell/heading/line, or the caller default when the index is out of range. A PRESENT value always wins -- "" is the DEFAULT content of a cell, so substituting the caller default for it would reinstate the collision C16 removed.

shared fn col_width(col: int): int

shared fn cell_index(row: int, col: int): int

exclusive fn add_row(): bool

exclusive proc set_cell(row: int, col: int, text: string)

shared fn cell(row: int, col: int): option.Option[string]

0.9.2 C16: None for an out-of-range row or column.

"" is not merely legal here, it is the DEFAULT: add_row() fills every new cell with "". So the old sentinel collided with the most common cell value in the widget.

shared fn cell_or(row: int, col: int, default: string): string

exclusive proc clear()

exclusive proc clear_activate()

exclusive proc set_selected(row: int)

exclusive proc ensure_visible()

exclusive proc scroll_by(delta: int)

override exclusive proc draw(buf: cell.CellBuffer, abs: cell.Rect, clip: cell.Rect, focused: bool, th: theme.Theme)

override exclusive fn handle_event(e: event.Event): view.EventResult

exclusive fn handle_mouse(e: event.Event): bool

exclusive fn is_double_click(idx: int): bool


Functions

fn max_cols(): int

fn max_rows_cap(): int


Generated by reefc doc