HighlighterRegistry: use idvaluemap to store factories
This commit is contained in:
parent
4252e0d610
commit
8e06e168d9
|
@ -14,8 +14,8 @@ struct factory_not_found : public runtime_error
|
||||||
void HighlighterRegistry::register_factory(const std::string& name,
|
void HighlighterRegistry::register_factory(const std::string& name,
|
||||||
const HighlighterFactory& factory)
|
const HighlighterFactory& factory)
|
||||||
{
|
{
|
||||||
assert(m_factories.find(name) == m_factories.end());
|
assert(not m_factories.contains(name));
|
||||||
m_factories[name] = factory;
|
m_factories.append(std::make_pair(name, factory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlighterRegistry::add_highlighter_to_window(Window& window,
|
void HighlighterRegistry::add_highlighter_to_window(Window& window,
|
||||||
|
@ -32,14 +32,7 @@ void HighlighterRegistry::add_highlighter_to_window(Window& window,
|
||||||
CandidateList HighlighterRegistry::complete_highlighter(const std::string& prefix,
|
CandidateList HighlighterRegistry::complete_highlighter(const std::string& prefix,
|
||||||
size_t cursor_pos)
|
size_t cursor_pos)
|
||||||
{
|
{
|
||||||
std::string real_prefix = prefix.substr(0, cursor_pos);
|
return m_factories.complete_id<str_to_str>(prefix, cursor_pos);
|
||||||
CandidateList result;
|
|
||||||
for (auto& highlighter : m_factories)
|
|
||||||
{
|
|
||||||
if (highlighter.first.substr(0, real_prefix.length()) == real_prefix)
|
|
||||||
result.push_back(highlighter.first);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "highlighter.hh"
|
#include "highlighter.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
#include "completion.hh"
|
#include "completion.hh"
|
||||||
|
#include "idvaluemap.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
@ -32,7 +33,7 @@ public:
|
||||||
size_t cursor_pos);
|
size_t cursor_pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, HighlighterFactory> m_factories;
|
idvaluemap<std::string, HighlighterFactory> m_factories;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user