From 4ed41259c9b74e6cab7a98a8942ed53580bdfe56 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 4 Jul 2021 05:29:55 -0400 Subject: [PATCH] don't emit smkx twice, flatten all initial writes --- src/lib/direct.c | 10 +++++++++- src/lib/notcurses.c | 11 +++++++---- src/lib/render.c | 2 +- src/lib/termdesc.c | 8 -------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/lib/direct.c b/src/lib/direct.c index bb911e87b..f79246bf7 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -834,9 +834,17 @@ ncdirect* ncdirect_core_init(const char* termtype, FILE* outfp, uint64_t flags){ TERMINAL_UNKNOWN, NULL, NULL)){ goto err; } - if(ncvisual_init(NCLOGLEVEL_SILENT)){ + if(ncvisual_init(loglevel)){ goto err; } + // if the keypad neen't be explicitly enabled, smkx is not present + const char* smkx = get_escape(&ret->tcache, ESCAPE_SMKX); + if(smkx){ + if(term_emit(tiparm(smkx), ret->ttyfp, true) < 0){ + fprintf(stderr, "Error entering keypad transmit mode\n"); + goto err; + } + } update_term_dimensions(ret->ctermfd, NULL, NULL, &ret->tcache, 0); ncdirect_set_styles(ret, 0); return ret; diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 2d7d08900..83cd8d875 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1145,6 +1145,10 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){ goto err; } } + if((ret->rstate.mstreamfp = open_memstream(&ret->rstate.mstream, &ret->rstate.mstrsize)) == NULL){ + free_plane(ret->stdplane); + goto err; + } const char* smkx = get_escape(&ret->tcache, ESCAPE_SMKX); if(smkx && term_emit(smkx, ret->ttyfp, false)){ free_plane(ret->stdplane); @@ -1155,13 +1159,12 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){ free_plane(ret->stdplane); goto err; } - if((ret->rstate.mstreamfp = open_memstream(&ret->rstate.mstream, &ret->rstate.mstrsize)) == NULL){ + ret->rstate.x = ret->rstate.y = -1; + int bannerlines = init_banner(ret); + if(ncflush(ret->ttyfp)){ free_plane(ret->stdplane); goto err; } - ret->rstate.x = ret->rstate.y = -1; - int bannerlines = init_banner(ret); - ncflush(ret->ttyfp); if(cursor_y >= 0 && cursor_x >= 0){ cursor_y += bannerlines; if(cursor_y >= ncplane_dim_y(ret->stdplane)){ diff --git a/src/lib/render.c b/src/lib/render.c index 6dcfd1228..4ed8b535f 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -1121,7 +1121,7 @@ raster_and_write(notcurses* nc, ncpile* p, FILE* out){ } // if the last pile was different from this one, we need clear all old // sprixels (and invalidate all those of the current pile -- FIXME). - if(nc->last_pile != p){ + if(nc->last_pile != p && nc->last_pile){ if(sprite_clear_all(&nc->tcache, out)){ return -1; } diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index b41ad04ba..e46f01a2b 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -640,14 +640,6 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8, goto err; } } - // if the keypad neen't be explicitly enabled, smkx is not present - const char* smkx = get_escape(ti, ESCAPE_SMKX); - if(smkx && fd >= 0){ - if(tty_emit(tiparm(smkx), fd) < 0){ - fprintf(stderr, "Error entering keypad transmit mode\n"); - goto err; - } - } // if op is defined as ansi 39 + ansi 49, make the split definitions // available. this ought be asserted by extension capability "ax", but // no terminal i've found seems to do so. =[