diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-12-23 22:15:53 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-12-23 22:15:53 +0000 |
| commit | fb611e2f6296e563850d74fea180ade749ab404b (patch) | |
| tree | 42d4ab676cc718a6b57f3f1ec10f077d79dcaa0e /src/function_registry.hh | |
| parent | c17fa7be1413c304dd4b21d4faf6b644de1da364 (diff) | |
Use an id_map directly for HighlighterRegistry rather than the FunctionRegistry class
Diffstat (limited to 'src/function_registry.hh')
| -rw-r--r-- | src/function_registry.hh | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/function_registry.hh b/src/function_registry.hh deleted file mode 100644 index cf0ea46e..00000000 --- a/src/function_registry.hh +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef function_registry_h_INCLUDED -#define function_registry_h_INCLUDED - -#include "completion.hh" -#include "id_map.hh" -#include "string.hh" -#include "exception.hh" -#include "containers.hh" - -namespace Kakoune -{ - -struct function_not_found : runtime_error -{ - function_not_found(StringView name) - : runtime_error("'" + name + "' not found") {} -}; - -template<typename FunctionType> -class FunctionRegistry -{ -public: - void register_func(StringView name, const FunctionType& function) - { - kak_assert(not m_functions.contains(name)); - m_functions.append(std::make_pair(name, function)); - } - - const FunctionType& operator[](StringView name) const - { - auto it = m_functions.find(name); - if (it == m_functions.end()) - throw function_not_found(name); - return it->second; - } - - CandidateList complete_name(StringView prefix, ByteCount cursor_pos) - { - auto c = transformed(m_functions, id_map<FunctionType>::get_id); - return complete(prefix, cursor_pos, c); - } - -private: - id_map<FunctionType> m_functions; -}; - -} - -#endif // function_registry_h_INCLUDED |
