1 /*
2  * SPDX-FileCopyrightText: 2017-2017 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 #ifndef _FCITX_MODULES_QUICKPHRASE_QUICKPHRASE_PUBLIC_H_
8 #define _FCITX_MODULES_QUICKPHRASE_QUICKPHRASE_PUBLIC_H_
9 
10 #include <functional>
11 #include <string>
12 #include <fcitx-utils/key.h>
13 #include <fcitx-utils/metastring.h>
14 #include <fcitx/addoninstance.h>
15 #include <fcitx/inputcontext.h>
16 
17 namespace fcitx {
18 
19 enum class QuickPhraseAction {
20     Commit,
21     TypeToBuffer,
22     DigitSelection,
23     AlphaSelection,
24     NoneSelection,
25     DoNothing,
26     AutoCommit,
27 };
28 
29 using QuickPhraseAddCandidateCallback = std::function<void(
30     const std::string &, const std::string &, QuickPhraseAction action)>;
31 using QuickPhraseProviderCallback =
32     std::function<bool(InputContext *ic, const std::string &,
33                        const QuickPhraseAddCandidateCallback &)>;
34 
35 } // namespace fcitx
36 
37 /// Trigger quickphrase, with following format:
38 /// description_text prefix_text
39 FCITX_ADDON_DECLARE_FUNCTION(QuickPhrase, trigger,
40                              void(InputContext *ic, const std::string &text,
41                                   const std::string &prefix,
42                                   const std::string &str,
43                                   const std::string &alt, const Key &key));
44 FCITX_ADDON_DECLARE_FUNCTION(QuickPhrase, setBuffer,
45                              void(InputContext *ic, const std::string &text));
46 
47 FCITX_ADDON_DECLARE_FUNCTION(
48     QuickPhrase, addProvider,
49     std::unique_ptr<HandlerTableEntry<QuickPhraseProviderCallback>>(
50         QuickPhraseProviderCallback));
51 
52 #endif // _FCITX_MODULES_QUICKPHRASE_QUICKPHRASE_PUBLIC_H_
53