add compare_versions, don't use C=1 with kitty < 0.20.0

pull/1842/head
nick black 3 years ago committed by Nick Black
parent 42fee43cf2
commit afffc96508

@ -151,6 +151,49 @@ void free_terminfo_cache(tinfo* ti){
free(ti->esctable);
}
// compare one terminal version against another. numerics, separated by
// periods, and comparison ends otherwise (so "20.0 alpha" doesn't compare
// as greater than "20.0", mainly). returns -1 if v1 < v2 (or v1 is NULL),
// 0 if v1 == v2, or 1 if v1 > v2.
static int
compare_versions(const char* restrict v1, const char* restrict v2){
if(v1 == NULL){
return -1;
}
while(*v1 && *v2){
if(isdigit(*v1) && isdigit(*v2)){
if(*v1 > *v2){
return 1;
}
if(*v2 > *v1){
return -1;
}
}else if(isdigit(*v1)){
return 1;
}else if(isdigit(*v2)){
return -1;
}else if(*v1 != '.' && *v2 != '.'){
break;
}else if(*v1 != '.' || *v2 != '.'){
if(*v1 == '.'){
return 1;
}else{
return -1;
}
}
++v1;
++v2;
}
// can only get out here if at least one was not a period
if(*v1 == '.'){
return 1;
}
if(*v2 == '.'){
return -1;
}
return 0;
}
// tlen -- size of escape table. tused -- used bytes in same.
// returns -1 if the starting location is >= 65535. otherwise,
// copies tstr into the table, and sets up 1-biased index.
@ -297,6 +340,10 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd,
if(add_smulx_escapes(ti, tablelen, tableused)){
return -1;
}
// kitty only introduced C=1 in 0.20.0
if(compare_versions(ti->termversion, "0.20.0") < 0){
ti->sixel_maxy_pristine = INT_MAX;
}
}else if(qterm == TERMINAL_ALACRITTY){
termname = "Alacritty";
ti->caps.quadrants = true;

@ -970,6 +970,12 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
bargs.u.pixel.cursor_hack = get_escape(&nc->tcache, ESCAPE_CIVIS);
}
}
// if we are kitty prior to 0.20.0, we set NCVISUAL_OPTION_SCROLL so that
// C=1 won't be supplied. we use sixel_maxy_pristine as a side channel to
// encode this version information.
if(nc->tcache.sixel_maxy_pristine){
bargs.flags |= NCVISUAL_OPTION_SCROLL;
}
// FIXME need to pull off the ncpile's sprixellist if anything below fails!
// at this point, disppixy/disppixx are the output geometry (might be larger
// than scaledy/scaledx for sixel), while scaledy/scaledx are the scaled

@ -201,7 +201,7 @@ force_rgba(ncvisual* n){
av_freep(&n->details->frame);
}
}
ncvisual_set_data(n, sframe->data[0], false);
ncvisual_set_data(n, sframe->data[0], true);
}
n->details->frame = sframe;
return 0;
@ -538,7 +538,7 @@ int ffmpeg_resize(ncvisual* n, int rows, int cols){
if(n->owndata){
av_frame_unref(n->details->frame);
}
ncvisual_set_data(n, sframe->data[0], false);
ncvisual_set_data(n, sframe->data[0], true);
n->details->frame = sframe;
//fprintf(stderr, "SIZE SCALED: %d %d (%u)\n", n->details->frame->height, n->details->frame->width, n->details->frame->linesize[0]);
return 0;
@ -566,7 +566,7 @@ int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
}
void ffmpeg_details_seed(ncvisual* ncv){
ncv->details->frame->data[0] = NULL;
ncv->details->frame->data[0] = (uint8_t*)ncv->data;
ncv->details->frame->data[1] = NULL;
ncv->details->frame->linesize[0] = ncv->rowstride;
ncv->details->frame->linesize[1] = 0;

Loading…
Cancel
Save