From a51a54bc5979a2491f152abc47ad54e6b63f27c8 Mon Sep 17 00:00:00 2001 From: Dylam De La Torre Date: Tue, 23 Nov 2021 05:21:56 +0100 Subject: Restructure source and resource files (#46) importantly, res is now res/res and css is now res/css --- src/emojis.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/emojis.hpp (limited to 'src/emojis.hpp') diff --git a/src/emojis.hpp b/src/emojis.hpp new file mode 100644 index 0000000..61b8a71 --- /dev/null +++ b/src/emojis.hpp @@ -0,0 +1,27 @@ +#pragma once +#include +#include +#include +#include +#include + +// shoutout to gtk for only supporting .svg's sometimes + +class EmojiResource { +public: + EmojiResource(std::string filepath); + bool Load(); + Glib::RefPtr GetPixBuf(const Glib::ustring &pattern); + const std::vector &GetPatterns() const; + const std::map &GetShortCodes() const; + void ReplaceEmojis(Glib::RefPtr buf, int size = 24); + std::string GetShortCodeForPattern(const Glib::ustring &pattern); + +private: + std::unordered_map> m_pattern_shortcode_index; + std::map m_shortcode_index; // shortcode -> pattern + std::unordered_map> m_index; // pattern -> [pos, len] + FILE *m_fp = nullptr; + std::string m_filepath; + std::vector m_patterns; +}; -- cgit v1.2.3