Debian Codegraph @

modules/pinyinhelper/pinyinhelper.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2017-2017 CSSlayer <[email protected]>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 */
7 #ifndef _PINYINHELPER_PINYINHELPER_H_
8 #define _PINYINHELPER_PINYINHELPER_H_
9
10 #include "pinyinhelper_public.h"
11 #include "pinyinlookup.h"
12 #include "stroke.h"
13 #include <fcitx-config/configuration.h>
14 #include <fcitx-utils/event.h>
15 #include <fcitx/addoninstance.h>
16 #include <fcitx/addonmanager.h>
17 #include <fcitx/instance.h>
18 #include <libime/core/datrie.h>
19 #include <quickphrase_public.h>
20
21 namespace fcitx {
22
23 class PinyinHelper final : public AddonInstance {
24 public:
25 PinyinHelper(Instance *instance);
26
27 std::vector<std::string> lookup(uint32_t);
28 std::vector<std::tuple<std::string, std::string, int>> fullLookup(uint32_t);
29 std::vector<std::pair<std::string, std::string>>
30 lookupStroke(const std::string &input, int limit);
31 std::string reverseLookupStroke(const std::string &input);
32 std::string prettyStrokeString(const std::string &input);
33 void loadStroke();
34
35 FCITX_ADDON_EXPORT_FUNCTION(PinyinHelper, lookup);
36 FCITX_ADDON_EXPORT_FUNCTION(PinyinHelper, fullLookup);
37 FCITX_ADDON_EXPORT_FUNCTION(PinyinHelper, lookupStroke);
38 FCITX_ADDON_EXPORT_FUNCTION(PinyinHelper, loadStroke);
39 FCITX_ADDON_EXPORT_FUNCTION(PinyinHelper, reverseLookupStroke);
40 FCITX_ADDON_EXPORT_FUNCTION(PinyinHelper, prettyStrokeString);
41
42 FCITX_ADDON_DEPENDENCY_LOADER(quickphrase, instance_->addonManager());
43 FCITX_ADDON_DEPENDENCY_LOADER(clipboard, instance_->addonManager());
44
45 private:
46 void initQuickPhrase();
47 Instance *instance_;
48 PinyinLookup lookup_;
49 Stroke stroke_;
50 std::unique_ptr<EventSource> deferEvent_;
51 std::unique_ptr<HandlerTableEntry<QuickPhraseProviderCallback>> handler_;
52 };
53 } // namespace fcitx
54
55 #endif // _PINYINHELPER_PINYINHELPER_H_