diff --git a/src/info/main.c b/src/info/main.c index f91fcb4c9..85437f78a 100644 --- a/src/info/main.c +++ b/src/info/main.c @@ -400,6 +400,7 @@ tinfo_debug_styles(const notcurses* nc, struct ncplane* n, const char* indent){ tinfo_debug_cap(n, "u7", get_escape(ti, ESCAPE_U7)); tinfo_debug_cap(n, "ccc", ti->caps.can_change_colors); tinfo_debug_cap(n, "rgb", ti->caps.rgb); + tinfo_debug_cap(n, "csr", get_escape(ti, ESCAPE_CSR)); finish_line(n); ncplane_putstr(n, indent); tinfo_debug_cap(n, "utf8", ti->caps.utf8); @@ -408,6 +409,7 @@ tinfo_debug_styles(const notcurses* nc, struct ncplane* n, const char* indent){ tinfo_debug_cap(n, "braille", ti->caps.braille); tinfo_debug_cap(n, "images", notcurses_canopen_images(nc)); tinfo_debug_cap(n, "video", notcurses_canopen_videos(nc)); + tinfo_debug_cap(n, "indn", get_escape(ti, ESCAPE_INDN)); finish_line(n); } diff --git a/src/lib/fbuf.h b/src/lib/fbuf.h index d5a95f70a..da90bb394 100644 --- a/src/lib/fbuf.h +++ b/src/lib/fbuf.h @@ -282,7 +282,9 @@ static inline int fbuf_flush(fbuf* f, FILE* fp){ int ret = 0; if(f->used){ - if(blocking_write(fileno(fp), f->buf, f->used)){ + if(fflush(fp) == EOF){ + ret = -1; + }else if(blocking_write(fileno(fp), f->buf, f->used)){ ret = -1; } } @@ -296,7 +298,9 @@ static inline int fbuf_finalize(fbuf* f, FILE* fp){ int ret = 0; if(f->used){ - if(blocking_write(fileno(fp), f->buf, f->used)){ + if(fflush(fp) == EOF){ + ret = -1; + }else if(blocking_write(fileno(fp), f->buf, f->used)){ ret = -1; } } diff --git a/src/lib/render.c b/src/lib/render.c index 059f6347e..3c5171652 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -935,8 +935,22 @@ rasterize_scrolls(ncpile* p, fbuf* f){ return -1; } } - while(p->scrolls){ - if(fbuf_putc(f, '\n') < 0){ + if(p->scrolls > 1){ + const char* indn = get_escape(&p->nc->tcache, ESCAPE_INDN); + if(indn){ + if(fbuf_emit(f, tiparm(indn, p->scrolls)) < 0){ + return -1; + } + p->scrolls = 0; + return 0; + } + } + const char* ind = get_escape(&p->nc->tcache, ESCAPE_IND); + if(ind == NULL){ + ind = "\v"; + } + while(p->scrolls > 0){ + if(fbuf_emit(f, ind) < 0){ return -1; } --p->scrolls; diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 8a4170e56..7331d755a 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -775,7 +775,10 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut { ESCAPE_RMUL, "rmul", }, { ESCAPE_SC, "sc", }, { ESCAPE_RC, "rc", }, + { ESCAPE_IND, "ind", }, + { ESCAPE_INDN, "indn", }, { ESCAPE_CLEAR, "clear", }, + { ESCAPE_CSR, "csr", }, { ESCAPE_OC, "oc", }, { ESCAPE_RMKX, "rmkx", }, { ESCAPE_U7, "u7", }, diff --git a/src/lib/termdesc.h b/src/lib/termdesc.h index 9efb46a7d..aee303620 100644 --- a/src/lib/termdesc.h +++ b/src/lib/termdesc.h @@ -60,12 +60,15 @@ typedef enum { ESCAPE_SMULX, // "Smulx" deparameterized: start extended underline ESCAPE_SMULNOX, // "Smulx" deparameterized: kill underline ESCAPE_RMXX, // "rmxx" end struckout + ESCAPE_IND, // "ind" scroll 1 line up + ESCAPE_INDN, // "indn" scroll n lines up ESCAPE_SC, // "sc" push the cursor onto the stack ESCAPE_RC, // "rc" pop the cursor off the stack ESCAPE_CLEAR, // "clear" clear screen and home cursor ESCAPE_INITC, // "initc" set up palette entry ESCAPE_GETM, // "getm" get mouse events ESCAPE_U7, // "u7" cursor position report + ESCAPE_CSR, // "csr" change scroll region // Application synchronized updates, not present in terminfo // (https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec) ESCAPE_BSUM, // Begin Synchronized Update Mode