Stage 1 tasks

Stage 1 is the demo: examples/demo.tcl opens a window on Linux, with grid, labels, buttons, and an entry, with bind, with a CSS stylesheet, and with a GPU renderer at 60 frames in each second. The same demo also draws directly on the display of a Linux device with no display server: with Vulkan on the display, or on the CPU to the framebuffer. The plan has the design.

Do the tasks in order. One task is one commit, or a few commits when the task says so. Do not start a task before the tests of the task before it pass.

Tasks 06, 07, 08, and 16 need no widget code. They can go before their place in the order when another task is blocked. The framebuffer output of task 20 does not need tasks 16 and 17.

Tasks 06, 07, 12, 18, 19, and 20 use what the Printdeck project learned with its own UI framework on a small touch screen. The lessons has the facts. The implementer reads that page and does not open the Printdeck source, because Printdeck has the AGPL.

The ztcl event loop

The event loop of ztcl (after, vwait, update, fileevent) is not on the main branch of ztcl at commit 125392f. Stage 1 does not wait for it.

Rules for each task

  1. Use Zig 0.16.0. Check with zig version.
  2. Run each build, test, and benchmark under the memory cap:
    systemd-run --user --scope -q -p MemoryMax=4G -p MemorySwapMax=0 -- <command>
    
    The commands in the task files do not show the cap. Add it to each one.
  3. Stop only your own processes, by PID. Do not use pkill -f.
  4. Work only in the ztk repository. Read ztcl through the pinned package. Do not change the local ztcl folder, and do not read the zslice source or the Printdeck source.
  5. Read WRITING.md before the first comment and the first commit.
  6. Start each source file with a //! comment that explains what the file does and how, and an SPDX line: // SPDX-License-Identifier: BSD-2-Clause (inside the //! block, as ztcl does).
  7. Add no dependency that the plan does not list. Stage 1 links only the Wayland client library, libxkbcommon, and libc for the Wayland backend, and opens the Vulkan loader at run time. The core, the text code, the headless backend, and the direct backend link no library.
  8. ztk keeps its state in the allocator of the App. It keeps no ztcl.Value and no slice of the ztcl arena after a command returns. Copy what must stay.
  9. Each error message that Tk also has is the same text as in wish 8.6.16. Run wish to get the text. Do not guess it.
  10. Each behavior comes from the manual page or from a run of wish. Copy no code from Tk. Add an entry in docs/references/ for each new source.
  11. A test that needs something the machine does not have (a GPU, a Wayland compositor, wish) skips with a message that names the missing thing. It does not pass silently, and the report counts it as skipped.
  12. Do not change a golden file to make a test pass, unless the task changes that output on purpose. Say so in the commit message.
  13. Run zig build test before each commit. All tests pass.
  14. A commit message passes WRITING.md. It names no AI model and no vendor, and has no attribution line.
  15. When a step of a task is not possible, stop and write the reason in docs/tasks/BLOCKED.md: the task, the step, what you tried, and the exact error. Then go to the next task that does not need the blocked one.
  16. When a task file and the manual page of Tk disagree, the manual page and wish win. Note the difference in the commit message.

Facts about the build that were checked

These were checked on the development machine on 2026-11-23 with a scratch program.

The ztcl interface

The signatures are from ztcl commit 125392f. Check them in the pinned package before use.

const ztcl = @import("ztcl");
// ztcl.Interp, ztcl.Value, ztcl.Error
// ztcl.interp.NativeFn = *const fn (it: *Interp, argv: []const Value, cmd: ?*Cmd) Error!Value
// ztcl.interp.Command { name, impl, ctx: ?*anyopaque, traces }

it.init(gpa)                          // the Interp must not move after init
it.register(name, native_fn)          // then: it.findCommand(name).?.ctx = ptr
it.findCommand(name) ?*Command
it.eval(text) Error!Value             // copies and parses the text at each call
it.compile(text) Error!*Script        // text must stay valid as long as the script
it.evalTop(script) Error!Value
it.callWords(argv) Error!Value
it.str(v) / it.list(v) / it.int(v)
it.setVar(name, v) / it.getVarOpt(name)
it.fail(fmt, args) Error              // sets the result, returns error.TclError
it.wrongArgs(usage) Error
it.alloc()                            // the arena of the interpreter
it.result                             // the message after error.TclError
it.frame, it.global, it.ns            // set frame = &global and ns = "" for a callback

argv[0] of a native command is the command name.

Names used in all tasks

Name File Meaning
App src/app.zig One ztk instance on one interpreter
Widget src/widget.zig One node of the widget tree
Class src/widget.zig The table of a widget class
Loop src/loop.zig Timers, idle work, and the wait
Platform, Window src/platform/platform.zig The backend interface
Event src/event.zig One input event
Scene, Quad src/scene.zig What a frame draws
Renderer src/render/renderer.zig The interface of the CPU and Vulkan renderers
Style src/style.zig The computed style of a widget
Harness src/testing.zig An interpreter, an App, and a headless backend for a test