Skip to content

Commit

Permalink
start cleaning up automaton to admit kittykeyboard query #2131
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Aug 31, 2021
1 parent f7a6d14 commit d19b176
Showing 1 changed file with 13 additions and 57 deletions.
70 changes: 13 additions & 57 deletions src/lib/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,8 @@ typedef enum {
STATE_SDA, // secondary DA (CSI > Pp ; Pv ; Pc c)
STATE_SDA_VER, // secondary DA, got semi, reading to next semi
STATE_SDA_DRAIN, // drain secondary DA to 'c'
STATE_DA, // primary DA (CSI ? ... c) OR XTSMGRAPHICS OR DECRPM
STATE_DA_1, // got '1', XTSMGRAPHICS color registers or primary DA
STATE_DA, // primary DA (CSI ? ... c) OR XTSMGRAPHICS OR DECRPM or kittykbd
STATE_DA_1, // got '1', XTSMGRAPHICS color registers or primary DA or kittykbd
STATE_DA_1_SEMI, // got '1;'
STATE_DA_1_0, // got '1;0', XTSMGRAPHICS color registers or VT101
STATE_DA_1_SEMI_2, // got '1;2', XTSMGRAPHICS color reg fail or VT100
Expand Down Expand Up @@ -1247,7 +1247,7 @@ pump_control_read(query_state* inits, unsigned char c){
break;
case STATE_CSI: // terminated by 0x40--0x7E ('@'--'~')
if(c == '?'){
inits->state = STATE_DA; // could also be DECRPM/XTSMGRAPHICS
inits->state = STATE_DA; // could also be DECRPM/XTSMGRAPHICS/kittykbd
}else if(c == '>'){
// SDA yields up Alacritty's crate version, but it doesn't unambiguously
// identify Alacritty. If we've got any other version information, skip
Expand Down Expand Up @@ -1484,65 +1484,24 @@ pump_control_read(query_state* inits, unsigned char c){
// CSI ? 6 2 ; Ps c ("VT220")
// CSI ? 6 3 ; Ps c ("VT320")
// CSI ? 6 4 ; Ps c ("VT420")
// KITTYKBD: CSI ? flags u
case STATE_DA: // return success on end of DA
//fprintf(stderr, "DA: %c\n", c);
if(c == '1'){
inits->state = STATE_DA_1;
}else if(c == '2'){
if(ruts_numeric(&inits->numeric, c)){ // stash for DECRPT
// FIXME several of these numbers could be DECRPM/XTSM/kittykbd. probably
// just want to read number, *then* make transition on non-number.
if(isdigit(c)){
if(ruts_numeric(&inits->numeric, c)){ // stash for DECRPM/XTSM/kittykbd
return -1;
}
inits->state = STATE_SIXEL;
}else if(c == '4' || c == '7'){ // VT132, VT131
inits->state = STATE_DA_DRAIN;
}else if(c == '6'){
inits->state = STATE_DA_6;
}else if(c >= 0x40 && c <= 0x7E){
inits->state = STATE_NULL;
}
break;
case STATE_DA_1:
//fprintf(stderr, "DA1: %c\n", c);
if(c == 'c'){
inits->state = STATE_NULL;
return 1;
}else if(c >= 0x40 && c <= 0x7E){
}else if(c == 'u'){ // kitty keyboard
// FIXME set kitty keyboard flags to inits->numeric
inits->state = STATE_NULL;
}else if(c == ';'){
inits->state = STATE_DA_1_SEMI;
} // FIXME error?
break;
case STATE_DA_1_SEMI:
//fprintf(stderr, "DA1SEMI: %c\n", c);
if(c == '2'){ // VT100 with Advanced Video Option *or* setcregs failure
inits->state = STATE_DA_1_SEMI_2;
}else if(c == '0'){
inits->state = STATE_DA_1_0;
}else if(c >= 0x40 && c <= 0x7E){
inits->state = STATE_NULL;
} // FIXME error?
break;
case STATE_DA_1_SEMI_2:
if(c == 'c'){
inits->state = STATE_NULL;
return 1;
}else if(c == 'S'){
inits->state = STATE_NULL;
inits->state = STATE_SIXEL;
}else if(c >= 0x40 && c <= 0x7E){
inits->state = STATE_NULL;
}
break;
case STATE_DA_1_0:
//fprintf(stderr, "DA_!_0: %c\n", c);
if(c == 'c'){
inits->state = STATE_NULL;
return 1;
}else if(c >= 0x40 && c <= 0x7E){
inits->state = STATE_NULL;
}else if(c == ';'){
inits->state = STATE_SIXEL_CREGS;
} // FIXME error?
break;
case STATE_SIXEL_CREGS:
if(c == 'S'){
//fprintf(stderr, "CREGS: %d\n", inits->numeric);
Expand Down Expand Up @@ -1571,11 +1530,7 @@ pump_control_read(query_state* inits, unsigned char c){
break;
case STATE_SIXEL:
if(c == ';'){
if(inits->numeric == 2026){
inits->state = STATE_APPSYNC_REPORT;
}else{
inits->state = STATE_SIXEL_SEMI1;
}
inits->state = STATE_SIXEL_SEMI1;
}else if(ruts_numeric(&inits->numeric, c)){
return -1;
}else{
Expand All @@ -1584,6 +1539,7 @@ pump_control_read(query_state* inits, unsigned char c){
break;
case STATE_SIXEL_SEMI1:
//fprintf(stderr, "SIXLE`l`: %c\n", c);
// FIXME [0--4] could be DECRPT, will be followed by $
if(c == '0'){
inits->state = STATE_SIXEL_SUCCESS;
}else if(c == '2'){
Expand Down

0 comments on commit d19b176

Please sign in to comment.