csi: implement cursor query and respones

This commit is contained in:
Daniel Eklöf 2019-06-23 18:17:36 +02:00
parent b0a2c54fe8
commit ec9b343550
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

29
csi.c
View file

@ -405,6 +405,35 @@ csi_dispatch(struct terminal *term, uint8_t final)
LOG_WARN("ignoring CSI with final 't'");
break;
case 'n': {
if (term->vt.params.idx > 0) {
int param = term->vt.params.v[0].value;
switch (param) {
case 6: {
/* u7 - cursor position query */
/* TODO: we use 0-based position, while the xterm
* terminfo says the receiver of the reply should
* decrement, hence we must add 2 */
char reply[64];
snprintf(reply, sizeof(reply), "\x1b[%d;%dR",
term->grid.cursor.row + 2, term->grid.cursor.col + 2);
write(term->ptmx, reply, strlen(reply));
break;
}
default:
LOG_ERR("CSI: unimplemented parameter for 'n': %d", param);
return false;
}
return true;
} else {
LOG_ERR("CSI: missing parameter for 'n'");
return false;
}
break;
}
case '=':
/*
* TODO: xterm's terminfo specifies *both* \e[?1h *and*