summary refs log tree commit diff
path: root/curtis
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2017-07-28 23:44:46 -0400
committerJune McEnroe <programble@gmail.com>2017-07-28 23:44:46 -0400
commit324d7c615ee30c616af731b9b5dbdb942ffa2b02 (patch)
tree3adca38953f372b8db7dbb48ac9ab27067a5765b /curtis
parentInstall sl (diff)
downloadsrc-324d7c615ee30c616af731b9b5dbdb942ffa2b02.tar.gz
src-324d7c615ee30c616af731b9b5dbdb942ffa2b02.zip
Add toggle to hnel
Diffstat (limited to '')
-rwxr-xr-xcurtis/.bin/hnel.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/curtis/.bin/hnel.c b/curtis/.bin/hnel.c
index bb087df1..981355a6 100755
--- a/curtis/.bin/hnel.c
+++ b/curtis/.bin/hnel.c
@@ -6,6 +6,7 @@ exec cc -Wall -Wextra -pedantic $@ -lutil -o $(dirname $0)/hnel $0
 
 #include <err.h>
 #include <poll.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <sys/wait.h>
@@ -41,6 +42,7 @@ int main(int argc, char *argv[]) {
 
     if (argc < 2) return EX_USAGE;
 
+    bool enable = true;
     char table[256] = {0};
     table['n'] = 'j'; table['N'] = 'J'; table[CTRL('N')] = CTRL('J');
     table['e'] = 'k'; table['E'] = 'K'; table[CTRL('E')] = CTRL('K');
@@ -82,8 +84,13 @@ int main(int argc, char *argv[]) {
             if (len < 0) err(EX_IOERR, "read(%d)", STDIN_FILENO);
 
             if (len == 1) {
+                if (buf[0] == CTRL('S')) {
+                    enable = !enable;
+                    continue;
+                }
+
                 unsigned char c = buf[0];
-                if (table[c]) buf[0] = table[c];
+                if (enable && table[c]) buf[0] = table[c];
             }
 
             len = writeAll(master, buf, len);