1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-21 18:41:29 +03:00
kakoune/src/face_registry.hh

49 lines
1.0 KiB
C++
Raw Normal View History

#ifndef face_registry_hh_INCLUDED
#define face_registry_hh_INCLUDED
#include "face.hh"
#include "utils.hh"
#include "completion.hh"
#include "hash_map.hh"
namespace Kakoune
{
class FaceRegistry : public Singleton<FaceRegistry>
{
public:
FaceRegistry();
2014-07-12 14:19:35 +04:00
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;
2017-09-09 16:55:35 +03:00
struct FaceOrAlias
{
Face face = {};
String alias = {};
};
2017-09-09 16:55:35 +03:00
using AliasMap = HashMap<String, FaceOrAlias, MemoryDomain::Faces>;
2017-09-09 16:55:35 +03:00
const AliasMap &aliases() const { return m_aliases; }
private:
AliasMap m_aliases;
};
2014-07-12 14:19:35 +04:00
inline Face get_face(const String& facedesc)
{
if (FaceRegistry::has_instance())
return FaceRegistry::instance()[facedesc];
return Face{};
}
2017-09-09 16:55:35 +03:00
String to_string(Face face);
}
#endif // face_registry_hh_INCLUDED