Skip to content

feat(ui): add textview, read-only text that selects, copies and colors - #36

Merged
1lck merged 1 commit into
mainfrom
feat/ui-textview
Nov 18, 2026
Merged

1lck merged 1 commit into
mainfrom
feat/ui-textview

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 17, 2026 •

Copy link
Copy Markdown

The same branch as vivaui#337, opened against the fork's main as well. It has two commits on 82a3318, which is already on fork main, so merging it brings in nothing else: 3724c4f adds the package, and 0e17e51 answers the upstream review by giving links and trail buttons identities of their own (Handlers.Parts).

It adds ui/textview, a read-only text view that can be selected, copied and colored. It covers process output, logs and record details. Lithe currently keeps its own copy in desktop/internal/textview (1lck/Lithe-IDEA#2085, for 1lck/Lithe-IDEA#2073). Once this is on fork main and the Lithe pin includes it, Lithe can import github.com/vivaui/viva/ui/textview and delete that copy.

The upstream PR has the full description, the verification, benchmarks and screenshots. In short, on macOS 27 / arm64:

  • gofmt and go vet ./... are clean.
  • go test ./... -count=1 passes in 92 packages. cmd/viva fails the same way without this change, because of the local toolchain (min_system 12.0 vs macOS 13.0).
  • go vet ./ui/textview/ is clean for windows/amd64, windows/arm64, linux/amd64 and js/wasm.
  • On upstream dde7a5b, the internal/layering tests pass with the package added.

If upstream asks for changes, the same branch is updated, so both PRs stay in step.

Process output, logs and the details of a record are text a user reads and
copies but never edits. A code editor in read-only mode is too heavy for
that, and components.TextSelection is only the selection model, so each app
ends up writing its own view.

ui/textview draws such text on the fixed-pitch grid, only the rows in view
when it scrolls, colors and links runs of it through spans, and takes the
selection a code editor takes: a drag across lines that scrolls past an
edge, a double click for a word, a triple click for a line, Shift with a
click to extend, Primary+C to copy, Primary+A to select everything and
Escape to drop it. A link opens on a click and selects on a drag. A trail
after a line (a note or a button) is never selected or copied.

Painting costs the same for 100 lines and 100000: one allocation of 48 B
per frame on Apple Silicon.
@1lck
1lck marked this pull request as ready for review November 18, 2026 03:37
@1lck
1lck merged commit 113224d into main Nov 18, 2026
12 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants