A TUI framework for SWI-Prolog, inspired by TEA (The Elm Architecture).
Components are defined via the multifile hooks alias_drawable/2 and
at_event_is/3.
This module gives the event loop and the core drawables. Ready-made,
styled components are opt-in: load library(tui/components).
- author
- - Mark Bolusmjak
- See also
- - app/4
- alias_drawable(+DrawableTerm, -ExpandedDrawable) is semidet[multifile]
- Multifile hook. Define custom drawable components by mapping a term
to its drawable expansion. During rendering the alias is pushed onto
the component stack so that at_event_is/3 can intercept events.
- See also
- - at_event_is/3
- at_event_is(+AliasOrStack, +PositionedEvent, -RewrittenEvent) is nondet[multifile]
- Multifile hook. Rewrite an event as seen by a component on the alias
stack. PositionedEvent is X-Y-RawEvent, X-Y being where the event
happened, relative to the component's
origin (absolute for [], the bottom of the stack; with no cursor, []
sees RawEvent alone). Called during event bubbling: each solution
replaces the event, and bubbles on from the same component; with
none, bubbling continues to the next stack entry. Every event the
raw event becomes reaches update, in order.
A cursor movement bubbles as moved(Direction) from where the cursor
was, and, for an arrow key no component claimed, as arrived(Direction)
where it lands. The cursor moves regardless; what they are rewritten
to is handled with the cursor moved. A mouse event bubbles where it
happened (see app/5).
Besides events for update, a component may produce a direction, which
moves the cursor one cell, or cursor_by(DX-DY), which moves it by an
offset; e.g. to keep the cursor after an edit, or, answering
arrived(Direction), on a cell where it belongs. noop takes the event
to do nothing: it bubbles no further, and update never sees it.
- See also
- - stack_event_is/3
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- direction(Arg1)
- limits_direction_from_to(Arg1, Arg2, Arg3, Arg4)
- drawable(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)
- drawable_raw(Arg1, Arg2)
- stack_event_is(Arg1, Arg2, Arg3)
- app(Arg1, Arg2, Arg3, Arg4)
- app(Arg1, Arg2, Arg3, Arg4, Arg5)
- port_send(Arg1, Arg2)