aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-06 17:32:29 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-06 17:32:29 +0200
commit06ec2a1388384b5ad5e821c8846df4ec65af50e2 (patch)
treea2d1650d2c27d480620c139f907193ccf782a761
parent99526126e48459d44402b4028ee8ac9513ee0ebb (diff)
downloadxK-06ec2a1388384b5ad5e821c8846df4ec65af50e2.tar.gz
xK-06ec2a1388384b5ad5e821c8846df4ec65af50e2.tar.xz
xK-06ec2a1388384b5ad5e821c8846df4ec65af50e2.zip
degesch: stub word completion
-rw-r--r--degesch.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/degesch.c b/degesch.c
index 3742baa..851971c 100644
--- a/degesch.c
+++ b/degesch.c
@@ -215,6 +215,7 @@ input_erase (struct input *self)
static int app_readline_init (void);
static void on_readline_input (char *line);
+static char **app_readline_completion (const char *text, int start, int end);
static void
input_start (struct input *self, const char *program_name)
@@ -225,9 +226,11 @@ input_start (struct input *self, const char *program_name)
// This can cause memory leaks, or maybe even a segfault. Funny, eh?
stifle_history (HISTORY_LIMIT);
+ rl_readline_name = PROGRAM_NAME;
rl_startup_hook = app_readline_init;
rl_catch_sigwinch = false;
rl_callback_handler_install (self->prompt, on_readline_input);
+ rl_attempted_completion_function = app_readline_completion;
self->prompt_shown = 1;
self->active = true;
}
@@ -5113,6 +5116,18 @@ app_readline_bind_meta (char key, rl_command_func_t cb)
#endif
}
+static char **
+app_readline_completion (const char *text, int start, int end)
+{
+ (void) text;
+ (void) start;
+ (void) end;
+
+ // Don't iterate over filenames and stuff
+ rl_attempted_completion_over = true;
+ return NULL;
+}
+
static int
app_readline_init (void)
{
@@ -5134,6 +5149,12 @@ app_readline_init (void)
// We need to hide the prompt first
rl_bind_key (RETURN, on_readline_return);
+
+ // Completion
+ rl_variable_bind ("completion-ignore-case", "on");
+ rl_bind_key (TAB, rl_named_function ("menu-complete"));
+ if (key_btab)
+ rl_bind_keyseq (key_btab, rl_named_function ("menu-complete-backward"));
return 0;
}
@@ -5188,6 +5209,15 @@ on_editline_next_buffer (EditLine *editline, int key)
}
static unsigned char
+on_editline_complete (EditLine *editline, int key)
+{
+ (void) key;
+ (void) editline;
+
+ return CC_ERROR;
+}
+
+static unsigned char
on_editline_return (EditLine *editline, int key)
{
(void) key;
@@ -5252,6 +5282,10 @@ app_editline_init (struct input *self)
el_set (self->editline, EL_ADDFN, "send-line",
"Send line", on_editline_return);
el_set (self->editline, EL_BIND, "\n", "send-line", NULL);
+
+ el_set (self->editline, EL_ADDFN, "complete",
+ "Complete word", on_editline_complete);
+ el_set (self->editline, EL_BIND, "^I", "complete", NULL);
}
#endif // HAVE_EDITLINE