ptty: add detection of cursor position question - scroll - scrollbackbuffer pro… | |
git clone git://git.suckless.org/scroll | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d5a014f1bdb047b6fbfa34e4e2354f121033aeff | |
parent 8eccc7198b45b63e990c56809015140f4380f272 | |
Author: Jan Klemkow <[email protected]> | |
Date: Sat, 18 Apr 2020 23:13:27 +0200 | |
ptty: add detection of cursor position question | |
always return 1,1 for now | |
Diffstat: | |
M ptty.c | 12 +++++++++++- | |
1 file changed, 11 insertions(+), 1 deletion(-) | |
--- | |
diff --git 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:"); | |
} |