summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJefferson Delfes <jefferson.delfes@gmail.com>2013-10-22 09:05:34 -0400
committerJefferson Delfes <jefferson.delfes@gmail.com>2013-10-29 09:45:42 -0400
commit96917972765e827f99557c1d0f01b8e1f13b01d0 (patch)
treefb9bfa03f1702780293f88dac7fceb5a133dd62d
parent63568473f8816e0765cb78bdfb752063d3f2d2b5 (diff)
rl_helper: add delete key behavior
When delete key is pressed, everything from right position is shifted to left.
-rw-r--r--rl_helper.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/rl_helper.c b/rl_helper.c
index ba185ae..8c32f23 100644
--- a/rl_helper.c
+++ b/rl_helper.c
@@ -46,6 +46,7 @@ typedef enum {
K_LEFT = 0x103,
K_END = 0x104,
K_HOME = 0x105,
+ K_DELETE = 0x106,
} keys_t;
line_process_callback line_cb;
@@ -86,6 +87,10 @@ const char_sequence seqs[] = {
.sequence = {K_ESC, 'O', 'H'},
.code = K_HOME
},
+ {
+ .sequence = {K_ESC, '[', '3', '~'},
+ .code = K_DELETE
+ },
};
void rl_clear_seq() {
@@ -230,6 +235,10 @@ void rl_feed(int c) {
pos = 0;
rl_reprint_prompt();
break;
+ case K_DELETE:
+ memmove(lnbuf + pos, lnbuf + pos + 1, sizeof(lnbuf) - pos - 1);
+ rl_reprint_prompt();
+ break;
default:
if (isprint(c)) {
if (pos < MAX_LINE_BUFFER) {