TUI (Terminal User Interface) pack

I’ve published a TUI library.
I did the design/prototyping/optimization of the MVP. Then worked with Claude Code to add features and polish before publishing.

Features include: TEA-inspired model/view/update · term-based views (rows, columns, tables, zones, align, ports, RGB styles) · components via alias_drawable/2 + at_event_is/3 event bubbling · ready-made inputs, buttons, check boxes, scroll areas · optimized incremental painting · Kitty keyboard protocol · mouse · Kitty graphics images · subscriptions for timers and worker threads · headless “VCR” testing · swipl tui examples


Installation:
?- pack_install(tui).

List examples:
swipl tui examples

Run a particular example:
swipl tui run gallery

There’s a basic text editor example (called atto) capable of editing one file:
swipl tui run atto — path/to/some_file.pl

Code is at GitHub - z5h/prolog_tui · GitHub

Care has been made to ensure tui is minimal, complete, stable and performant.

See this “LLM use” section at the end of the README for more notes on that topic. GitHub - z5h/prolog_tui · GitHub

@jan:
swipl pack publish https://github.com/z5h/prolog_tui.git registered the pack, but reported Pack prolog_tui at version 0.1.0 failed for unknown reason (false).
The repo name (prolog_tui) differs from the pack name in pack.pl (tui). For a git URL, pack_default_options/4 takes the pack name from the URL (git_url(URL, Pack)). register_downloads/2 then looks for prolog_tui-Result in the server’s reply, which is keyed tui, so it reports failure although the server registered the pack.
The installation plan shows the same confusion: “Install prolog_tui at version 0.0.0”.
What’s the best course of action here?

Looks impressive!

Settle a name that is both the pack name and repository name and publish. I can delete a pack and change the registered source on the server. Deleting will do the job if you prefer a new pack name. If you change the repo, I can change the registered source, so you can push again.

Amazing :slight_smile:
Is your library compatible with swi-prolog make/0 hot-reloading features ?
One thing that was kind of impressive when I last tried to write a text editor in swi-prolog was to edit the source code of the editor through the editor and have shortcut call make and then the live editor instance would pick up the changes on the fly !

I’ve renamed the repo to “tui” and updated pack.pl to reflect that.
I can republish whenever I get the go-ahead.

I have approved all the pending posts here. Weird. You are at a high trust level and I can’t find anything wrong with it. It was flagged by Discourse itself. Hope it learns …

So you renamed the repo to “tui.git”? You want me to delete the current or change the source URL?

I renamed the repo, bumped the version and tried publishing:
> swipl pack publish https://github.com/z5h/tui.git

I got:
ERROR: [Thread main] Pack tui at version 0.1.2 is already registered with a different URL

So, change the source URL? (I’m not clear how things work under the hood).

I updated the URL to drop the prolog_. Packs are bound to a source location. If this is a git repo, it is simply that repo. Otherwise the directory must match and the file name should properly reflect the pack and version. Anything else is rejected. This restricts updating the package to the original publisher. GIT repos are by far preferred (maybe we should block anything else?).

I just did a quick test of the async example that uses the ports and subscription feature for multithreaded support. (As I thought this would be the most fragile).

It works!

The only catch is it has to be run with 2> /dev/null or however your shell discards stderr, because make prints a warning to the terminal.

Well, you can define user:message_hook/3 to capture the messages and display them where they belong. That is precisely why the print_message/2 stuff is meant for,

Hot reloading is now “officially” supported and documented:

app/5 option reload(Key): hot reloading. Key runs make/0, paints the view as the new code draws it, keeping the state, then update receives reloaded.

Yay, happy to see this released after the “sneak preview” you gave me a while ago :grin: