From 1cb6e9717f70978c4b1a0a054bdb559c5402208e Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Fri, 28 Jul 2017 23:44:46 -0400 Subject: Add toggle to hnel --- home/.bin/hnel.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'home/.bin/hnel.c') diff --git a/home/.bin/hnel.c b/home/.bin/hnel.c index bb087df1..981355a6 100755 --- a/home/.bin/hnel.c +++ b/home/.bin/hnel.c @@ -6,6 +6,7 @@ exec cc -Wall -Wextra -pedantic $@ -lutil -o $(dirname $0)/hnel $0 #include #include +#include #include #include #include @@ -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); -- cgit 1.4.1