opentui icon indicating copy to clipboard operation
opentui copied to clipboard

Feature Request: add support for highlighting ANSI text as colored text

Open remorses opened this issue 2 weeks ago • 4 comments

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 TextChunk like 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?

remorses avatar Nov 19 '25 13:11 remorses

I think opencode would solve that with something like #166, but probably using libghostty-vt.

kommander avatar Nov 19 '25 17:11 kommander

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

remorses avatar Nov 19 '25 19:11 remorses

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.

kommander avatar Nov 20 '25 00:11 kommander

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?

remorses avatar Nov 25 '25 16:11 remorses

I created a package to use ghostty-vt to turn ANSI into opentui renderables here

https://github.com/remorses/opentui-ansi-vt.git

remorses avatar Nov 27 '25 10:11 remorses