summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-07-15 09:45:17 +1000
committerMaxime Coste <mawww@kakoune.org>2018-07-15 11:10:32 +1000
commitbde726d0342f32ff2e9cb464a351450a43ecea9f (patch)
treefc6164f391f8232fe8c92a0792f14aa97ac400fe
parent58c7b06e1d9e8a9e0cb12aace972b7d9119b7863 (diff)
Change autoshowcompl to auto_complete with insert|prompt possible values
-rw-r--r--doc/pages/changelog.asciidoc5
-rw-r--r--doc/pages/options.asciidoc6
-rw-r--r--src/input_handler.cc16
-rw-r--r--src/input_handler.hh16
-rw-r--r--src/main.cc6
-rwxr-xr-xtest/run2
6 files changed, 36 insertions, 15 deletions
diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc
index e188caad..0053d2bb 100644
--- a/doc/pages/changelog.asciidoc
+++ b/doc/pages/changelog.asciidoc
@@ -78,6 +78,11 @@ change to make Kakoune command model cleaner and more robust.
inserting on the next character, which will be the first character
of the next line.
+- `autoshowcompl` options has been renames `auto_complete` and is
+ now a `flags(insert|prompt)` option, allowing more granular
+ configuration of when the completions should be displayed
+ automatically.
+
== Kakoune 2018.04.13
First official Kakoune release.
diff --git a/doc/pages/options.asciidoc b/doc/pages/options.asciidoc
index 60c6f454..d56c3ccb 100644
--- a/doc/pages/options.asciidoc
+++ b/doc/pages/options.asciidoc
@@ -166,9 +166,9 @@ are exclusively available to built-in options.
_default_ command|onkey +
display automatic information box in the enabled contexts
-*autoshowcompl* `bool`::
- _default_ true +
- automatically display possible completions when editing a prompt
+*auto_complete* `flags(insert|prompt)`::
+ _default_ insert|prompt +
+ automatically display possible completions in the enabled modes.
*ignored_files* `regex`::
filenames matching this regex won't be considered as candidates
diff --git a/src/input_handler.cc b/src/input_handler.cc
index cf9773c9..0d0d2feb 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -709,10 +709,10 @@ public:
: InputMode(input_handler), m_prompt(prompt.str()), m_prompt_face(face),
m_empty_text{std::move(emptystr)},
m_flags(flags), m_completer(std::move(completer)), m_callback(std::move(callback)),
- m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()},
+ m_auto_complete{context().options()["auto_complete"].get<AutoComplete>() & AutoComplete::Prompt},
m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) {
- if (m_autoshowcompl and m_refresh_completion_pending)
+ if (m_auto_complete and m_refresh_completion_pending)
refresh_completions(CompletionFlags::Fast);
if (m_line_changed)
{
@@ -880,7 +880,7 @@ public:
}
else if (key == ctrl('o'))
{
- m_autoshowcompl = false;
+ m_auto_complete = false;
clear_completions();
if (context().has_client())
context().client().menu_hide();
@@ -1019,7 +1019,7 @@ private:
LineEditor m_line_editor;
bool m_line_changed = false;
PromptFlags m_flags;
- bool m_autoshowcompl;
+ bool m_auto_complete;
bool m_refresh_completion_pending = true;
Timer m_idle_timer;
@@ -1078,11 +1078,11 @@ public:
m_restore_cursor(mode == InsertMode::Append),
m_edition(context()),
m_completer(context()),
- m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()},
+ m_auto_complete{context().options()["auto_complete"].get<AutoComplete>() & AutoComplete::Insert},
m_disable_hooks{context().hooks_disabled(), context().hooks_disabled()},
m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) {
- if (m_autoshowcompl)
+ if (m_auto_complete)
m_completer.update();
context().hooks().run_hook("InsertIdle", "", context());
}}
@@ -1267,7 +1267,7 @@ public:
}
else if (key == ctrl('o'))
{
- m_autoshowcompl = false;
+ m_auto_complete = false;
m_completer.reset();
}
else if (key == ctrl('u'))
@@ -1433,7 +1433,7 @@ private:
ScopedEdition m_edition;
InsertCompleter m_completer;
const bool m_restore_cursor;
- bool m_autoshowcompl;
+ bool m_auto_complete;
Timer m_idle_timer;
bool m_in_end = false;
MouseHandler m_mouse_handler;
diff --git a/src/input_handler.hh b/src/input_handler.hh
index d5c9f7b4..600d78b8 100644
--- a/src/input_handler.hh
+++ b/src/input_handler.hh
@@ -152,6 +152,22 @@ constexpr auto enum_desc(Meta::Type<AutoInfo>)
});
}
+enum class AutoComplete
+{
+ None = 0,
+ Insert = 0b01,
+ Prompt = 0b10
+};
+constexpr bool with_bit_ops(Meta::Type<AutoComplete>) { return true; }
+
+constexpr auto enum_desc(Meta::Type<AutoComplete>)
+{
+ return make_array<EnumDesc<AutoComplete>, 3>({
+ { AutoComplete::Insert, "insert"},
+ { AutoComplete::Prompt, "prompt" }
+ });
+}
+
bool show_auto_info_ifn(StringView title, StringView info, AutoInfo mask, const Context& context);
void hide_auto_info_ifn(const Context& context, bool hide);
diff --git a/src/main.cc b/src/main.cc
index 8987fe20..a1cfbafd 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -350,9 +350,9 @@ void register_options()
reg.declare_option("autoinfo",
"automatically display contextual help",
AutoInfo::Command | AutoInfo::OnKey);
- reg.declare_option("autoshowcompl",
- "automatically display possible completions for prompts",
- true);
+ reg.declare_option("auto_complete",
+ "automatically display possible completions",
+ AutoComplete::Insert | AutoComplete::Prompt);
reg.declare_option("aligntab",
"use tab characters when possible for alignment",
false);
diff --git a/test/run b/test/run
index 85a92120..c019eb60 100755
--- a/test/run
+++ b/test/run
@@ -9,7 +9,7 @@ main() {
kak_commands='
set global autoreload yes
set global autoinfo ""
- set global autoshowcompl false
+ set global auto_complete ""
try %{
exec -save-regs / %{%s%\(\K[^)]+\)<ret>a<backspace><esc>i<backspace><backspace><c-u><esc><a-;>}
} catch %{ exec gg }