[terminfo] add alacritty hack for sixel #1430

pull/1520/head
nick black 3 years ago committed by Nick Black
parent cf3a6317aa
commit 62242f0e41

@ -1138,6 +1138,7 @@ int ncdirect_stream(ncdirect* n, const char* filename, ncstreamcb streamer,
ncvisual_destroy(ncv);
return -1;
}
ncdirect_raster_frame(n, v, (vopts->flags & NCVISUAL_OPTION_HORALIGNED) ? vopts->x : 0);
streamer(ncv, vopts, NULL, curry);
}while(ncvisual_decode(ncv));
ncvisual_destroy(ncv);

@ -371,6 +371,12 @@ typedef struct tinfo {
bool pixel_query_done; // have we yet performed pixel query?
bool sextants; // do we have (good, vetted) Unicode 13 sextant support?
bool braille; // do we have Braille support? (linux console does not)
// alacritty went rather off the reservation for their sixel support. they
// reply to DSA with CSI?6c, meaning VT102, but no VT102 had Sixel support,
// and indeed they don't respond to XTSMGRAPHICS (which we need to query
// after validating basic Sixel). so if the TERM variable contains
// "alacritty", *and* we get VT102, we go ahead and query XTSMGRAPHICS.
bool alacritty_sixel_hack;
} tinfo;
typedef struct ncinputlayer {

@ -67,6 +67,8 @@ apply_term_heuristics(tinfo* ti, const char* termname){
set_pixel_blitter(kitty_blit);
/*}else if(strstr(termname, "alacritty")){
ti->sextants = true; // alacritty https://github.com/alacritty/alacritty/issues/4409 */
}else if(strstr(termname, "alacritty")){
ti->alacritty_sixel_hack = true;
}else if(strstr(termname, "vte") || strstr(termname, "gnome") || strstr(termname, "xfce")){
ti->sextants = true; // VTE has long enjoyed good sextant support
}else if(strncmp(termname, "foot", 4) == 0){
@ -319,17 +321,22 @@ setup_sixel(tinfo* ti){
// query for Sixel support
static int
query_sixel(tinfo* ti, int fd){
fprintf(stderr, "SIXEL QUERY!\n");
if(writen(fd, "\x1b[c", 3) != 3){
return -1;
}
char in;
// perhaps the most lackadaisical response is that of st, which returns a
// bare ESC[?6c (note no semicolon).
// bare ESC[?6c (note no semicolon). this is equivalent to alacritty's
// return, both suggesting a VT102. alacritty's miraculous technicolor VT102
// can display sixel, but real VT102s can even reply to XTSMGRAPHICS, so we
// detect VT102 + TERM including alacritty, and special-case that.
enum {
WANT_CSI,
WANT_QMARK,
WANT_SEMI,
WANT_C,
WANT_VT102_C,
DONE
} state = WANT_CSI;
// we're looking for a 4 following a semicolon
@ -350,6 +357,18 @@ query_sixel(tinfo* ti, int fd){
state = WANT_C;
}else if(in == 'c'){
state = DONE;
}else if(in == '6'){
state = WANT_VT102_C;
}
break;
case WANT_VT102_C:
if(in == 'c'){
if(ti->alacritty_sixel_hack){
setup_sixel(ti);
}
state = DONE;
}else if(in == ';'){
state = WANT_C;
}
break;
case WANT_C:

Loading…
Cancel
Save