Merge pull request #5845 from dnmfarrell/dnmfarrell/term-recognize-vt-term-sequences

term: support vt escape sequences
This commit is contained in:
fang 2022-06-17 19:46:18 +02:00 committed by GitHub
commit 1b994e89bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 11 deletions

View File

@ -156,6 +156,7 @@
c3_o mou; // M (for mouse event) received
c3_y ton_y; // mouse button
c3_y col_y; // column coordinate
c3_y seq_y; // vt sequence
} esc;
struct { // input buffering

View File

@ -668,19 +668,39 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y)
//
if ( c3y == tat_u->esc.ape ) {
if ( c3y == tat_u->esc.bra ) {
switch ( cay_y ) {
default: {
_term_it_dump_buf(uty_u, &uty_u->ufo_u.bel_u);
break;
}
case 'A': _term_io_spit(uty_u, u3nc(c3__aro, 'u')); break;
case 'B': _term_io_spit(uty_u, u3nc(c3__aro, 'd')); break;
case 'C': _term_io_spit(uty_u, u3nc(c3__aro, 'r')); break;
case 'D': _term_io_spit(uty_u, u3nc(c3__aro, 'l')); break;
// vt sequence
//
case 'M': tat_u->esc.mou = c3y; break;
if ( cay_y == '~' ) {
switch ( tat_u->esc.seq_y ) {
default: {
_term_it_dump_buf(uty_u, &uty_u->ufo_u.bel_u);
break;
}
case '3': _term_io_spit(uty_u, u3nc(c3__del, u3_nul)); break;
}
tat_u->esc.ape = tat_u->esc.bra = c3n;
tat_u->esc.seq_y = 0;
}
else if ( cay_y <= '9' ) {
tat_u->esc.seq_y = cay_y;
}
// xterm sequence
//
else {
switch ( cay_y ) {
default: {
_term_it_dump_buf(uty_u, &uty_u->ufo_u.bel_u);
break;
}
case 'A': _term_io_spit(uty_u, u3nc(c3__aro, 'u')); break;
case 'B': _term_io_spit(uty_u, u3nc(c3__aro, 'd')); break;
case 'C': _term_io_spit(uty_u, u3nc(c3__aro, 'r')); break;
case 'D': _term_io_spit(uty_u, u3nc(c3__aro, 'l')); break;
//
case 'M': tat_u->esc.mou = c3y; break;
}
tat_u->esc.ape = tat_u->esc.bra = c3n;
}
tat_u->esc.ape = tat_u->esc.bra = c3n;
}
else {
if ( (cay_y >= 'a') && (cay_y <= 'z') ) {