aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-03-05 11:00:38 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-03-05 11:00:38 +0100
commitbcdacf4d9a41d4226867e36074d085dd4fe97c10 (patch)
tree7d08ca38a56d535c911edeae789b04e70aadad49
parent62fe04e615ce6b7f3893b979fc36d382729d8742 (diff)
downloadvis-bcdacf4d9a41d4226867e36074d085dd4fe97c10.tar.gz
vis-bcdacf4d9a41d4226867e36074d085dd4fe97c10.tar.xz
vis: remove word and file name completion from editor core
-rw-r--r--config.def.h2
-rw-r--r--main.c77
2 files changed, 0 insertions, 79 deletions
diff --git a/config.def.h b/config.def.h
index 1c3e26d..4a170f9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -317,8 +317,6 @@ static const KeyBinding bindings_insert[] = {
{ "<C-d>", ALIAS("<vis-operator-shift-left><vis-operator-shift-left>") },
{ "<C-i>", ALIAS("<Tab>") },
{ "<C-j>", ALIAS("<Enter>") },
- { "<C-n>", ACTION(COMPLETE_WORD) },
- { "<C-x><C-f>", ACTION(COMPLETE_FILENAME) },
{ "<C-m>", ALIAS("<Enter>") },
{ "<C-r>", ACTION(INSERT_REGISTER) },
{ "<C-t>", ALIAS("<vis-operator-shift-right><vis-operator-shift-right>") },
diff --git a/main.c b/main.c
index 01b06ef..6751fa1 100644
--- a/main.c
+++ b/main.c
@@ -126,10 +126,6 @@ static const char *window(Vis*, const char *keys, const Arg *arg);
static const char *unicode_info(Vis*, const char *keys, const Arg *arg);
/* either go to count % of ile or to matching item */
static const char *percent(Vis*, const char *keys, const Arg *arg);
-/* complete input text at cursor based on the words in the current file */
-static const char *complete_word(Vis*, const char *keys, const Arg *arg);
-/* complete input text at cursor based on file names of the current directory */
-static const char *complete_filename(Vis*, const char *keys, const Arg *arg);
enum {
VIS_ACTION_EDITOR_SUSPEND,
@@ -304,8 +300,6 @@ enum {
VIS_ACTION_MOTION_LINEWISE,
VIS_ACTION_UNICODE_INFO,
VIS_ACTION_UTF8_INFO,
- VIS_ACTION_COMPLETE_WORD,
- VIS_ACTION_COMPLETE_FILENAME,
VIS_ACTION_NOP,
};
@@ -1170,16 +1164,6 @@ static const KeyAction vis_action[] = {
VIS_HELP("Show UTF-8 encoded codepoint(s) of character under cursor")
unicode_info, { .i = VIS_ACTION_UTF8_INFO }
},
- [VIS_ACTION_COMPLETE_WORD] = {
- "vis-complete-word",
- VIS_HELP("Complete word in file")
- complete_word,
- },
- [VIS_ACTION_COMPLETE_FILENAME] = {
- "vis-complete-filename",
- VIS_HELP("Complete file name")
- complete_filename,
- },
[VIS_ACTION_NOP] = {
"vis-nop",
VIS_HELP("Ignore key, do nothing")
@@ -1992,67 +1976,6 @@ static const char *percent(Vis *vis, const char *keys, const Arg *arg) {
return keys;
}
-static char *get_completion_prefix(Vis *vis, Filerange (*text_object)(Text *, size_t)) {
- View *view = vis_view(vis);
- Text *txt = vis_text(vis);
- size_t pos = view_cursor_get(view);
- Filerange r = text_object(txt, pos-1);
- r = text_range_inner(txt, &r);
- if (r.end > pos)
- r.end = pos;
- size_t size = text_range_size(&r);
- if (size == 0) {
- vis_info_show(vis, "No valid prefix found for completion");
- return NULL;
- }
-
- return text_bytes_alloc0(txt, r.start, size);
-}
-
-static void insert_dialog_selection(Vis *vis, Filerange *range, const char *argv[]) {
- char *out = NULL;
- if (vis_pipe_collect(vis, range, argv, &out, NULL) == 0) {
- View *view = vis_view(vis);
- size_t len = out ? strlen(out) : 0;
- for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) {
- size_t pos = view_cursors_pos(c);
- vis_insert(vis, pos, out, len);
- view_cursors_scroll_to(c, pos + len);
- }
- } else {
- vis_info_show(vis, "Completion command failed, is vis-menu in $PATH?");
- }
- vis_draw(vis);
- free(out);
-}
-
-static const char *complete_word(Vis *vis, const char *keys, const Arg *arg) {
- Text *txt = vis_text(vis);
- Buffer cmd;
- buffer_init(&cmd);
- char *prefix = get_completion_prefix(vis, text_object_word);
- if (prefix && buffer_printf(&cmd, VIS_COMPLETE " --word '%s'", prefix)) {
- Filerange all = text_range_new(0, text_size(txt));
- insert_dialog_selection(vis, &all, (const char*[]){ buffer_content0(&cmd), NULL });
- }
- buffer_release(&cmd);
- free(prefix);
- return keys;
-}
-
-static const char *complete_filename(Vis *vis, const char *keys, const Arg *arg) {
- Buffer cmd;
- buffer_init(&cmd);
- char *prefix = get_completion_prefix(vis, text_object_filename);
- if (prefix && buffer_printf(&cmd, VIS_COMPLETE " --file '%s'", prefix)) {
- Filerange empty = text_range_new(0, 0);
- insert_dialog_selection(vis, &empty, (const char*[]){ buffer_content0(&cmd), NULL });
- }
- buffer_release(&cmd);
- free(prefix);
- return keys;
-}
-
static Vis *vis;
static void signal_handler(int signum, siginfo_t *siginfo, void *context) {