Commit Graph

92 Commits

Author SHA1 Message Date
Hermes Agent
668966380e prose: split scrollbox-tabbar.org prose into per-module org files
Distribute the literate prose from the old combined scrollbox-tabbar.org
into three individual module org files:

- scrollbox.org: ScrollBox class, render, scrollbars, bug fixes,
  plus the combined test suite (tangles scrollbox-tabbar-tests.lisp)
- tabbar.org: TabBar class, navigation, keyboard handler, render
- container-package.org: Package definition and exports

The old scrollbox-tabbar.org is retained as a documentation archive
with all code blocks set to :tangle no and a redirecting note.

Fixes the draw-scrollbars code block to use the post-bugfix version
(with layout-node origin offset ox/oy), matching the working code.
All 13 test suites pass at 100%.
2026-05-12 18:06:07 +00:00
Hermes Agent
a061d60898 split: scrollbox-tabbar.org into scrollbox.org, tabbar.org, container-package.org
- Create org/scrollbox.org (tangles scrollbox.lisp)
- Create org/tabbar.org (tangles tabbar.lisp)
- Create org/container-package.org (tangles container-package.lisp)
- Disable :tangle in old scrollbox-tabbar.org (kept for prose docs)
- Fix missing paren in render method (was depth=1 at EOF)
- All 483 tests pass, 14 suites, 100%
2026-05-12 18:00:06 +00:00
Hermes Agent
d5caaf296d fix: restore original text-input.lisp in org to fix handle-text-input
The tangled handle-text-input used (key-event-text event) for character
insertion, but the test suite creates key events with :code not :text.
Restored the original handle-text-input which uses
(code-char (key-event-code event)) — matching the test expectations.
2026-05-12 17:52:43 +00:00
Hermes Agent
0fb5309133 literate: convert org/markdown-renderer.org from doc-only to tangle source
Now tangles to markdown.lisp + markdown-package.lisp.
Deleted hand-written originals and regenerated — GREEN.
2026-05-12 17:25:52 +00:00
Hermes Agent
d3bc6c748a literate: convert org/layout-engine.org from doc-only to tangle source
Now tangles to layout.lisp + layout/tests.lisp.
Deleted hand-written originals and regenerated — GREEN.
2026-05-12 17:18:27 +00:00
Hermes Agent
f50d0e61d1 literate: convert org/box-renderable.org from doc-only to tangle source
Now tangles to box.lisp + text.lisp + box-tests.lisp.
Deleted hand-written originals and regenerated — GREEN.
2026-05-12 17:16:26 +00:00
Hermes Agent
c77c6b9d02 literate: convert org/modern-backend.org from doc-only to tangle source
Now tangles to modern.lisp + modern-tests.lisp.
Deleted hand-written originals and regenerated from org — GREEN.
2026-05-12 17:14:37 +00:00
Hermes Agent
dfd828c914 literate: convert org/backend-protocol.org from doc-only to tangle source
Now tangles to: package.lisp, classes.lisp, simple.lisp, tests.lisp
All 4 .lisp files deleted and regenerated from org alone — verified GREEN
2026-05-12 17:08:54 +00:00
Hermes Agent
ce7e9fbab0 literate: create org/render.org, org/theme.org, org/package.org
Follows the literate programming workflow:
  Overview → Contract → Tests → Implement → Tangle → Test (GREEN)

render.org covers render.lisp + render-tests.lisp (component protocol,
render dispatch, dirty propagation)
theme.org covers theme.lisp + theme-tests.lisp (theme class, presets,
color resolution)
package.org covers package.lisp (cl-tty.box defpackage)
2026-05-12 17:05:47 +00:00
Hermes Agent
ba5cb360db literate: create org/dirty.org as proof of literate programming workflow
org/dirty.org is now the source of truth for dirty.lisp and
dirty-tests.lisp. The process:
  Overview → Contract → Tests → Implement → Tangle → Test (GREEN)

