Repository navigation
TUI theme switcher — Delphi-side, modal picker with live preview - #123
Merged
Merged
Conversation
`pasclaw tui --theme <name>` picks the initial theme; typing `/theme`
in the TUI opens a modal menu with Up/Down live-preview, Enter to
apply, Escape to revert. Seven themes from DMVCFramework: `navy`
(default), `matrix`, `sunset`, `ocean`, `midnight`, `classic`,
`default`. Unknown names fall back to navy silently. Changes are
session-only (no persistence) — pass `--theme` on the next run, or
wire a config field in a follow-up.
Approach:
- New unit-scope helpers in PasClaw.TUI's Delphi branch:
THEME_NAMES (constant array — display order),
ResolveTheme(name) -> TConsoleColorStyle,
CanonicalThemeName(name) -> string (case-insensitive lookup + fallback).
- TTUI gains a public ThemeName field (Cmd_TUI_Run forwards from
--theme), an FMenuOpen / FMenuSelIdx / FMenuOrigTheme /
FCurrentTheme state set, plus three methods: ApplyTheme,
OpenThemeMenu, HandleMenuKey, DrawThemeMenu.
- HandleKey intercepts when FMenuOpen, routes to HandleMenuKey;
Escape in menu = revert + close (instead of quitting the TUI),
Enter = commit, Up/Dn = preview-by-applying.
- SubmitInput's slash-command branch grew `/theme` -> OpenThemeMenu.
`/help` flash updated to mention `/theme`.
- DrawFrame draws the menu LAST so the modal sits on top of both
panes. The picker is a 32-col centred box with a title row, a
separator, one row per theme, and the highlighted selection
drawn in ConsoleTheme.Highlight (which itself updates as the
user arrows through).
- ApplyTheme calls SetConsoleTheme (mutates the global ConsoleTheme
record DMVCFramework's WriteAnsiText reads from), ClrScr (drop
stale ink the previous theme's background fill left behind), and
FLastResizeW := -1 to force a full repaint on the next tick.
- Startup replaces the hardcoded `SetConsoleTheme(ConsoleThemeNavy)`
with `SetConsoleTheme(ResolveTheme(CanonicalThemeName(ThemeName)))`
so the --theme flag actually takes effect.
FPC branch deliberately untouched. The FPC line-based renderer uses
Ansi.* constants directly with no theme abstraction — a port would
need its own palette system and isn't in scope. Slash command lookup
on Delphi still flashes "unknown" for the FPC-only legacy
HandleSlashCommand stub (which is dead code on Delphi anyway).
FPC build clean (443730 lines), smoke 11/11 OK. The Delphi branch is
gated by {$IFNDEF FPC} so dcc64 compile + runtime needs a human side
check — I was conservative with the syntax (no inline-var, no
anonymous records, only known-stable DMVCFramework APIs).
Out of scope (deliberate v1 cuts):
- Config persistence (theme survives next start) — needs Cmd.TUI
to thread a write-back to TConfig, ~30 LOC plumbing punted to
follow-up.
- FPC palette — separate PR.
- Per-role colour theming — chat headers stay semantic
(user=cyan, assistant=magenta, tool=yellow); theme only governs
chrome.
- Custom theme files under workspace/themes/ — picoclaw doesn't
have it; seven vendored themes is the v1 surface.
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
This was referenced Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a theme switcher to the Delphi build of
pasclaw tui.--theme <name>picks the initial theme; typing/themein the TUI opens a modal menu with Up/Down live-preview, Enter to apply, Escape to revert. Seven themes from the vendored DMVCFramework:navy(default),matrix,sunset,ocean,midnight,classic,default. Unknown names fall back to navy. Session-only (no persistence — pass--themenext time, or wire a config field in a follow-up).FPC branch deliberately untouched.
What's new
pasclaw tui --theme matrixsets the initial theme./themeopens the modal picker.SetConsoleThemeimmediately, so you see chrome change as you navigate. Escape reverts to the original (the one in effect when the menu opened); Enter commits the highlighted one.Implementation
PasClaw.TUI's Delphi branch:THEME_NAMESconstant array (display order),ResolveTheme(name) → TConsoleColorStyle,CanonicalThemeName(name) → string(case-insensitive lookup + silent fallback).TTUIgains a publicThemeName: string(forwarded fromCmd_TUI_Run),FMenuOpen/FMenuSelIdx/FMenuOrigTheme/FCurrentThemestate, and methodsApplyTheme/OpenThemeMenu/HandleMenuKey/DrawThemeMenu.HandleKeyintercepts whenFMenuOpenand routes toHandleMenuKey. Escape in menu = revert + close (instead of quitting); Enter = commit; Up/Dn = preview-by-applying.SubmitInput's slash branch grew/theme → OpenThemeMenu./helpflash updated to mention it.DrawFramedraws the menu last so the modal sits on top of both panes. Centred 32-col box with title + separator + per-theme rows; highlighted selection rendered inConsoleTheme.Highlight(which itself updates as the user arrows through).ApplyThemecallsSetConsoleTheme(mutates the globalConsoleThemerecord DMVCFramework'sWriteAnsiTextreads), thenClrScr+ setsFLastResizeW := -1to force a full repaint on the next tick — drops stale ink the previous theme's background fill leaves behind.SetConsoleTheme(ConsoleThemeNavy)withSetConsoleTheme(ResolveTheme(CanonicalThemeName(ThemeName)))so the flag actually takes effect.Out of scope (deliberate v1 cuts)
Cmd.TUIto thread a write-back toTConfig(~30 LOC plumbing); follow-up.workspace/themes/— picoclaw doesn't have it; seven vendored themes is the v1 surface.Test plan
make smoke11/11 OK{$IFNDEF FPC}-gated, so FPC build path is unchanged)pasclaw tui --theme matrixstarts in matrix theme,/themeopens the modal, arrows live-preview, Enter commits, Escape reverts. The env this PR was authored in has nodcc64; the changes use only known-stable DMVCFramework APIs (SetConsoleTheme,WriteAnsiText,GotoXY) and no inline-var / anonymous-record patterns.Generated by Claude Code