diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_handler.cc | 16 | ||||
| -rw-r--r-- | src/input_handler.hh | 16 | ||||
| -rw-r--r-- | src/main.cc | 6 |
3 files changed, 27 insertions, 11 deletions
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); |
