c8-lua #
c8-lua: runs c8ui apps and live tile providers written in Lua 5.4, and c8-lua-new that starts one from a template.
Depends on: c8ui, c8-base, gdk-pixbuf, Lua 5.4 (the system's, else fetched and built in).
Apps and tiles without a build step: c8-lua SCRIPT [FILE...] runs a
Lua script once, which says what it is with c8.app{...} (then
c8ui_app_main: one copy, files handed over, the charms) or
c8.provider{...} (a tile provider on c8_tile_provider_watch, no
window). Its README is the API for app writers: keep it true when the
bindings change. c8-lua-new app|tile ID "NAME" (a shell script, in
bin) writes a script into ~/.local/share/c8-lua/ID/ and the .desktop
or .widget file that puts it in All apps or Live tiles.
Lua is 5.4, asked for by name (lua-5.4, lua5.4, lua54; never plain
lua, which here is LuaJIT and elsewhere may be 5.5), else meson
fetches 5.4.8 from subprojects/lua.wrap and links it statically
(Tumbleweed's lua54-devel conflicts with luajit-devel, which
mpv-devel needs, so this PC always uses the fetched one; build.sh
installs with --skip-subprojects so no liblua lands in the prefix; no
C modules, loadlib is off). LuaJIT was turned down for its 5.1
language; QuickJS may come later as a second language over the same
shape, so keep what is language-neutral out of the Lua glue where it's
cheap to.
main.c (the runner, c8l_call: every call into Lua is a pcall with a
traceback to stderr, so no error longjmps through c8ui; the charms),
ui.c (windows and widgets), draw.c (g for lists and canvases,
pictures through gdk-pixbuf, events as tables), sys.c (timers, JSON
on c8-base's reader, c8_http, commands, c8.save/load as
~/.config/cont8nuum/NAME.json 0600, tiles).
A widget in Lua is a userdata (struct handle: the c8ui widget and its
kind) held in the registry (LIVE) while the widget lives; its
uservalue table has the script's functions and fields. c8ui's
on_destroy/user_data are the binding's (widget_gone runs the
script's on_destroy, clears the pointer, drops the registry entry),
so callbacks find the handle from the widget they're given, with no
data. A dead handle's methods do nothing (ALIVE), which is what
makes late answers safe; don't turn that into errors. Methods are per
kind (METHODS[kind], then K_PLAIN's), w:get()/w:set() switch on
the kind, and common properties (hidden, fill, width...) go
through set_prop. A window's root child is a box of ours (holder)
whose on_destroy says the window closed; the app's widget goes in it.
win:close() on the last window quits (a hold let go). Indexes are
from 1 in Lua, 0 in c8ui. A new widget kind: an enum value, a
constructor in constructors[], its values in push_value/w_set,
methods with kind_methods, and a line in the README.
Tested headless in a bwrap sandbox, wide and at 480
(examples/demo.lua): pages, buttons, a dialog, toggle, slider, combo,
entry, a list with c8.save, a canvas on a timer, c8.run, the Search
and Settings charms, a second launch handing over; a kitchen-sink
script: checkbox, choice, radio, ring, progress, link, icon button,
info bar, expander, grid, rich text, a picture, the text view, pivot, a
drawn kept grid list, stack push and pop, menu, flyout, the app bar,
c8.http (https, and plain http refused), timers; load-tile.lua
pinned on Start and c8tile restart; c8-lua-new for both kinds.
Also (nested c8 under dbus-run-session, dbus-monitor on Tiles1,
2026-11-28): count_children (and after a destroy), box:padding both
forms, label:style/color (and a bad name erroring), w:enter() (fades
and slides in, measured from frames), scroll_to and scroll_to_x with
:offset() on down, sideways and both-way scrolls (one-way scrolls
ignore the other axis), list:is_selected/reveal, pic:size and
c8.picture shrinking and nil+why, c8.tile.update with tags and
c8.tile.remove (the D-Bus calls, not Start's turns), dead handles
quiet. scroll_to_x exists because c8ui_scroll_to only moves down.
Built alone on Debian 13 (podman debian:trixie, 2026-11-28): c8ui,
c8-theme, c8-lua with --prefix ~/.local --libdir lib and only Debian's packages (libwayland-dev wayland-protocols
libxkbcommon-dev libcairo2-dev libpango1.0-dev libglib2.0-dev
libgdk-pixbuf-2.0-dev librsvg2-dev liblua5.4-dev desktop-file-utils
meson ninja-build pkgconf gcc; curl for c8.http). It found the
system Lua 5.4.7, and hello drew in a nested c8 through the socket.
No c8-protocols needed.
Hub, pivot and tilt as c8ui has them (2026-11-30): hub:title,
hub:show, pivot:title, pivot:wrap, and tilts and background as
properties. background is c8ui's colour on any widget, but on a hub a
picture (or nil) goes to c8ui_hub_set_background: before, finish
passed the hub's picture to the colour setter too, which painted the
hub white under it. Tested headless (nested c8, 1280x800): the pivot's
title, wrap, :set(3) going round, :wrap(false), :title(nil) and
back; the hub's picture panning slower than :show(4) (a 2400x600
picture; a 16:10 one in a 16:10 window has no width to pan),
:title, background = nil and back; tilts read and set on a
canvas. Untested: a canvas actually tilting from Lua (a nested c8 can't
hold a button), the list's own tilt from Lua, touch.
Untested: the file pickers, the clipboard, touch, the real
session, a tile's several tagged updates, a system Lua 5.4.
Our own Lua apps are in apps/lua (its own meson project, and its own CLAUDE.md).
Wake-ups: c8.app{ wake } is c8ui's info.wake (app_wake in main.c:
done when it returns, unless it returns true, then c8.wake.done()),
c8.wake.at/every/cancel/done (only once the app has started: c8ui
needs the running app), info.command is this runner's
/proc/self/exe and the script's absolute path; c8.args leaves out
--c8-wake TAG DUE. c8.notify (sys.c) sends a toast with the app id
as desktop-entry and no actions, so a click opens the app. Clock's
timer books timer and keeps ends (os.time) in clock.json, so a
Clock opened again picks a running timer up, on the Timer tab. Tested
headless: reopened mid-timer it went on counting; with Clock closed the
wake's toast came and a click on it opened Clock.
The rest of c8ui (2026-11-30), for examples/gallery.lua, which is
toolkit/c8ui/examples/gallery.c page for page: nav, number, rating, date,
time, calendar (marks is called with y, m, d and no widget), flip,
split, tree (item ids are c8ui's; the top is 0), columns and list
cells (drawn with c8ui_columns_draw_cell through the list's
columns, kept in its uservalue), zoom, rich columns and overflow,
viewbox, toggle and repeat buttons, item container, transport,
win:navbar, win:settings, menu items as tables (always through
c8ui_menu_show_items; items without an id numbered in reading order),
list spans/:mode, grid column_widths/:span, info bar
closable; in g: c8.gradient, c8.draw_picture, g:shape,
g:paint, family, baseline (cairo's toy text, as gallery.c's
slides use). Traps: c8-lua's lists default to click_opens = true,
c8ui's to false, so the gallery passes false; c8l colours are 8 bit, so
a gradient from doubles can be a level off. Tested headless (nested c8
under dbus-run-session, 1280x800 and 480x900, the C and Lua galleries
run side by side, keys from one wtype call, magick compare): every
page wide and narrow pixel for pixel the same, except the hub (the
gradient's rounding); gallery.c now sets the locale as c8-lua does (the
user's, numbers C's), so Pickers matches in en_GB too. The ring and the
indeterminate bar differ by when the shot fell. Narrow runs also differ by
whichever row the pointer happens to hover, run to run. Also the same: the app bar and nav bar
(Menu, F2), fruit suggestions, the menu and "Menu dismissed", narrow
Enter/Escape through every page, Tab focus, a tree folder opening and
selected, the toggle and repeat buttons. Untested: the menu's
submenus and ticks chosen, flyouts and the settings flyout, the
transport, item containers, the calendar's marks clicked, zoom,
column sorting, pinches and touch.
The narrow setters (2026-12-01): every widget's narrow_hidden;
boxes' narrow_padding/narrow_spacing/narrow_vertical (options
and methods; padding() in ui.c reads either key), scrolls'
narrow_horizontal/narrow_vertical, labels' narrow_style, the
hub's narrow_column and a section's name. pages:narrow() only
says whether it is folded (c8ui's pages fold by themselves). Tested
headless, 2026-12-01: Calculator and Notes snapped and back, the C and
Lua galleries snapped side by side (Text, Hub, Layout, Reader: Layout
and Reader pixel for pixel, Text by the pointer's hover, the hub by
its gradient). Untested: narrow_style and narrow_column from Lua
(no bundled script uses them).
w:colors() (2026-12-05): c8ui_widget_colors as a table (fg, bg,
accent, secondary, dark), for colours an app writes into markup (the
editor's Markdown preview: links, code). Read when called: a theme
changed later isn't heard. Tested through the editor's preview, light
and on a scheme = "dark" scroll. w:rect() (x, y, w, h as laid out,
for scrolling to a widget: the preview's anchors) and c8.rich's
on_link (c8ui_rich_on_link only when it's given), same day, tested
the same way.
Not bound yet: drag and drop, thumbnails, curves in g, Miller
columns (c8ui_miller_*), c8ui_hub_set_name/_set_width.