curses icon indicating copy to clipboard operation
curses copied to clipboard

Pass ansi color codes straight through to a curses window?

Open isene opened this issue 4 years ago • 2 comments

Is there a way to output text to a curses window without curses messing with the ansi color codes - I would like the color codes to simply pass through and let the text be colored in the window. I am perfectly aware of how to color text in curses, but I would rather not go through that roundabout when outputting syntax highlighted text to a curses window (like with the command

curses_window << `batcat --color=always #{file}`

... where batcat is the syntax highlighting cousin to cat (also known as just "bat")

isene avatar Oct 21 '20 20:10 isene

I don't know whether there is such a feature in ncurses itself.

You can use Kernel#print to output raw escape sequences, but it breaks redisplay by curses.

shugo avatar Dec 10 '20 09:12 shugo

I went to the roundabout way and wrote a parser for all ansi color sequences as part of my project RTFM

isene avatar Dec 10 '20 10:12 isene