From e909e6d6e9be0a25b4c48f0fa341c8ef8baf89bc Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 22 Jun 2021 14:13:16 -0400 Subject: [PATCH] gimme that appsync support #1582 --- src/lib/debug.c | 5 +++-- src/lib/input.c | 26 ++++++++++++++++++++++++-- src/lib/termdesc.c | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/lib/debug.c b/src/lib/debug.c index 6eeb40f540..e55203ae6d 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -51,10 +51,11 @@ static void tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols, unsigned images, unsigned videos){ const char indent[] = " "; - fprintf(debugfp, "%scolors: %u rgb: %c ccc: %c setaf: %c setab: %c\n", + fprintf(debugfp, "%scolors: %u rgb: %c ccc: %c setaf: %c setab: %c app-sync: %c\n", indent, ti->caps.colors, capbool(ti->caps.rgb), capbool(ti->caps.can_change_colors), capyn(get_escape(ti, ESCAPE_SETAF)), - capyn(get_escape(ti, ESCAPE_SETAB))); + capyn(get_escape(ti, ESCAPE_SETAB)), + capyn(get_escape(ti, ESCAPE_BSU))); fprintf(debugfp, "%ssgr: %c sgr0: %c op: %c fgop: %c bgop: %c\n", indent, capyn(get_escape(ti, ESCAPE_SGR)), capyn(get_escape(ti, ESCAPE_SGR0)), diff --git a/src/lib/input.c b/src/lib/input.c index 2a49188754..b39a77d06d 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -646,6 +646,8 @@ typedef enum { STATE_SIXEL_HEIGHT, // reading maximum sixel height until 'S' STATE_SIXEL_CREGS, // reading max color registers until 'S' STATE_XTSMGRAPHICS_DRAIN, // drain out XTSMGRAPHICS to 'S' + STATE_APPSYNC_REPORT, // got DECRPT ?2026 + STATE_APPSYNC_REPORT_DRAIN, // drain out decrpt to 'y' } initstates_e; typedef struct query_state { @@ -817,7 +819,7 @@ stash_string(query_state* inits){ // ought be fed to the machine, and -1 on an invalid state transition. static int pump_control_read(query_state* inits, unsigned char c){ -//fprintf(stderr, "state: %2d char: %1c %3d %02x\n", inits->state, isprint(c) ? c : ' ', c, c); +fprintf(stderr, "state: %2d char: %1c %3d %02x\n", inits->state, isprint(c) ? c : ' ', c, c); if(c == NCKEY_ESC){ inits->state = STATE_ESC; return 0; @@ -1006,6 +1008,9 @@ pump_control_read(query_state* inits, unsigned char c){ if(c == '1'){ inits->state = STATE_DA_1; }else if(c == '2'){ + if(ruts_numeric(&inits->numeric, c)){ // stash for DECRPT + return -1; + } inits->state = STATE_SIXEL; }else if(c == '4' || c == '7'){ // VT132, VT131 inits->state = STATE_DA_DRAIN; @@ -1065,7 +1070,13 @@ pump_control_read(query_state* inits, unsigned char c){ break; case STATE_SIXEL: if(c == ';'){ - inits->state = STATE_SIXEL_SEMI1; + if(inits->numeric == 2026){ + inits->state = STATE_APPSYNC_REPORT; + }else{ + inits->state = STATE_SIXEL_SEMI1; + } + }else if(ruts_numeric(&inits->numeric, c)){ + return -1; }else{ // FIXME error? } @@ -1108,6 +1119,17 @@ pump_control_read(query_state* inits, unsigned char c){ inits->state = STATE_NULL; } break; + case STATE_APPSYNC_REPORT: + if(c == '2'){ + inits->appsync = 1; + inits->state = STATE_APPSYNC_REPORT_DRAIN; + } + break; + case STATE_APPSYNC_REPORT_DRAIN: + if(c == 'y'){ + inits->state = STATE_NULL; + } + break; default: fprintf(stderr, "Reached invalid init state %d\n", inits->state); return -1; diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 7df7cc1304..4cf8156962 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -288,7 +288,7 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd, static int send_initial_queries(int fd){ const char queries[] = CSI_BGQ - "\x1b[?2026$p" // App-Sync Update support + "\x1b[?2026$p" // query for App-sync updates "\x1b[=0c" // Tertiary Device Attributes "\x1b[>0q" // XTVERSION "\x1bP+q544e\x1b\\" // XTGETTCAP['TN']