# tvision-m2 - milestone summary (2026-09-16) A TVision/Turbo-Vision style character-cell UI toolkit written in ISO GNU Modula-2 (`gm2 -fiso`) for the terminal, developed alongside the tigr and microui bindings in this repository. No C source and no graphics dependency; the only non-Modula-2 part is the libc binding `tvtty.def`. ## Status Working milestone: a retained view tree with clipping and z-order, a diffed ANSI screen, keyboard + mouse input, widgets and modal dialogs. Builds warning-free and was exercised by driving a real pty (frames reconstructed from the captured terminal stream). ## Files | file | role | |---|---| | `tvtty.def` | libc binding: raw mode, winsize, read/write | | `tv.def` / `tv.mod` | screen, view tree, widgets, events, modal dialog | | `demo.mod` | demo application (two windows, all widgets, mouse) | | `ttysize.mod` | diagnostic for the tty binding | | `Makefile` | build | | `README.md` | build/run + API + GM2 notes | ## Implemented - Alternate screen, hidden/show cursor, terminal restore on exit. - 16-colour fg/bg, explicit blink on/off, UTF-8 box drawing, clipping stack. - Diffed redraw: only changed cells are written. - View tree: groups and windows own children; per-window clipping; z-order with click-to-front; windows draggable by the title row (any direction) and clamped so the title stays on screen; ` X ` close box. - Widgets: static text, frame, input line (insert/backspace/delete/Home/End/ arrows), push button, check box, radio buttons, list box (selection, wheel scroll) and vertical scroll bar. - Focus chain (Tab / Shift-Tab / up-down); hardware cursor in the focused input; Enter/Space activate. - Keyboard decoding: printable UTF-8, arrows, Home/End, PgUp/PgDn, Ins/Del, F1-F12, Enter, Space, Backspace, Esc, Ctrl-C. - Mouse: xterm SGR reporting (mode 1002/1006) - click to focus/press, drag titles, click list rows, wheel scroll. - Modal `Message` dialog with its own event loop. - Menu bar with drop-down menus: click or `F10` to open, Left/Right switch menus, Up/Down move, Enter/Space or click selects (returns the item tag); separators supported. ## Verified Driving the demo through a pty and reconstructing the screen: - initial layout (Editor + About windows, list, radios, check box, buttons, status bar) renders correctly; - clicking `OK` with the mouse opens the modal Info box; - dragging the title moves the window in every direction and clamps at the top-left so the title stays visible; - clicking the `File` title opens the drop-down (New/Open/Sep/Quit), `F10` + Enter selects the first item (status shows the command tag), and clicking `Quit` exits the program. ## Known limitations / next steps - `Message` is the only dialog helper; no generic form dialog. - Menu items have no hotkeys; no check/radio menu items. - Windows are not resizable; no hover highlight. - Terminal size is polled (no `SIGWINCH`-driven relayout). - Nested clipping groups beyond windows are untested. ## GNU Modula-2 notes See `README.md`: value-returning no-arg procedures need `()` in the `.def`; pointer fields need `^`; a `BEGIN...END` block cannot be a `CASE` branch; `INTEGER` vs `HIGH()` comparisons need `VAL`; termios/winsize use fixed Linux offsets. A subtle runtime bug was found and fixed in the ANSI output: SGR attributes accumulate, so blink must be emitted explicitly as `;5`/`;25` or it leaks into every following cell.