summary refs log tree commit diff
path: root/home
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-07-16 12:21:13 -0400
committerJune McEnroe <june@causal.agency>2017-07-16 12:21:13 -0400
commit74761bb17339761bfd63e355163427365d95ad88 (patch)
treee88b4f1022c2e157b7bb941b340becae03a54079 /home
parentSort dtch includes (diff)
downloadsrc-74761bb17339761bfd63e355163427365d95ad88.tar.gz
src-74761bb17339761bfd63e355163427365d95ad88.zip
Send ^L on attach, rmcup reset on detach
Diffstat (limited to 'home')
-rwxr-xr-xhome/.bin/dtch.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/home/.bin/dtch.c b/home/.bin/dtch.c
index bed6bc29..ac7164fd 100755
--- a/home/.bin/dtch.c
+++ b/home/.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);