Add Context::option_manager()

it returns the more specific option manager available
(window -> buffer -> global)
This commit is contained in:
Maxime Coste 2012-06-28 14:01:37 +02:00
parent 9c78453cb7
commit 286462a2f6
2 changed files with 11 additions and 1 deletions

View File

@ -32,6 +32,16 @@ struct Context
return *m_window; return *m_window;
} }
bool has_window() const { return m_window; } bool has_window() const { return m_window; }
OptionManager& option_manager() const
{
if (m_window)
return m_window->option_manager();
if (m_buffer)
return m_buffer->option_manager();
return GlobalOptionManager::instance();
}
public: public:
safe_ptr<Window> m_window; safe_ptr<Window> m_window;
safe_ptr<Buffer> m_buffer; safe_ptr<Buffer> m_buffer;

View File

@ -440,7 +440,7 @@ int main(int argc, char* argv[])
{ return context.window().selections_content().back(); }); { return context.window().selections_content().back(); });
shell_manager.register_env_var("opt_.+", shell_manager.register_env_var("opt_.+",
[](const String& name, const Context& context) [](const String& name, const Context& context)
{ return context.window().option_manager()[name.substr(4)].as_string(); }); { return context.option_manager()[name.substr(4)].as_string(); });
register_commands(); register_commands();
register_highlighters(); register_highlighters();
register_filters(); register_filters();