From 05fdd0b11712182191887f2722222d81f9ba30d5 Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 20 Jul 2021 18:37:25 -0400 Subject: [PATCH] flush before making SUM decision, to get true value --- src/lib/render.c | 9 +++++---- src/lib/termdesc.c | 26 +++++++++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/lib/render.c b/src/lib/render.c index 21f89c51b..16d39f6ad 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -1126,12 +1126,16 @@ notcurses_rasterize_inner(notcurses* nc, ncpile* p, FILE* out, unsigned* asu){ if(rasterize_core(nc, p, out, 1)){ return -1; } + // need to flush before doing SUMode size check, to update mstrsize + if(ncflush(out)){ + return -1; + } #define MIN_SUMODE_SIZE BUFSIZ if(*asu){ if(nc->rstate.mstrsize >= MIN_SUMODE_SIZE){ const char* endasu = get_escape(&nc->tcache, ESCAPE_ESUM); if(endasu){ - if(fprintf(out, "%s", endasu) < 0){ + if(fprintf(out, "%s", endasu) < 0 || ncflush(out)){ *asu = 0; } }else{ @@ -1142,9 +1146,6 @@ notcurses_rasterize_inner(notcurses* nc, ncpile* p, FILE* out, unsigned* asu){ } } #undef MIN_SUMODE_SIZE - if(ncflush(out)){ - return -1; - } return nc->rstate.mstrsize; } diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 88e2b0827..267473a5e 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -413,6 +413,17 @@ add_smulx_escapes(tinfo* ti, size_t* tablelen, size_t* tableused){ return 0; } +static inline void +kill_escape(tinfo* ti, escape_e e){ + ti->escindices[e] = 0; +} + +static void +kill_appsync_escapes(tinfo* ti){ + kill_escape(ti, ESCAPE_BSUM); + kill_escape(ti, ESCAPE_ESUM); +} + static int add_appsync_escapes_sm(tinfo* ti, size_t* tablelen, size_t* tableused){ if(get_escape(ti, ESCAPE_BSUM)){ @@ -496,8 +507,9 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd, if(add_pushcolors_escapes(ti, tablelen, tableused)){ return -1; } - // FIXME remove synchronization mode; it's still broken in 0.21.2, and we - // don't need it anyway + // kitty SUM doesn't want long sequences, which is exactly where we use + // it. remove support (we pick it up from queries). + kill_appsync_escapes(ti); }else if(qterm == TERMINAL_ALACRITTY){ termname = "Alacritty"; ti->caps.quadrants = true; @@ -801,17 +813,17 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8, } } } + if(appsync_advertised){ + if(add_appsync_escapes_sm(ti, &tablelen, &tableused)){ + goto err; + } + } bool invertsixel = false; if(apply_term_heuristics(ti, termname, fd, qterm, &tablelen, &tableused, &invertsixel)){ ncinputlayer_stop(&ti->input); goto err; } - if(appsync_advertised){ - if(add_appsync_escapes_sm(ti, &tablelen, &tableused)){ - goto err; - } - } build_supported_styles(ti); // our current sixel quantization algorithm requires at least 64 color // registers. we make use of no more than 256. this needs to happen