summary refs log tree commit diff
path: root/home
diff options
context:
space:
mode:
Diffstat (limited to 'home')
-rwxr-xr-xhome/.bin/hnel.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/home/.bin/hnel.c b/home/.bin/hnel.c
index 981355a6..3aec85b3 100755
--- a/home/.bin/hnel.c
+++ b/home/.bin/hnel.c
@@ -22,6 +22,13 @@ exec cc -Wall -Wextra -pedantic $@ -lutil -o $(dirname $0)/hnel $0
 #include <util.h>
 #endif
 
+static char table[256] = {
+    ['n'] = 'j', ['N'] = 'J', [CTRL('N')] = CTRL('J'),
+    ['e'] = 'k', ['E'] = 'K', [CTRL('E')] = CTRL('K'),
+    ['j'] = 'e', ['J'] = 'E', [CTRL('J')] = CTRL('E'),
+    ['k'] = 'n', ['K'] = 'N', [CTRL('K')] = CTRL('N'),
+};
+
 static ssize_t writeAll(int fd, const char *buf, size_t len) {
     ssize_t writeLen;
     while (0 < (writeLen = write(fd, buf, len))) {
@@ -42,13 +49,6 @@ 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');
-    table['j'] = 'e'; table['J'] = 'E'; table[CTRL('J')] = CTRL('E');
-    table['k'] = 'n'; table['K'] = 'N'; table[CTRL('K')] = CTRL('N');
-
     error = tcgetattr(STDERR_FILENO, &saveTerm);
     if (error) err(EX_IOERR, "tcgetattr");
     atexit(restoreTerm);
@@ -71,6 +71,8 @@ int main(int argc, char *argv[]) {
         err(EX_OSERR, "%s", argv[1]);
     }
 
+    bool enable = true;
+
     struct pollfd fds[2] = {
         { .fd = STDIN_FILENO, .events = POLLIN },
         { .fd = master, .events = POLLIN },