2014-07-11 01:27:04 +02:00
|
|
|
#ifndef face_registry_hh_INCLUDED
|
|
|
|
#define face_registry_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "face.hh"
|
|
|
|
#include "utils.hh"
|
|
|
|
#include "completion.hh"
|
2014-12-16 19:57:19 +01:00
|
|
|
#include "unordered_map.hh"
|
2014-07-11 01:27:04 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class FaceRegistry : public Singleton<FaceRegistry>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FaceRegistry();
|
|
|
|
|
2014-07-12 12:19:35 +02:00
|
|
|
Face operator[](const String& facedesc);
|
2014-07-11 01:27:04 +02:00
|
|
|
void register_alias(const String& name, const String& facedesc,
|
|
|
|
bool override = false);
|
|
|
|
|
|
|
|
CandidateList complete_alias_name(StringView prefix,
|
|
|
|
ByteCount cursor_pos) const;
|
|
|
|
private:
|
2014-08-20 00:10:56 +02:00
|
|
|
struct FaceOrAlias
|
|
|
|
{
|
|
|
|
Face face;
|
|
|
|
String alias;
|
|
|
|
|
|
|
|
FaceOrAlias(Face face = Face{}) : face(face) {}
|
|
|
|
};
|
|
|
|
|
2014-12-16 19:57:19 +01:00
|
|
|
UnorderedMap<String, FaceOrAlias> m_aliases;
|
2014-07-11 01:27:04 +02:00
|
|
|
};
|
|
|
|
|
2014-07-12 12:19:35 +02:00
|
|
|
inline Face get_face(const String& facedesc)
|
2014-07-11 01:27:04 +02:00
|
|
|
{
|
2014-08-15 00:51:24 +02:00
|
|
|
if (FaceRegistry::has_instance())
|
|
|
|
return FaceRegistry::instance()[facedesc];
|
|
|
|
return Face{};
|
2014-07-11 01:27:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // face_registry_hh_INCLUDED
|
|
|
|
|