summaryrefslogtreecommitdiffstats
path: root/linenoise/linenoise.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-07 20:28:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-07 20:28:55 -0700
commitac22923c691dfaf40830bedf056ee8948427dced (patch)
treec19427e8292bb29b1dbef430681157a677321d91 /linenoise/linenoise.c
parent925deb5f0ec8d201f701493d3e571ba46b169a15 (diff)
downloadtxr-ac22923c691dfaf40830bedf056ee8948427dced.tar.gz
txr-ac22923c691dfaf40830bedf056ee8948427dced.tar.bz2
txr-ac22923c691dfaf40830bedf056ee8948427dced.zip
linenoise: Ctrl-Z suspend.
* linenoise.c (key_action): New enum constant, CTRL_Z. (edit): Implement Ctrl-Z suspend.
Diffstat (limited to 'linenoise/linenoise.c')
-rw-r--r--linenoise/linenoise.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index 5ebd2b62..75479513 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -116,6 +116,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
+#include <signal.h>
#include "linenoise.h"
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
@@ -174,6 +175,7 @@ enum key_action {
CTRL_U = 21,
CTRL_V = 22,
CTRL_W = 23,
+ CTRL_Z = 26,
ESC = 27,
BACKSPACE = 127
};
@@ -958,6 +960,12 @@ static int edit(lino_t *l, const char *prompt)
case CTRL_W:
edit_delete_prev_word(l);
break;
+ case CTRL_Z:
+ disable_raw_mode(l);
+ raise(SIGTSTP);
+ enable_raw_mode(l);
+ refresh_line(l);
+ break;
}
}
return l->len;