2012-04-03 17:39:20 +04:00
|
|
|
#include "option_manager.hh"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-04-14 05:17:09 +04:00
|
|
|
Option& OptionManager::operator[] (const String& name)
|
2012-04-03 22:25:27 +04:00
|
|
|
{
|
|
|
|
auto it = m_options.find(name);
|
|
|
|
if (it != m_options.end())
|
|
|
|
return it->second;
|
|
|
|
else if (m_parent)
|
|
|
|
return (*m_parent)[name];
|
|
|
|
else
|
|
|
|
return m_options[name];
|
|
|
|
}
|
|
|
|
|
2012-04-14 05:17:09 +04:00
|
|
|
const Option& OptionManager::operator[] (const String& name) const
|
2012-04-03 22:25:27 +04:00
|
|
|
{
|
|
|
|
auto it = m_options.find(name);
|
|
|
|
if (it != m_options.end())
|
|
|
|
return it->second;
|
|
|
|
else if (m_parent)
|
|
|
|
return (*m_parent)[name];
|
|
|
|
else
|
|
|
|
throw option_not_found(name);
|
|
|
|
}
|
|
|
|
|
2012-04-14 05:17:09 +04:00
|
|
|
CandidateList OptionManager::complete_option_name(const String& prefix,
|
2012-04-03 22:25:27 +04:00
|
|
|
size_t cursor_pos)
|
|
|
|
{
|
2012-04-14 05:17:09 +04:00
|
|
|
String real_prefix = prefix.substr(0, cursor_pos);
|
2012-04-03 22:25:27 +04:00
|
|
|
CandidateList result;
|
|
|
|
if (m_parent)
|
|
|
|
result = m_parent->complete_option_name(prefix, cursor_pos);
|
|
|
|
for (auto& option : m_options)
|
|
|
|
{
|
|
|
|
if (option.first.substr(0, real_prefix.length()) == real_prefix and
|
|
|
|
not contains(result, option.first))
|
|
|
|
result.push_back(option.first);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-04-03 17:39:20 +04:00
|
|
|
GlobalOptionManager::GlobalOptionManager()
|
|
|
|
: OptionManager()
|
|
|
|
{
|
|
|
|
(*this)["tabstop"] = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|