mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
query_sixel: support alacritty's ugh decisions #1430
This commit is contained in:
parent
0c2e3d6e35
commit
7865539505
@ -305,6 +305,17 @@ query_sixel_details(tinfo* ti, int fd){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we found Sixel support -- set up the API
|
||||||
|
static void
|
||||||
|
setup_sixel(tinfo* ti, int (**pixel_init)(int fd)){
|
||||||
|
ti->sixel_supported = true;
|
||||||
|
ti->color_registers = 256; // assumed default [shrug]
|
||||||
|
*pixel_init = ti->pixel_init = sprite_sixel_init;
|
||||||
|
ti->pixel_draw = sixel_draw;
|
||||||
|
ti->sixel_maxx = ti->sixel_maxy = 0;
|
||||||
|
ti->pixel_destroy = sixel_delete;
|
||||||
|
}
|
||||||
|
|
||||||
// query for Sixel support
|
// query for Sixel support
|
||||||
static int
|
static int
|
||||||
query_sixel(tinfo* ti, int fd){
|
query_sixel(tinfo* ti, int fd){
|
||||||
@ -320,8 +331,12 @@ query_sixel(tinfo* ti, int fd){
|
|||||||
WANT_QMARK,
|
WANT_QMARK,
|
||||||
WANT_SEMI,
|
WANT_SEMI,
|
||||||
WANT_C,
|
WANT_C,
|
||||||
|
WANT_C_ALACRITTY_HACK,
|
||||||
DONE
|
DONE
|
||||||
} state = WANT_CSI;
|
} state = WANT_CSI;
|
||||||
|
// we're looking for a 4 following a semicolon, or alacritty's insistence
|
||||||
|
// on CSI 6c followed by XTSMGRAPHICS, which probably breaks us on a real
|
||||||
|
// VT102, but how many of them could there be? le sigh FIXME
|
||||||
while(read(fd, &in, 1) == 1){
|
while(read(fd, &in, 1) == 1){
|
||||||
switch(state){
|
switch(state){
|
||||||
case WANT_CSI:
|
case WANT_CSI:
|
||||||
@ -339,20 +354,22 @@ query_sixel(tinfo* ti, int fd){
|
|||||||
state = WANT_C;
|
state = WANT_C;
|
||||||
}else if(in == 'c'){
|
}else if(in == 'c'){
|
||||||
state = DONE;
|
state = DONE;
|
||||||
|
}else if(in == '6'){
|
||||||
|
state = WANT_C_ALACRITTY_HACK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WANT_C:
|
case WANT_C:
|
||||||
if(in == 'c'){
|
if(in == 'c'){
|
||||||
state = DONE;
|
state = DONE;
|
||||||
}else if(in == '4'){
|
}else if(in == '4'){
|
||||||
if(!ti->sixel_supported){
|
setup_sixel(ti, &pixel_init);
|
||||||
ti->sixel_supported = true;
|
state = DONE;
|
||||||
ti->color_registers = 256; // assumed default [shrug]
|
}
|
||||||
pixel_init = ti->pixel_init = sprite_sixel_init;
|
break;
|
||||||
ti->pixel_draw = sixel_draw;
|
case WANT_C_ALACRITTY_HACK:
|
||||||
ti->sixel_maxx = ti->sixel_maxy = 0;
|
if(in == 'c'){
|
||||||
ti->pixel_destroy = sixel_delete;
|
setup_sixel(ti, &pixel_init);
|
||||||
}
|
state = DONE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DONE:
|
case DONE:
|
||||||
|
Loading…
Reference in New Issue
Block a user