Skip to content

Commit

Permalink
[automaton] extract older XTerm versions #2252
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Oct 10, 2021
1 parent 69db355 commit 0450951
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/lib/in.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,12 +947,32 @@ da1_attrs_cb(inputctx* ictx){
return 1;
}

// we use secondary device attributes to recognize the alacritty crate
// version, and to ascertain the version of old, pre-XTVERSION XTerm.
static int
da2_cb(inputctx* ictx){
loginfo("read secondary device attributes\n");
if(ictx->initdata == NULL){
return 2;
}
amata_next_numeric(&ictx->amata, "\x1b[>", ';');
unsigned pv = amata_next_numeric(&ictx->amata, "", ';');
int maj, min, patch;
if(pv == 0){
return 2;
}
if(ictx->initdata->qterm == TERMINAL_XTERM){
if(ictx->initdata->version == NULL){
char ver[8];
int s = snprintf(ver, sizeof(ver), "%u", pv);
if(s < 0 || (unsigned)s >= sizeof(ver)){
logerror("bad version: %u\n", pv);
}else{
ictx->initdata->version = strdup(ver);
}
return 2;
}
}
// SDA yields up Alacritty's crate version, but it doesn't unambiguously
// identify Alacritty. If we've got any other version information, don't
// use this. use the second parameter (Pv).
Expand All @@ -968,12 +988,6 @@ da2_cb(inputctx* ictx){
termname ? termname : "unset");
return 2;
}
amata_next_numeric(&ictx->amata, "\x1b[>", ';');
unsigned pv = amata_next_numeric(&ictx->amata, "", ';');
int maj, min, patch;
if(pv == 0){
return 2;
}
maj = pv / 10000;
min = (pv % 10000) / 100;
patch = pv % 100;
Expand Down

0 comments on commit 0450951

Please sign in to comment.