Change autoshowcompl to auto_complete with insert|prompt possible values

This commit is contained in:
Maxime Coste 2018-07-15 09:45:17 +10:00
parent 58c7b06e1d
commit bde726d034
6 changed files with 36 additions and 15 deletions

View File

@ -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 inserting on the next character, which will be the first character
of the next line. 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 == Kakoune 2018.04.13
First official Kakoune release. First official Kakoune release.

View File

@ -166,9 +166,9 @@ are exclusively available to built-in options.
_default_ command|onkey + _default_ command|onkey +
display automatic information box in the enabled contexts display automatic information box in the enabled contexts
*autoshowcompl* `bool`:: *auto_complete* `flags(insert|prompt)`::
_default_ true + _default_ insert|prompt +
automatically display possible completions when editing a prompt automatically display possible completions in the enabled modes.
*ignored_files* `regex`:: *ignored_files* `regex`::
filenames matching this regex won't be considered as candidates filenames matching this regex won't be considered as candidates

View File

@ -709,10 +709,10 @@ public:
: InputMode(input_handler), m_prompt(prompt.str()), m_prompt_face(face), : InputMode(input_handler), m_prompt(prompt.str()), m_prompt_face(face),
m_empty_text{std::move(emptystr)}, m_empty_text{std::move(emptystr)},
m_flags(flags), m_completer(std::move(completer)), m_callback(std::move(callback)), 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 ? m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) { 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); refresh_completions(CompletionFlags::Fast);
if (m_line_changed) if (m_line_changed)
{ {
@ -880,7 +880,7 @@ public:
} }
else if (key == ctrl('o')) else if (key == ctrl('o'))
{ {
m_autoshowcompl = false; m_auto_complete = false;
clear_completions(); clear_completions();
if (context().has_client()) if (context().has_client())
context().client().menu_hide(); context().client().menu_hide();
@ -1019,7 +1019,7 @@ private:
LineEditor m_line_editor; LineEditor m_line_editor;
bool m_line_changed = false; bool m_line_changed = false;
PromptFlags m_flags; PromptFlags m_flags;
bool m_autoshowcompl; bool m_auto_complete;
bool m_refresh_completion_pending = true; bool m_refresh_completion_pending = true;
Timer m_idle_timer; Timer m_idle_timer;
@ -1078,11 +1078,11 @@ public:
m_restore_cursor(mode == InsertMode::Append), m_restore_cursor(mode == InsertMode::Append),
m_edition(context()), m_edition(context()),
m_completer(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_disable_hooks{context().hooks_disabled(), context().hooks_disabled()},
m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ? m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) { Timer::Callback{} : [this](Timer&) {
if (m_autoshowcompl) if (m_auto_complete)
m_completer.update(); m_completer.update();
context().hooks().run_hook("InsertIdle", "", context()); context().hooks().run_hook("InsertIdle", "", context());
}} }}
@ -1267,7 +1267,7 @@ public:
} }
else if (key == ctrl('o')) else if (key == ctrl('o'))
{ {
m_autoshowcompl = false; m_auto_complete = false;
m_completer.reset(); m_completer.reset();
} }
else if (key == ctrl('u')) else if (key == ctrl('u'))
@ -1433,7 +1433,7 @@ private:
ScopedEdition m_edition; ScopedEdition m_edition;
InsertCompleter m_completer; InsertCompleter m_completer;
const bool m_restore_cursor; const bool m_restore_cursor;
bool m_autoshowcompl; bool m_auto_complete;
Timer m_idle_timer; Timer m_idle_timer;
bool m_in_end = false; bool m_in_end = false;
MouseHandler m_mouse_handler; MouseHandler m_mouse_handler;

View File

@ -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); bool show_auto_info_ifn(StringView title, StringView info, AutoInfo mask, const Context& context);
void hide_auto_info_ifn(const Context& context, bool hide); void hide_auto_info_ifn(const Context& context, bool hide);

View File

@ -350,9 +350,9 @@ void register_options()
reg.declare_option("autoinfo", reg.declare_option("autoinfo",
"automatically display contextual help", "automatically display contextual help",
AutoInfo::Command | AutoInfo::OnKey); AutoInfo::Command | AutoInfo::OnKey);
reg.declare_option("autoshowcompl", reg.declare_option("auto_complete",
"automatically display possible completions for prompts", "automatically display possible completions",
true); AutoComplete::Insert | AutoComplete::Prompt);
reg.declare_option("aligntab", reg.declare_option("aligntab",
"use tab characters when possible for alignment", "use tab characters when possible for alignment",
false); false);

View File

@ -9,7 +9,7 @@ main() {
kak_commands=' kak_commands='
set global autoreload yes set global autoreload yes
set global autoinfo "" set global autoinfo ""
set global autoshowcompl false set global auto_complete ""
try %{ try %{
exec -save-regs / %{%s%\(\K[^)]+\)<ret>a<backspace><esc>i<backspace><backspace><c-u><esc><a-;>} exec -save-regs / %{%s%\(\K[^)]+\)<ret>a<backspace><esc>i<backspace><backspace><c-u><esc><a-;>}
} catch %{ exec gg } } catch %{ exec gg }