Skip to content

Commit

Permalink
gimme that appsync support #1582
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jun 22, 2021
1 parent 2b6dc8a commit e909e6d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/lib/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
26 changes: 24 additions & 2 deletions src/lib/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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?
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/termdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit e909e6d

Please sign in to comment.