From 4c3bd68876841ad9547f1d270c36a78d5a68cfed Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 8 Jul 2014 20:24:51 +0100 Subject: [PATCH] Change autoinfo option to be an integer, allowing different levels --- src/commands.cc | 30 ++++++++++++++++-------------- src/normal.cc | 4 ++-- src/option_manager.cc | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 6bf62164..b6286cd0 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -964,6 +964,19 @@ const ParameterDesc context_wrap_params = { ParameterDesc::Flags::SwitchesOnlyAtStart, 1 }; +template +struct DisableOption { + DisableOption(Context& context, const char* name) + : m_option(context.options()[name]), + m_prev_value(m_option.get()) + { m_option.set(T{}); } + + ~DisableOption() { m_option.set(m_prev_value); } + + Option& m_option; + T m_prev_value; +}; + template void context_wrap(const ParametersParser& parser, Context& context, Func func) { @@ -975,20 +988,9 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) GlobalHooks::instance().enable_user_hooks(); }); - struct DisableOption { - DisableOption(Context& context, const char* name) - : m_option(context.options()[name]), - m_prev_value(m_option.get()) - { m_option.set(false); } - - ~DisableOption() { m_option.set(m_prev_value); } - - Option& m_option; - bool m_prev_value; - }; - DisableOption disable_autoinfo(context, "autoinfo"); - DisableOption disable_autoshowcompl(context, "autoshowcompl"); - DisableOption disable_incsearch(context, "incsearch"); + DisableOption disable_autoinfo(context, "autoinfo"); + DisableOption disable_autoshowcompl(context, "autoshowcompl"); + DisableOption disable_incsearch(context, "incsearch"); ClientManager& cm = ClientManager::instance(); diff --git a/src/normal.cc b/src/normal.cc index e4c5995d..307dfbf0 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -107,7 +107,7 @@ void repeat_last_insert(Context& context, int) bool show_auto_info_ifn(const String& title, const String& info, const Context& context) { - if (not context.options()["autoinfo"].get() or not context.has_ui()) + if (context.options()["autoinfo"].get() < 1 or not context.has_ui()) return false; ColorPair col = get_color("Information"); CharCoord pos = context.window().dimensions(); @@ -348,7 +348,7 @@ void command(Context& context, int) if (context.has_ui()) { context.ui().info_hide(); - if (event == PromptEvent::Change and context.options()["autoinfo"].get()) + if (event == PromptEvent::Change and context.options()["autoinfo"].get() > 0) { auto info = CommandManager::instance().command_info(cmdline); ColorPair col = get_color("Information"); diff --git a/src/option_manager.cc b/src/option_manager.cc index 0bb2f4df..5ad35387 100644 --- a/src/option_manager.cc +++ b/src/option_manager.cc @@ -145,7 +145,7 @@ GlobalOptions::GlobalOptions() true); declare_option("autoinfo", "automatically display contextual help", - true); + 1); declare_option("autoshowcompl", "automatically display possible completions for prompts", true);