2020-10-24 23:42:06 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
#include <gtkmm.h>
|
|
|
|
|
|
|
|
// shoutout to gtk for only supporting .svg's sometimes
|
|
|
|
|
|
|
|
class EmojiResource {
|
|
|
|
public:
|
|
|
|
EmojiResource(std::string filepath);
|
|
|
|
bool Load();
|
|
|
|
Glib::RefPtr<Gdk::Pixbuf> GetPixBuf(const Glib::ustring &pattern);
|
|
|
|
const std::vector<Glib::ustring> &GetPatterns() const;
|
2020-12-21 03:10:45 +00:00
|
|
|
const std::map<std::string, std::string> &GetShortCodes() const;
|
2020-11-10 06:38:44 +00:00
|
|
|
void ReplaceEmojis(Glib::RefPtr<Gtk::TextBuffer> buf, int size = 24);
|
2021-01-18 04:24:44 +00:00
|
|
|
std::string GetShortCodeForPattern(const Glib::ustring &pattern);
|
2020-10-24 23:42:06 +00:00
|
|
|
|
|
|
|
private:
|
2021-04-06 04:56:24 +00:00
|
|
|
std::unordered_map<std::string, std::vector<std::string>> m_pattern_shortcode_index;
|
2020-12-21 03:10:45 +00:00
|
|
|
std::map<std::string, std::string> m_shortcode_index; // shortcode -> pattern
|
2020-10-24 23:42:06 +00:00
|
|
|
std::unordered_map<std::string, std::pair<int, int>> m_index; // pattern -> [pos, len]
|
|
|
|
FILE *m_fp = nullptr;
|
|
|
|
std::string m_filepath;
|
|
|
|
std::vector<Glib::ustring> m_patterns;
|
|
|
|
};
|