aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-06-23 16:17:36 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-06-23 16:17:36 +0000
commitec9b3435502c5a46fd34d02a4b5821a2464e53a4 (patch)
tree3ef3eb0cccfdda6931192b2814380d7f3303ef10
parentvt: wip: implement scrolling region (diff)
csi: implement cursor query and respones
-rw-r--r--csi.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/csi.c b/csi.c
index 0200e6a3..a0872466 100644
--- a/csi.c
+++ b/csi.c
@@ -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*