Change autoinfo option to be an integer, allowing different levels
This commit is contained in:
parent
81d3eadd09
commit
4c3bd68876
|
@ -964,6 +964,19 @@ const ParameterDesc context_wrap_params = {
|
|||
ParameterDesc::Flags::SwitchesOnlyAtStart, 1
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct DisableOption {
|
||||
DisableOption(Context& context, const char* name)
|
||||
: m_option(context.options()[name]),
|
||||
m_prev_value(m_option.get<T>())
|
||||
{ m_option.set(T{}); }
|
||||
|
||||
~DisableOption() { m_option.set(m_prev_value); }
|
||||
|
||||
Option& m_option;
|
||||
T m_prev_value;
|
||||
};
|
||||
|
||||
template<typename Func>
|
||||
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<bool>())
|
||||
{ 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<int> disable_autoinfo(context, "autoinfo");
|
||||
DisableOption<bool> disable_autoshowcompl(context, "autoshowcompl");
|
||||
DisableOption<bool> disable_incsearch(context, "incsearch");
|
||||
|
||||
|
||||
ClientManager& cm = ClientManager::instance();
|
||||
|
|
|
@ -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<bool>() or not context.has_ui())
|
||||
if (context.options()["autoinfo"].get<int>() < 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<bool>())
|
||||
if (event == PromptEvent::Change and context.options()["autoinfo"].get<int>() > 0)
|
||||
{
|
||||
auto info = CommandManager::instance().command_info(cmdline);
|
||||
ColorPair col = get_color("Information");
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user