From dc4bb1095ed6170b0d8e1f55cf23bffdb990bee9 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 23 Dec 2021 03:24:39 -0500 Subject: [PATCH] detect rectangular edit support, display in notcurses-info #2498 --- doc/man/man1/notcurses-info.1.md | 9 +++++++-- src/info/main.c | 2 +- src/lib/in.c | 4 ++++ src/lib/in.h | 1 + src/lib/termdesc.c | 5 +++++ src/lib/termdesc.h | 1 + 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/man/man1/notcurses-info.1.md b/doc/man/man1/notcurses-info.1.md index 71737131f..7016d5a80 100644 --- a/doc/man/man1/notcurses-info.1.md +++ b/doc/man/man1/notcurses-info.1.md @@ -45,7 +45,6 @@ The next five lines describe properties of the terminal environment: * af: Foreground color can be set * ab: Background color can be set * sum: Synchronized Update Mode is supported - * cup: Arbitrary cursor moves * vpa: Cursor can be moved to an absolute vertical coordinate * hpa: Cursor can be moved to an absolute horizontal coordinate * sgr0: Styling can be reset via a single escape @@ -53,6 +52,7 @@ The next five lines describe properties of the terminal environment: * fgop: Foreground can be reset via a single escape * bgop: Background can be reset via a single escape * bce: The back-color-erase property is in play + * rect: Rectangular editing is available * The second line is more of the same: * bold: Boldface is available @@ -75,9 +75,11 @@ The next five lines describe properties of the terminal environment: * vid: Video can be decoded * indn: Multiple-line scrolling is available * gpm: Connection is established to the GPM server + * kbd: The Kitty keyboard protocol is in use * The fourth line indicates the default background color, and whether that - color is treated as transparent. + color is treated as transparent by the terminal (only **kitty** is known + to do this), and the default foreground color. * The fifth line describes the available bitmap graphics. If Sixels are available, the maximum number of color registers and maximum Sixel @@ -86,6 +88,9 @@ The next five lines describe properties of the terminal environment: with "rgba graphics are available"; if Kitty's animation support is also present, that will be reported with "rgba pixel animation support". +To the right of this material is the Notcurses homepage's URI, and the +Notcurses logo (the latter only if bitmap graphics are available). + The final eleven lines, only printed when in a UTF8 locale, show various Unicode glyphs. The first four lines include the quadrant, sextant, and box-drawing characters. The next four lines include the entire Braille set. diff --git a/src/info/main.c b/src/info/main.c index 037a80af2..33d3cfe94 100644 --- a/src/info/main.c +++ b/src/info/main.c @@ -422,7 +422,6 @@ tinfo_debug_caps(struct ncplane* n, const tinfo* ti, const char* indent){ tinfo_debug_cap(n, "af", get_escape(ti, ESCAPE_SETAF)); tinfo_debug_cap(n, "ab", get_escape(ti, ESCAPE_SETAB)); tinfo_debug_cap(n, "sum", get_escape(ti, ESCAPE_BSUM)); - tinfo_debug_cap(n, "cup", get_escape(ti, ESCAPE_CUP)); tinfo_debug_cap(n, "vpa", get_escape(ti, ESCAPE_VPA)); tinfo_debug_cap(n, "hpa", get_escape(ti, ESCAPE_HPA)); tinfo_debug_cap(n, "sgr0", get_escape(ti, ESCAPE_SGR0)); @@ -430,6 +429,7 @@ tinfo_debug_caps(struct ncplane* n, const tinfo* ti, const char* indent){ tinfo_debug_cap(n, "fgop", get_escape(ti, ESCAPE_FGOP)); tinfo_debug_cap(n, "bgop", get_escape(ti, ESCAPE_BGOP)); tinfo_debug_cap(n, "bce", ti->bce); + tinfo_debug_cap(n, "rect", get_escape(ti, ESCAPE_DECERA)); finish_line(n); } diff --git a/src/lib/in.c b/src/lib/in.c index a8fd54030..b2e1e7306 100644 --- a/src/lib/in.c +++ b/src/lib/in.c @@ -1082,6 +1082,8 @@ da1_attrs_cb(inputctx* ictx){ if(ictx->initdata->color_registers <= 0){ ictx->initdata->color_registers = 256; } + }else if(curattr == 28){ + ictx->initdata->rectangular_edits = true; } curattr = 0; } @@ -1091,6 +1093,8 @@ da1_attrs_cb(inputctx* ictx){ if(ictx->initdata->color_registers <= 0){ ictx->initdata->color_registers = 256; } + }else if(curattr == 28){ + ictx->initdata->rectangular_edits = true; } if(!foundsixel){ scrub_sixel_responses(ictx->initdata); diff --git a/src/lib/in.h b/src/lib/in.h index 006fb9d22..fc73c9ecb 100644 --- a/src/lib/in.h +++ b/src/lib/in.h @@ -66,6 +66,7 @@ struct initial_responses { bool got_bg; // have we read default background? bool got_fg; // have we read default foreground? bool rgb; // was RGB DirectColor advertised? + bool rectangular_edits; // were rectangular edits advertised? int pixx; // screen geometry in pixels int pixy; // screen geometry in pixels int dimx; // screen geometry in cells diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index a1f7a2eb1..969c2fbb6 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -1327,6 +1327,11 @@ int interrogate_terminfo(tinfo* ti, FILE* out, unsigned utf8, ti->sixel_maxy = iresp->sixely; ti->sixel_maxx = iresp->sixelx; } + if(iresp->rectangular_edits){ + if(grow_esc_table(ti, "\x1b[6n", ESCAPE_DECERA, &tablelen, &tableused)){ + goto err; + } + } free(iresp); if(nocbreak){ // FIXME do this in input later, upon signaling completion? diff --git a/src/lib/termdesc.h b/src/lib/termdesc.h index 6b7c97f48..64a19f5c2 100644 --- a/src/lib/termdesc.h +++ b/src/lib/termdesc.h @@ -84,6 +84,7 @@ typedef enum { ESCAPE_ESUM, // End Synchronized Update Mode ESCAPE_SAVECOLORS, // XTPUSHCOLORS (push palette/fg/bg) ESCAPE_RESTORECOLORS, // XTPOPCOLORS (pop palette/fg/bg) + ESCAPE_DECERA, // rectangular erase ESCAPE_MAX } escape_e;