titrmlib

A curses-style TUI library for the TI-84 Plus CE. Panels, widgets, scenes, dialogs, colors and text styles for CE C programs.

View the Project on GitHub gavinhsmith/titrmlib

Phase 2 design

Status: complete, merged to main and released as v0.2.0; see Progress. titrmlib is at v0.3.0, so the API may change freely until v1.0.

Phase 2 reworks how titrmlib renders and routes input, then adds scenes, overlays, a revised widget set and color. Function and type names below are proposals and may change during implementation.

Goals

1. Retained panels and change-based rendering

2. Key queue

3. Scenes

4. Overlays

5. Focus

6. Events

Events pass along a chain until one step consumes them:

  1. the focused widget
  2. the active scene’s handler
  3. the global handler

Ticks go to the active scene’s handler and the global handler.

Event Meaning
TERM_EV_START Once, before the first frame
TERM_EV_KEY A key nothing earlier in the chain consumed
TERM_EV_TICK The interval set with term_set_tick() passed
TERM_EV_SUBMIT The user confirmed with [enter]: a button, an input, or a list item (value = item index)
TERM_EV_CHANGE A widget’s value changed: input text edited, list selection moved, checkbox toggled
TERM_EV_FOCUS_LOST The focused panel was hidden or destroyed
TERM_EV_SCENE_ENTER / TERM_EV_SCENE_LEAVE The scene became active or inactive

TERM_EV_SELECT is removed; choosing a list item sends TERM_EV_SUBMIT. Custom widgets send the same events.

7. Widgets

Widgets are panels with general properties, not one-off code:

Built-in widgets:

Widget Behavior
Container A plain panel that holds children. Border and title are optional fields
Text Static or word-wrapped text, with a scroll offset, appending lines and optional auto-scroll to the bottom (replaces the log widget)
Input Single-line editable text
List Selectable items. Up/down move and send TERM_EV_CHANGE; [enter] sends TERM_EV_SUBMIT
Button A focusable text panel, centered and reversed, that sends TERM_EV_SUBMIT on [enter]. term_make_button is a shortcut for those settings
Checkbox A focusable on/off item with a label; [enter] toggles it and sends TERM_EV_CHANGE
Progress A horizontal bar, value out of a maximum

8. Color

Build order

  1. Retained panels, change-based rendering and the key queue (sections 1–2)
  2. Focus and event changes (sections 5–6)
  3. Scenes (section 3)
  4. Overlays (section 4)
  5. Widget set (section 7), and the demo rebuilt on it
  6. Color (section 8)

Each step keeps the unit tests and hardware tests passing, with screens re-recorded where output changes on purpose. The perf budgets tighten to the 50 ms goal once step 1 lands.

Progress

Step State
1. Retained panels, change-based rendering, key queue Done
2. Focus and event changes Done
3. Scenes Done
4. Overlays Done
5. Widget set and demo Done
6. Color Done

Steps 1 and 2 were built together: with retained output, the app has to be told about everything that changes what it shows, which is what step 2 adds.

Decisions made while building steps 1–2

Decisions made while building step 3

Decisions made while building step 4

Decisions made while building step 5

Decisions made while building step 6

Still to decide