Hand-written .lisp files were deleted and regenerated from org alone
to prove the pipeline works.
2026-05-12 17:03:15 +00:00
Hermes Agent
47094c48e5 restructure: move backend/ and layout/ into src/; convert README to org syntax; fix demo package conflict and alien-sap ioctl; update ROADMAP with v0.15.0; remove stale files
- Move backend/ and layout/ directories into src/
- Update all path references in ASD, scripts, docs
- Convert README.org from Markdown syntax to proper Org-mode
- Fix demo.lisp use-package conflict (both backend and input export #:read-event)
- Fix modern-backend TIOCGWINSZ ioctl alien type (alien-sap wrapper)
- Add v0.15.0 section to ROADMAP, update line count to 5760
- Add known gaps (suspend/resume-backend, slot modes) to v1.0.0 checklist
- Remove docs/plans/, debug-layout.lisp, system-index.txt, ci-watchdog.sh
- Move tangle.py to Hermes skill (org-babel-tangle)
- Add .gitignore for fasl files
2026-05-12 16:57:19 +00:00
Hermes Agent
5f07c1fd76 fix: tangle.py write-once-then-append logic (was always-appending, triplicating files); confirm-dialog option plist comparison; mouse-event button type (or keyword null) 2026-05-12 15:51:44 +00:00
Hermes Agent
a812955329 docs: mark v1.0.0 Org/Lisp sync verified — all 483+57+17 checks pass on fresh tangle 2026-05-12 15:42:49 +00:00
Hermes Agent
ca90d6b945 chore: org tangle sync — regenerate .lisp from .org sources (zero functional changes, file sizes identical) 2026-05-12 15:42:40 +00:00
Hermes Agent
60866a80c1 docs: update README tangle instructions to use Python script 2026-05-12 15:22:42 +00:00
Hermes Agent
5930e17b57 fix: org tangle — fix END_SRC boundaries in mouse.org/slot.org (prose inside code blocks), replace emacs tangle with Python script that handles all blocks 2026-05-12 15:22:29 +00:00
Hermes Agent
4bb9160f8d docs: update test counts to 483/13 in README and ROADMAP 2026-05-12 14:42:00 +00:00
Hermes Agent
d5a767350f fix: word-wrap never incremented current-len (all text treated as single line); scrollbox wrong offset origin; integration test fixes 2026-05-12 14:41:16 +00:00
Hermes Agent
00db3c61a5 fix: dialog draw-border arg, markdown/slot nil guards, +integration test suite 2026-05-12 14:30:31 +00:00
Hermes Agent
6e73c3bb19 fix: redundant compute-layout per child, framebuffer diff size test, test file cleanup 2026-05-12 14:19:48 +00:00
Hermes Agent
a153746111 fix: demo arrow keys on Widgets tab move cursor instead of switching tabs; +12 keybinding dispatch tests 2026-05-12 14:12:53 +00:00
Hermes Agent
baa27f766f fix: cursor movement marks dirty in text-input and textarea (regression from cursor rendering fix) 2026-05-12 14:07:17 +00:00
Hermes Agent
b0ede26bff fix: demo uses backend-size instead of hardcoded 80x24 2026-05-12 14:04:51 +00:00
Hermes Agent
b38436038b fix: scrollbar position offset, dialog size clamp to terminal dimensions 2026-05-12 14:03:12 +00:00
Hermes Agent
df5ceabd3b fix: distribute-sizes rounding remainder, render-screen uses backend-size 2026-05-12 14:00:59 +00:00
Hermes Agent
80abb23197 fix: query-terminal stream, enable-mouse/bracketed-paste methods, simple-backend draw-ellipsis position 2026-05-12 13:53:38 +00:00
Hermes Agent
e198e8b5da fix: text-input cursor now rendered as solid block at cursor position 2026-05-12 13:50:55 +00:00
Hermes Agent
26ec1dfbe8 fix: backend-size (TIOCGWINSZ), kitty keyboard enable, Wayland clipboard, SIGWINCH handler 2026-05-12 13:49:23 +00:00
Hermes Agent
bb1717a43d fix: draw-border renders titles in modern and simple backends (title, title-align respected) 2026-05-12 13:46:42 +00:00
Hermes Agent
b21daa99b8 fix: input timeout bugs — read-raw-byte, SS3, parse-csi-params all use sub-second timeouts now (get-internal-real-time replaces get-universal-time which truncated to integer seconds) 2026-05-12 13:42:39 +00:00
Hermes Agent
30fdb1def8 Fix verify-api.py: use correct API names throughout
Previous version had 14 failing checks due to wrong function names:
- Theme: load-preset with :keyword mode, not nonexistent load-default-*-preset
- Select: setf select-filter + select-filtered-options with 1 arg
- Dialog: push-dialog/pop-dialog + dialog-title on car of *dialog-stack*
- Mouse: make-box has no :x/:y initargs, use default constructor
- Framebuffer: draw-text on framebuffer-backend, not draw-text-on-fb
- Dirty: dirty-p, not component-dirty-p
- Theme functions in cl-tty.box package, not cl-tty.rendering

Also add ci-watchdog.sh for 15-min polling CI.
All 29 checks now pass.
2026-05-12 11:41:15 +00:00
Hermes Agent
5213bdeae5 CI test 4: recreated webhook with explicit events 2026-05-12 11:39:13 +00:00
Hermes Agent
3f54fdb76a CI test 3: verify webhook after recreate 2026-05-12 11:38:34 +00:00
Hermes Agent
eabec0c48a CI test 2: verify webhook delivery 2026-05-12 11:37:21 +00:00
Hermes Agent
1e9a780d61 CI test: trigger webhook verification 2026-05-12 11:36:36 +00:00
Hermes Agent
0f408eeff7 Add CI test runner: run-all-tests.sh + verify-api.py + verify-demo-pty.py
Three-tier verification suite:
  - Tier 1: FiveAM unit tests (392 tests, 12 suites)
  - Tier 2: API feature verification (29 checks across 20 components)
  - Tier 3: PTY demo integration test (17 checks through real terminal)

Webhook subscription 'cl-tty-ci' configured to run on push.
Gitea repo webhook configured at amr/cl-tui → Hermes gateway.
2026-05-12 11:36:16 +00:00
Hermes Agent
7f4f712399 v0.15.1: EOF/Escape fixes, box title rendering, full feature verification
Bug fixes:
  - read-raw-byte now returns (values nil :eof) on stdin EOF
    instead of just nil, so callers can distinguish EOF from
    timeout.  Previously, non-TTY stdin (pipes, /dev/null)
    caused a busy-spin: sb-posix:read returned 0 immediately,
    read-raw-byte returned nil, the demo loop treated nil as
    'no event yet' and spun at 100% CPU producing 86MB of
    repeated rendering frames.

  - %read-escape-sequence now uses a 50ms timeout on the first
    follow-up byte to resolve the classic Escape-key ambiguity:
    a lone Escape press returned an :escape key-event instead of
    blocking indefinitely on VMIN=1 VTIME=0.  All callers
    (SS3, CSI, Alt+char) propagate :eof instead of faking
    :escape events when EOF occurs mid-sequence.

  - parse-csi-params now uses multiple-value-bind on read-raw-byte
    to preserve the :eof signal through CSI parsing.

  - simple-backend draw-border now renders :title on the top
    edge instead of declaring it (ignore).  The title was
    silently swallowed — the box rendered with the right border
    frame but the title text was never written.

  - demo.lisp: removed 'q' as quit key (conflicted with text
    input).  Only Esc and Ctrl+C quit.  Widget event forwarding
    scoped to tab 1 (Widgets tab).  EOF handling in main loop.
  - Stale help text (still said 'q/esc: quit') updated.

Verification infrastructure:
  - PTY-based demo test (17 checks) spawns the demo in a real
    pseudo-terminal, sends actual keystrokes, reads terminal
    output back.  Verifies: startup rendering, tab switching,
    key dispatch, 'q' doesn't quit, Escape quits via timeout,
    Ctrl+C quits, EOF clean exit, no busy-spin.

  - API feature verification (29 checks) exercises every major
    component through the actual exported API: Simple backend,
    Box with title, Text attributes, draw-rect, TextInput
    (insert/backspace/cursor/Ctrl-A/E), TextArea, key/mouse
    events, Layout flex, Markdown, Theme presets (dark/light/
    nord), Select filtering, Dialog stack, Mouse hit-test,
    Framebuffer, Dirty tracking, Modern backend, draw-ellipsis/
    draw-link, Render dispatch, Detection, Capabilities.

  - Testing pattern saved as skill (tui-pty-testing) for reuse.

Unit tests: 392/392 passing.  All 12 test suites green.
2026-05-12 10:58:27 +00:00
Hermes
eede03ee3f Add demo.sh — shell wrapper for raw terminal mode
Raw terminal mode must be set by the parent process (the shell),
not from inside SBCL.  sb-ext:run-program subprocesses cannot
reliably access the controlling terminal for stty operations.
./demo.sh sets raw mode via stty, runs sbcl --script demo.lisp,
and restores terminal state on exit (EXIT, INT, TERM).

demo.lisp no longer calls with-raw-terminal — it assumes the
calling shell has already set raw mode.
2026-05-12 01:49:48 +00:00
Hermes
2b2119a2f1 Shell wrapper for terminal raw mode, demo no longer sets raw mode
Added ./demo shell script that sets raw mode via stty before running
the Lisp demo and restores it on exit (including SIGINT/SIGTERM).

demo.lisp no longer attempts to set raw mode from inside SBCL —
terminal raw mode is the shell's responsibility.  This avoids the
recurring problem of sb-ext:run-program + stty not being able to
access the controlling terminal from inside sbcl --script.
2026-05-12 01:43:52 +00:00
Hermes
613e4b6217 stty via /bin/sh -c + stdin redirect instead of -F /dev/tty
The -F flag isn't available on all stty implementations.  Using
shell stdin redirect (stty ... < /dev/tty) via /bin/sh is more
portable and doesn't depend on run-program preserving the
controlling terminal across subprocess boundaries.
2026-05-12 01:42:15 +00:00
Hermes
0ed7427802 Raw mode via stty -F /dev/tty, explicit device path
stty now operates on /dev/tty explicitly (-F flag) instead of
relying on stdin inheritance.  This is more reliable in SBCL's
--script mode where stdin may be handled differently by run-program.
Also ensures stty always targets the controlling terminal regardless
of how the subprocess is spawned.
2026-05-12 01:40:24 +00:00
Hermes
2649dbeb79 Replace sb-posix:termios raw mode with stty-based approach
set-raw-mode now uses (stty raw -echo ...) via sb-ext:run-program
instead of sb-posix:tcgetattr/tcsetattr + termios flag manipulation.
The sb-posix termios API changed between SBCL versions (termios-cc
accessor went from 2-arg to 1-arg), and tcgetattr fails in some
container/PTY environments.

Stty is available on every Unix and is independent of SBCL's
sb-posix version.  set-raw-mode errors if stty -g returns empty
(no real terminal attached).  restore-terminal-state is a no-op
when called with nil.
2026-05-12 01:35:25 +00:00
Hermes
4594d40a9c Fix termios-cc API for SBCL 2.5.x, demo exits cleanly if raw mode fails
make-raw-termios (input.lisp:66-67): termios-cc accessor in SBCL 2.5.x
takes one arg (the struct) and returns the cc array.  Use (aref ...)
to set individual control characters.  Old code used 3-arg setf form
that no longer works and produced style warnings.

demo.lisp: Now exits with a clear error message when raw mode can't
be established, rather than running in broken pipe-safe mode where
escape sequences are echoed and input is line-buffered.
2026-05-12 01:30:09 +00:00
Hermes
517b43b801 Zero-dependency demo loading: just (require asdf) + push cwd + load-system
No Quicklisp needed at all.  Works from a fresh git clone with
just SBCL installed.  Registering the current directory in ASDF's
central-registry is enough to find cl-tty.asd.
2026-05-12 01:22:55 +00:00
Hermes
bdd558407e Robust demo loading: check quickload failure, fall through to ASDF
The demo now guards the quickload with a (find-package :cl-tty.backend)
check first, tries ql:quickload inside ignore-errors, and falls through
to direct (load cl-tty.asd) + (asdf:load-system :cl-tty) if the
package still isn't loaded.  Works in --disable-debugger mode where
Quicklisp's SYSTEM-NOT-FOUND continuable error kills the process.
2026-05-12 01:20:28 +00:00
Hermes
149316cb58 Fix demo quickload: register cwd, fallback to asdf:load-system
demo.lisp now registers the current directory as a quicklisp project
source and falls back to direct asdf:load-system if quicklisp can't
find cl-tty.  Lets the demo run from a fresh git clone without
symlinking into ~/quicklisp/local-projects/.
2026-05-12 01:18:09 +00:00
Hermes
a888eb2c76 Fix demo exit code, manual raw-mode handling, pipe-safe fallback
demo.lisp:
  - Removed ignore-errors wrapper: run-demo now returns normally,
    followed by (uiop:quit 0) at top level — fixes exit code always 1 bug
  - Manual set-raw-mode/unwind-protect/restore-terminal-state instead of
    with-raw-terminal macro (safer in edge cases)
  - Graceful fallback when raw mode fails: continues in pipe-safe mode
    so the demo renders frames even without terminal control
  - Simplified tab rendering, fixed textarea-lines display

The demo runs correctly in both interactive and pipe-safe modes.
In a real terminal: raw mode, keyboard/mouse event loop.
In pipe-safe mode: spins rendering frames (read-event returns nil).

Verified running: frames render correctly with borders, tabs, content,
status bar, and event counter.
2026-05-12 01:15:11 +00:00
Hermes
26b1aaf36d v0.15.0: Rewrite demo, update README, fix read-raw-byte buffer, export textarea-lines
Demo (demo.lisp):
  - Full interactive demo with 3 tabs: Home, Widgets, Console
  - Uses read-event/SGR mouse paths (exercises real terminal input)
  - Demonstrates text-input, textarea, backend drawing, tab navigation
  - Event log console shows keyboard and mouse events in real time
  - Proper terminal cleanup via shutdown-backend + unwind-protect

README.org:
  - Complete rewrite with getting-started guide, architecture overview
  - API reference for all components with signatures and examples
  - Event loop pattern, layout system, rendering pipeline docs
  - Backend features table, development guide, project structure

Bug fixes:
  - read-raw-byte (input.lisp:89-109): use sb-sys:with-pinned-objects +
    vector-sap for proper sb-posix:read buffer handling (SBCL type error
    with plain (unsigned-byte 8) arrays)
  - input-package.lisp: export textarea-lines (was missing from package)

Version bump: v0.14.0 → v0.15.0

392 tests pass.
2026-05-12 01:08:26 +00:00
Hermes
abf8e5cdeb Backport round-2 fixes to org source files
org/text-input.org: remove (declare (ignore w)) from textarea render;
  add truncation to text-input render (subseq display 0 w)
org/mouse.org: hit-test now uses component-layout-node and recurses
  into children for deepest-match hit testing
org/select.org: render reads layout-node-x/y instead of hardcoded (0,0)
org/scrollbox-tabbar.org: tabbar render reads layout-node-x/y
  instead of hardcoded (0,0); x-pos starts at x offset

All 4 org files tangled clean. 392 tests pass.
2026-05-12 01:00:17 +00:00
Hermes
a294f21c70 Subagent review fixes: textarea ignore-w, hit-test recursion, select/tabbar position, X10 release, CSI param < digit, text-input truncation
CRITICAL: Remove (declare (ignore w)) from textarea render (textarea.lisp:251)
  w is used for horizontal truncation on the next line.  Declaring it
  ignored while using it is undefined behavior in CL (SBCL warns).

HIGH: hit-test recurses into children (mouse.lisp:18-34)
  Was returning the root component for any click within its bounds,
  ignoring nested widgets entirely.  Now checks component-children
  first, returning the deepest match.

MEDIUM: Select/TabBar position hardcoded to (0,0)
  Both rendered at terminal origin regardless of layout position.
  Now read layout-node-x/y for absolute positioning.

MEDIUM: Text-input truncation missing
  Render drew full value string even when exceeding widget width.
  Now truncates to (min (length display) w).

MEDIUM: X10 mouse release detection added (input.lisp:219-226)
  X10 encoding uses button=3 for release.  Was detecting all events
  as press/drag.  Now checks button=3 → :release.

MEDIUM: parse-csi-params handles private markers (input.lisp:128-131)
  < = > ? characters (0x3c-0x3f) treated as parameter start markers
  instead of accumulating bogus digit values.  Latent trap removed.

Deferred (pre-existing design):
- Scrollbox visibility cy vs orig-y: match for column layout (common case)
- Nested scrollbox coordinates: assumes sequential layout positions
- text-input cursor drawing: feature, not bugfix

392 tests pass.
2026-05-12 00:55:03 +00:00