Closed joshtriplett closed 8 years ago
Good shit :+1:
Is there a capability query for this or can we use it at all times and assume everything supports it?
Not every terminal supports it, no. And unfortunately, termcap and terminfo don't provide a capability to detect this support. A wide range of terminals support it, but not all terminals.
Perhaps you could add an option to support it, and attempt to autodetect when you can enable that option based on TERM and other environment variables? Not pleasant, though.
If we'd be going the $TERM
route, which terminals support it?
@nabijaczleweli After doing some further searching, it turns out that an unofficial terminfo capability "tc" exists to identify terminals with truecolor support. See http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002260.html . Unfortunately, very few terminals actually list that capability.
See https://gist.github.com/XVilka/8346728 for a list of terminals supporting truecolor. Unfortunately, you can't easily identify all of them by TERM, since some use the same TERM string; many terminals identify themselves as TERM=xterm. I think you can assume truecolor if you see VTEVERSION set (to any value), or TERM set to xterm-256color, vte, vte-, konsole, konsole-_ , and probably many others. This seems like an unfortunate whitelist to have to maintain. :(
@joshtriplett Could you verify the current HEAD
(by modifying main.rs#28
to write_ansi_256()
) works?
That doesn't work; it looks like you forgot the 'm' at the end, and the text to set the background color of.
I'd highly recommend not writing ANSI sequences by hand, and instead using the ansi_term
crate.
(Also, it looks like you called the function write_ansi_265
. And in any case, 256
wouldn't be accurate either; you probably want something like truecolor
or 24bit
.)
Retry, please?
That works.
Some terminals support truecolor escape sequences.
ansi_term
supports those; with them, you can render the exact pixel color from the image. (http://invisible-island.net/xterm/ctlseqs/ctlseqs.html documents the escape sequences, though I'd suggest usingansi_term
rather than writing them directly.)