commit d5a014f1bdb047b6fbfa34e4e2354f121033aeff
Author:     Jan Klemkow <[email protected]>
AuthorDate: Sat Apr 18 23:13:27 2020 +0200
Commit:     Jan Klemkow <[email protected]>
CommitDate: Sat Apr 18 23:13:27 2020 +0200

    ptty: add detection of cursor position question
    
    always return 1,1 for now

diff --git a/ptty.c b/ptty.c
index 0c30fd5..ca3eb85 100644
--- a/ptty.c
+++ b/ptty.c
@@ -121,9 +121,19 @@ main(int argc, char *argv[])
                }
 
                if (pfd[1].revents & POLLIN) {
-                       if ((n = read(mfd, buf, sizeof buf)) == -1)
+                       if ((n = read(mfd, buf, sizeof(buf)-1)) == -1)
                                die("read:");
+
                        if (n == 0) break;
+
+                       buf[n] = '\0';
+
+                       /* handle cursor position request */
+                       if (strcmp("\033[6n", buf) == 0) {
+                               dprintf(mfd, "\033[%d;%dR", 1, 1);
+                               break;
+                       }
+
                        if (write(STDOUT_FILENO, buf, n) == -1)
                                die("write:");
                }

Reply via email to