blob: 7e77c1cc155c30e041db445c32ef2c3e355109a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#ifndef face_registry_hh_INCLUDED
#define face_registry_hh_INCLUDED
#include "face.hh"
#include "utils.hh"
#include "completion.hh"
#include <unordered_map>
namespace Kakoune
{
class FaceRegistry : public Singleton<FaceRegistry>
{
public:
FaceRegistry();
Face operator[](const String& facedesc);
void register_alias(const String& name, const String& facedesc,
bool override = false);
CandidateList complete_alias_name(StringView prefix,
ByteCount cursor_pos) const;
private:
struct FaceOrAlias
{
Face face;
String alias;
FaceOrAlias(Face face = Face{}) : face(face) {}
};
std::unordered_map<String, FaceOrAlias> m_aliases;
};
inline Face get_face(const String& facedesc)
{
if (FaceRegistry::has_instance())
return FaceRegistry::instance()[facedesc];
return Face{};
}
}
#endif // face_registry_hh_INCLUDED
|