summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2017-07-16 12:21:13 -0400
committerJune McEnroe <programble@gmail.com>2017-07-16 12:21:13 -0400
commit9fce56ebefa02ca5e310f568dc513d83fa61b6f7 (patch)
tree45bedc32513dbf241194292cda79ddf0bf517c35
parentSort dtch includes (diff)
downloadsrc-9fce56ebefa02ca5e310f568dc513d83fa61b6f7.tar.gz
src-9fce56ebefa02ca5e310f568dc513d83fa61b6f7.zip
Send ^L on attach, rmcup reset on detach
Diffstat (limited to '')
-rwxr-xr-xcurtis/.bin/dtch.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/curtis/.bin/dtch.c b/curtis/.bin/dtch.c
index bed6bc29..ac7164fd 100755
--- a/curtis/.bin/dtch.c
+++ b/curtis/.bin/dtch.c
@@ -165,6 +165,10 @@ static struct termios saveTerm;
 
 static void restoreTerm(void) {
     tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm);
+    printf(
+        "\x1b[?1049l" // rmcup
+        "\x1b\x63\x1b[!p\x1b[?3;4l\x1b[4l\x1b>" // reset
+    );
 }
 
 static int atch(int argc, char *argv[]) {
@@ -199,14 +203,19 @@ static int atch(int argc, char *argv[]) {
     error = tcsetattr(STDERR_FILENO, TCSADRAIN, &raw);
     if (error) err(EX_IOERR, "tcsetattr(%d)", STDERR_FILENO);
 
+    char ctrlL = CTRL('L');
+    ssize_t len = write(master, &ctrlL, 1);
+    if (len < 0) err(EX_IOERR, "write(%d)", master);
+
     struct pollfd fds[2] = {
         { .fd = STDIN_FILENO, .events = POLLIN },
         { .fd = master, .events = POLLIN },
     };
 
-    char buf[4096];
-    ssize_t len;
     while (0 < poll(fds, 2, -1)) {
+        char buf[4096];
+        ssize_t len;
+
         if (fds[0].revents) {
             len = read(STDIN_FILENO, buf, sizeof(buf));
             if (len < 0) err(EX_IOERR, "read(%d)", STDIN_FILENO);