opentui
opentui copied to clipboard
Feature Request: add support for highlighting ANSI text as colored text
Currently opencode has no way to show colors for commands outputs because we do not have ANSI highlighting support
My idea for implementing this would be to
- Parse ANSI into an array of colored segments
- Convert this array into a list of
TextChunklike we do now for tree sitter highlighting
I guess ANSI parsing would need to be fast so implemented in the Zig side
What do you think @kommander?
I think opencode would solve that with something like #166, but probably using libghostty-vt.
I also found this project which would be a good start: https://github.com/coder/ghostty-web
It uses libghostty to render a terminal in the browser
Yeah that's basically what #166 does for opentui, but also providing it as a TerminalRenderable. So that but libghostty would be the way to go imo.
I found another example https://github.com/kcosr/pty-to-html/blob/main/src/main.zig
I can open a PR to add support for this, but without any stdin handling, just rendering the ansi into styled text without keeping any state
It would depend on some ghostty code. what do you think?
I created a package to use ghostty-vt to turn ANSI into opentui renderables here
https://github.com/remorses/opentui-ansi-vt.git