Module: reefvision.vt

Source: ./reefvision/vt.reef


Overview

reefvision.vt — pure VT cell-grid emulator (no TTY)

Byte-stream in, cell.Cell grid out. C0 / CUP / ED / EL / UTF-8 / SGR 16+256 / default FG/BG 39+49 / alt screen 1049 / DECSTBM / mouse 1000/1002/1006. OSC (ESC ]) and DCS (ESC P) are ignored until BEL or ST (ESC ). ESC ( / ) / * / + / % Final (charset / UTF-8 designate) consumed so xterm sgr0=\E(B\E[m does not paint a literal 'B'.


Types

Vt

Fields:

Name Type
cols int
rows int
cells [cell.Cell]
alt_cells [cell.Cell]
alt_screen bool
cx int
cy int
saved_cx int
saved_cy int
cur_style cell.Style
saved_style cell.Style
scroll_top int
scroll_bottom int
mouse_tracking int
mouse_sgr bool
state int
params [int]
nparams int
param_acc int
csi_private bool
csi_inter bool
utf8_buf [int]
utf8_len int
sb [cell.Cell]
sb_cap int
sb_count int
sb_head int
view_off int

Functions

fn clamp_dim(n: int): int

fn alloc_grid(cols: int, rows: int, style: cell.Style): [cell.Cell]

fn active_buf(vt: Vt): [cell.Cell]

fn vt_create(cols: int, rows: int): Vt

fn vt_cell(vt: Vt, x: int, y: int): cell.Cell

fn vt_encode_mouse(vt: Vt, x: int, y: int, button: int, pressed: bool, motion: bool): string

fn sb_logical_row(vt: Vt, i: int): int

fn vt_display_cell(vt: Vt, x: int, y: int): cell.Cell

fn cursor_index(vt: Vt): int

fn ansi16_channel(idx: int, mask: int): int

fn ansi16_color(idx: int): cell.Color

fn cube_level(c: int): int

fn xterm256(n: int): cell.Color

fn csi_param(vt: Vt, idx: int, default: int): int

fn csi_param_raw(vt: Vt, idx: int): int

fn byte_of(c: char): int

fn utf8_need(lead: int): int


Procedures

proc fill_cells(cells: [cell.Cell], start: int, count: int, style: cell.Style)

proc copy_overlap(old: [cell.Cell], old_c: int, old_r: int, nu: [cell.Cell], new_c: int, new_r: int)

proc clamp_cursor(vt: Vt)

proc vt_resize(vt: Vt, cols: int, rows: int)

proc push_scrollback_row(vt: Vt, src: [cell.Cell], row: int)

proc rebuild_scrollback(vt: Vt, new_cols: int)

proc rebuild_scrollback_to(vt: Vt, new_cols: int, new_cap: int)

proc vt_set_scrollback_cap(vt: Vt, cap: int)

proc vt_follow_output(vt: Vt)

proc vt_scroll_view(vt: Vt, delta: int)

proc put_cp(vt: Vt, cp: int)

proc erase_linear(vt: Vt, start: int, end_excl: int)

proc copy_row(buf: [cell.Cell], cols: int, dst_y: int, src_y: int)

proc scroll_up(vt: Vt)

proc scroll_down(vt: Vt)

proc do_index(vt: Vt)

proc do_ri(vt: Vt)

proc save_cursor(vt: Vt)

proc restore_cursor(vt: Vt)

proc set_alt_screen(vt: Vt, on: bool)

1049h: save cursor, switch to alt, clear alt (no-op if already alt). 1049l: restore primary and cursor (no-op if already primary).

proc csi_push(vt: Vt)

proc csi_enter(vt: Vt)

proc do_cup(vt: Vt)

proc do_cuu(vt: Vt)

proc do_cud(vt: Vt)

proc do_cuf(vt: Vt)

proc do_cub(vt: Vt)

proc do_ed(vt: Vt)

proc do_el(vt: Vt)

proc do_decstbm(vt: Vt)

proc do_private_mode(vt: Vt, set: bool)

proc cow_cur_style(vt: Vt)

Style/Color are heap pointers: put_cp stores cur_style by reference. Field mutations must COW first or prior cells share the rewrite.

proc do_sgr(vt: Vt)

proc csi_exec(vt: Vt, final: int)

proc drop_utf8(vt: Vt, n: int)

proc utf8_consume(vt: Vt)

proc utf8_push(vt: Vt, u: int)

proc feed_string(vt: Vt, u: int)

proc feed_str_esc(vt: Vt, u: int)

proc feed_esc(vt: Vt, u: int)

proc feed_csi(vt: Vt, u: int)

proc feed_one(vt: Vt, b: int)

proc vt_feed(vt: Vt, data: string)


Generated by reefc doc