ReefVision notes

Getting started: Writing a ReefVision app (new Application, win.add, locals not ids, do_step / run_loop).

This page is the leftover patterns sheet (commands, paste, resize, demos). API detail lives in the ReefVision stdlib reference, starting at reefvision.desktop.

Building blocks

Module Role
desktop Application (passive) + Desktop; do_step / run_loop, status, modals, paste
theme Palettes, frame mode (single/double/ascii), TOML load
view View / Group tree, focus, EventResult
widgets.* Label, Button, InputLine, ListBox, Checkbox, RadioGroup, ProgressBar, TextArea, Table, MenuBar, MessageBox, Window, Scrollbar
event / input Keys, mouse, bracketed paste
commands Enable/disable + accelerators

Patterns that matter

  1. Client coordinates — Window.add child bounds are relative to the client (inside the frame). Outer size is client + 2 in each dimension.
  2. Commands — toolkit IDs 1–99 (CMD_OK, CMD_QUIT, …); app commands ≥ 100. Register with commands_set, wire menus via menu_item / menu_item_accel.
  3. Accelerators — menu_item_accel + app.register_menu_accels(); global match when menus are closed.
  4. Modals — app.message_box for simple dialogs; modal_push / modal_run / modal_poll for wizards (see installer demo).
  5. Paste — bracketed paste is enabled on fullscreen open; text goes to the focused InputLine or TextArea. app.clipboard_set uses OSC 52 (best-effort).
  6. Resize — desktop reclamps windows; win.set_center_on_resize(true) keeps dialogs centered; modals re-center automatically.

Reference demos

The release tree ships these under share/reef/examples/.

Demo Path What it stresses
Hello reefvision_hello.reef InputLine local, OK/Quit, MessageBox
App shell reefvision_app_shell.reef Menus, multi-window, themes, forms, context menu
Installer reefvision_installer.reef Modal stack, ProgressBar
Mini IDE reefvision_ide.reef TextArea + Table
Gauge reefvision_gauge.reef Custom View subclass

They need a TTY. From the release tree:

cd share/reef/examples
# hello
reefc reefvision_hello.reef -o /tmp/rv_hello && /tmp/rv_hello
# shell
reefc reefvision_app_shell.reef -o /tmp/rv_shell && /tmp/rv_shell
# installer wizard
reefc reefvision_installer.reef -o /tmp/rv_install && /tmp/rv_install
# IDE
reefc reefvision_ide.reef -o /tmp/rv_ide && /tmp/rv_ide

API docs

Start at reefvision.desktop and the widget pages under reefvision.widgets in the stdlib reference.

Themes

Built-ins: theme.theme_builtin_at / F2 cycle. Theme TOML files ship with the stdlib under lib/reef/stdlib/reefvision/themes/*.toml in the release tree (or your install prefix) (frame.preset, colors, desktop_fill). Copy one next to your app, or pass its full path:

module main

import reefvision.desktop as desktop
import reefvision.theme as theme

proc main()
    mut app = new desktop.Application(theme.default_theme())
    let th = theme.theme_load_file("green.toml")
    if theme.theme_parse_ok()
        app.set_theme(th)
    end if
end main

end module