2014-07-11 03:27:04 +04:00
|
|
|
#ifndef face_registry_hh_INCLUDED
|
|
|
|
#define face_registry_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "face.hh"
|
|
|
|
#include "utils.hh"
|
|
|
|
#include "completion.hh"
|
2017-03-07 03:30:54 +03:00
|
|
|
#include "hash_map.hh"
|
2014-07-11 03:27:04 +04:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class FaceRegistry : public Singleton<FaceRegistry>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FaceRegistry();
|
|
|
|
|
2014-07-12 14:19:35 +04:00
|
|
|
Face operator[](const String& facedesc);
|
2014-07-11 03:27:04 +04: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 02:10:56 +04:00
|
|
|
struct FaceOrAlias
|
|
|
|
{
|
2017-09-01 13:32:38 +03:00
|
|
|
Face face = {};
|
|
|
|
String alias = {};
|
2014-08-20 02:10:56 +04:00
|
|
|
};
|
2017-03-07 03:30:54 +03:00
|
|
|
using AliasMap = HashMap<String, FaceOrAlias, MemoryDomain::Faces>;
|
2016-02-12 22:14:06 +03:00
|
|
|
AliasMap m_aliases;
|
2014-07-11 03:27:04 +04:00
|
|
|
};
|
|
|
|
|
2014-07-12 14:19:35 +04:00
|
|
|
inline Face get_face(const String& facedesc)
|
2014-07-11 03:27:04 +04:00
|
|
|
{
|
2014-08-15 02:51:24 +04:00
|
|
|
if (FaceRegistry::has_instance())
|
|
|
|
return FaceRegistry::instance()[facedesc];
|
|
|
|
return Face{};
|
2014-07-11 03:27:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // face_registry_hh_INCLUDED
|