Themes (slate/dialog/midnight) and their lipgloss styles, Paint/Outer, ListState and the text helpers that yet, yavebu and yalsh menuconfig each carried as a hand-kept copy (yavebu's had already drifted). Values are yet's (grey slate); Paint is menuconfig's profile-aware version. Own go.mod and tui/vX.Y.Z tags keep Charm out of the main module. Programs are not switched yet; tui/README.md has the steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
4.1 KiB
Markdown
80 lines
4.1 KiB
Markdown
# yetano.dev/yetano/core/tui
|
|
|
|
The shared kernel of the Yetano terminal UIs, on Charm v2
|
|
(`charm.land/lipgloss/v2`). It is the code that yet's TUI
|
|
(`yet/internal/tui`), yavebu's TUI (`yavebu/internal/tui`) and yalsh's
|
|
menuconfig (`yalsh/cli/internal/menuconfig`) each carried as a hand-kept
|
|
copy -- and that had already started to drift (yavebu's slate theme kept
|
|
two blue-tinted greys that render dark blue without truecolor; yet and
|
|
yavebu kept an older, truecolor-only `paint`).
|
|
|
|
```text
|
|
module yetano.dev/yetano/core/tui tags: tui/v0.1.0, ... go 1.25
|
|
```
|
|
|
|
A nested module of the core repository, like `core/gui`, so the main core
|
|
module stays free of Charm. Depends only on lipgloss v2 (and
|
|
`colorprofile` in tests); no bubbletea, no bubbles.
|
|
|
|
```sh
|
|
GOPRIVATE=teruna.dev,yetano.dev,yalsh.dev go get yetano.dev/yetano/core/tui@tui/v0.1.0
|
|
```
|
|
|
|
## API
|
|
|
|
| | |
|
|
|---|---|
|
|
| `Theme`, `ThemeByName(name)`, `ThemeNames`, `ValidTheme`, `NormalizeThemeName`, `NextThemeName` | the three themes `slate` (default), `dialog`, `midnight`; F2 cycles them |
|
|
| `Theme.Styles() Styles` | the 21 lipgloss styles (Root, Header, Info, Panel, PanelAlt, ListItem, ListSelected, Search, Footer, Key, Value, ...) |
|
|
| `Paint(block, fg, bg, width)` | re-grounds a pre-styled block on its area's colors after every SGR reset and pads each line (menuconfig's profile-aware version) |
|
|
| `Outer(style, w, h)` | sizes a style so the rendered block, border and padding included, is exactly w x h |
|
|
| `ListState{Filtered, Cursor, Scroll}` with `Rebuild`, `Move`, `ClampScroll`, `Index` | filtered list with cursor and scroll window |
|
|
| `Truncate`, `TruncateBlock`, `WrapStyled`, `KeyValue`, `FirstNonEmpty` | text helpers; `Truncate` counts runes, not cells (unchanged behavior) |
|
|
|
|
The values are byte-identical to yet's `theme.go` (= menuconfig's). The
|
|
exported names are the former unexported ones capitalized; `listState`
|
|
fields are exported (`filtered` -> `Filtered`, ...).
|
|
|
|
## Not in the kernel (yet)
|
|
|
|
- The app frame (`render()`: header, info bar, list + detail, search,
|
|
footer): yet, yavebu and menuconfig share the structure, not the code
|
|
(minimum sizes, width ratios, stacking differ). A `Frame` helper is the
|
|
natural next step once a third v2 program needs it.
|
|
- Menus/dialogs, task logs, terminal hand-over (`tea.Exec`), yet's
|
|
Markdown renderer and manual view: each exists in one program only.
|
|
- Standard screens for `manual`/`doctor`/`version`: only yet has a manual
|
|
view; it belongs here once a second program wants it (it would build on
|
|
the JSON form of `core/manual`).
|
|
- yamc (Charm v1, its own Midnight-Commander palette and layout) and yaki
|
|
(no TUI yet) are not consumers.
|
|
|
|
## Migration (per program, when it is next touched)
|
|
|
|
**yet** (`internal/tui`):
|
|
|
|
1. `go get yetano.dev/yetano/core/tui@tui/v0.1.0`.
|
|
2. Delete `theme.go` (keep the package comment elsewhere), `list.go`,
|
|
`paint`/`outer`/`truncate`/`truncateBlock`/`wrapStyled`/`keyValue`/
|
|
`firstNonEmpty` in `view.go`, `ThemeNames`/`ValidTheme` in `app.go`
|
|
(re-export `ThemeNames = coretui.ThemeNames` if the CLI uses it).
|
|
3. Rename call sites: `themeByName` -> `coretui.ThemeByName`,
|
|
`theme.styles()` -> `theme.Styles()`, `paint` -> `coretui.Paint`,
|
|
`listState` -> `coretui.ListState` (`.filtered/.cursor/.scroll` ->
|
|
`.Filtered/.Cursor/.Scroll`, methods capitalized), and so on.
|
|
4. Move `theme_test.go` away (it lives here now). `go test ./...`, then
|
|
look at `yet tui` in Apple Terminal (no truecolor) and a truecolor
|
|
terminal. `Paint` now emits lipgloss's own sequence, which Bubble Tea
|
|
downsamples -- the visible change is that slate stays grey on
|
|
256-color terminals.
|
|
|
|
**yavebu** (`internal/tui`): same steps for `theme.go`, `util.go`
|
|
(`listState`, `paint`, `outer`, `truncate*`, `wrapStyled`, `keyValue`,
|
|
`firstNonEmpty`) and `ThemeNames`/`ValidTheme` in `tui.go`. Intended
|
|
visible change: slate `Panel` `#2A2D33` -> `#2A2A2E` and `SelectedText`
|
|
`#202734` -> `#20242B` (the grey fix yet already has).
|
|
|
|
**yalsh menuconfig**: identical code; whether a `yalsh.dev` program
|
|
imports a `yetano.dev` module is an owner decision -- until then it stays
|
|
a copy.
|