1 /***************************************************************************
2  *   Copyright (C) 2010~2010 by CSSlayer                                   *
3  *   wengxt@gmail.com                                                      *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
19  ***************************************************************************/
20 
21 /**
22  * @addtogroup Fcitx
23  * @{
24  */
25 
26 /**
27  * @file   ime.h
28  * @author Yuking yuking_net@sohu.com
29  * @date   2008-1-16
30  *
31  *  Public Header for Input Method Develop
32  *
33  * The input method is key event centric application. When a key event comes to fcitx,
34  * the process handling the keyboard event can be separated into 7 phases, PreInput, DoInput, Update Candidates, Prev/Next Page
35  * PostInput, Hotkey, and key blocker.
36  *
37  * The input method engine process key event inside "DoInput".
38  *
39  * Each phase will change the INPUT_RETURN_VALUE, if INPUT_RETURN_VALUE is non-zero (non IRV_TO_PROCESS), the following
40  * phases will not run.
41  *
42  * If a key event goes through all phase and still the state is IRV_TO_PROCESS, it will be forwarded.
43  *
44  * When it comes to update candidates, if the flag contains IRV_FLAG_UPDATE_CANDIDATE_WORDS, it will trigger the GetCandWords
45  * of input method engine and clean up all strings in the input window, after that, it will trigger update candidates hook.
46  *
47  * Key blocker is useful if you want to do something in the post input phase, but you don't want forward key if they do nothing.
48  * There is an default implemention inside fcitx, it will blocks key when raw input buffer is not empty. Those keys
49  * contains direction key(left/right..), key will cause something input (a,b,c...), key will cause cursor move (home/end...).
50  *
51  * DoInput, Update Candidates, Key Blocker are belongs to input method engine, other can be registered by other addon.
52  */
53 #ifndef _FCITX_IME_H_
54 #define _FCITX_IME_H_
55 
56 #include <time.h>
57 #include <fcitx-utils/utf8.h>
58 #include <fcitx-config/hotkey.h>
59 #include <fcitx/ui.h>
60 #include <fcitx/addon.h>
61 
62 #ifdef __cplusplus
63 
64 extern "C" {
65 #endif
66 
67 /** max length of rawInputBuffer and outputString */
68 #define MAX_USER_INPUT    300
69 
70 /** FcitxHotkey internally use 2 hotkeys for everycase */
71 #define HOT_KEY_COUNT   2
72 
73 /**
74  * Only keep for compatible
75  * @deprecated
76  */
77 #define MAX_CAND_LEN    127
78 
79 /** max language code length, common 5 length is zh_CN
80  * a shorter case is en
81  */
82 #define LANGCODE_LENGTH 5
83 
84 /** when input method priority is larger than 100, it will be disabled by default after install */
85 #define PRIORITY_DISABLE 100
86 
87 /** due to backward compatible, this priority will be the most priority one */
88 #define PRIORITY_MAGIC_FIRST 0xf1527
89 
90     struct _FcitxInputContext;
91     struct _FcitxInstance;
92     struct _FcitxAddon;
93     struct _FcitxCandidateWordList;
94 
95     /** input method available status */
96     typedef enum _FcitxIMAvailableStatus {
97         IMAS_Enable,
98         IMAS_Disable,
99     } FcitxIMAvailableStatus;
100 
101     /** do input function return value */
102     typedef enum _INPUT_RETURN_VALUE {
103         IRV_TO_PROCESS = 0, /* do something */
104         IRV_FLAG_BLOCK_FOLLOWING_PROCESS = 1 << 0, /* nothing to do, actually non-zero is blocking, but you need a flag for do nothing */
105         IRV_FLAG_FORWARD_KEY = 1 << 1, /* the key will be forwarded */
106         IRV_FLAG_RESET_INPUT = 1 << 2, /* reset input */
107         IRV_FLAG_PENDING_COMMIT_STRING = 1 << 3, /* there is something in input strStringGet buffer, commit it */
108         IRV_FLAG_UPDATE_INPUT_WINDOW = 1 << 4, /* something updated in input window, let the UI update */
109         IRV_FLAG_UPDATE_CANDIDATE_WORDS = 1 << 5, /* update the candidate words */
110         IRV_FLAG_ENG = 1 << 6, /* special */
111         IRV_FLAG_PUNC = 1 << 7, /* special */
112         IRV_FLAG_DISPLAY_LAST = 1 << 8, /* special */
113         IRV_FLAG_DO_PHRASE_TIPS = 1 << 9, /* special */
114         /* compatible */
115         IRV_DONOT_PROCESS = IRV_FLAG_FORWARD_KEY,
116         IRV_COMMIT_STRING = IRV_FLAG_PENDING_COMMIT_STRING | IRV_FLAG_DO_PHRASE_TIPS,
117         IRV_DO_NOTHING = IRV_FLAG_BLOCK_FOLLOWING_PROCESS,
118         IRV_CLEAN = IRV_FLAG_RESET_INPUT,
119         IRV_COMMIT_STRING_REMIND = IRV_FLAG_PENDING_COMMIT_STRING | IRV_FLAG_UPDATE_INPUT_WINDOW,
120         IRV_DISPLAY_CANDWORDS = IRV_FLAG_UPDATE_INPUT_WINDOW | IRV_FLAG_UPDATE_CANDIDATE_WORDS,
121         IRV_DONOT_PROCESS_CLEAN = IRV_FLAG_FORWARD_KEY | IRV_FLAG_RESET_INPUT,
122         IRV_COMMIT_STRING_NEXT =  IRV_FLAG_PENDING_COMMIT_STRING | IRV_FLAG_UPDATE_INPUT_WINDOW,
123         IRV_DISPLAY_MESSAGE = IRV_FLAG_UPDATE_INPUT_WINDOW,
124         IRV_ENG = IRV_FLAG_PENDING_COMMIT_STRING | IRV_FLAG_ENG | IRV_FLAG_RESET_INPUT,
125         IRV_PUNC = IRV_FLAG_PENDING_COMMIT_STRING | IRV_FLAG_PUNC | IRV_FLAG_RESET_INPUT,
126         IRV_DISPLAY_LAST = IRV_FLAG_UPDATE_INPUT_WINDOW | IRV_FLAG_DISPLAY_LAST
127     } INPUT_RETURN_VALUE;
128 
129     /**
130      * Fcitx Input Method class, it can register more than one input
131      *        method in create function
132      **/
133     typedef struct _FcitxIMClass {
134         void* (*Create)(struct _FcitxInstance* instance); /**< interface for create a input method */
135         void  (*Destroy)(void *arg); /**< interface for destroy all input method created by this class */
136     } FcitxIMClass;
137 
138     /**
139      * Fcitx Input Method class, it can register more than one input
140      *        method in create function
141      **/
142     typedef struct _FcitxIMClass2 {
143         void* (*Create)(struct _FcitxInstance* instance); /**< interface for create a input method */
144         void  (*Destroy)(void *arg); /**< interface for destroy all input method created by this class */
145         void  (*ReloadConfig)(void *arg); /**< interface for destroy all input method created by this class */
146         void  (*padding1)(void *arg); /**< padding */
147         void  (*padding2)(void *arg); /**< padding */
148         void  (*padding3)(void *arg); /**< padding */
149         void  (*padding4)(void *arg); /**< padding */
150         void  (*padding5)(void *arg); /**< padding */
151     } FcitxIMClass2;
152 
153     typedef enum _FcitxIMCloseEventType {
154         /**
155          * when user press inactivate key, default behavior is commit raw preedit.
156          * If you want to OVERRIDE this behavior, be sure to implement this function.
157          *
158          * in some case, your implementation of OnClose should respect the value of
159          * [Output/SendTextWhenSwitchEng], when this value is true, commit something you
160          * want.
161          *
162          * And no matter in which case, Reset will be called after that.
163          *
164          * CET_ChangeByUser will not be emitted once CET_ChangeByInactivate is emitted.
165          */
166         CET_ChangeByInactivate,
167         /**
168          * when using lost focus
169          * this might be variance case to case. the default behavior is to commit
170          * the preedit, and resetIM.
171          *
172          * Controlled by [Output/DontCommitPreeditWhenUnfocus], this option will not
173          * work for application switch doesn't support async commit.
174          *
175          * So OnClose is called when preedit IS committed (not like CET_ChangeByInactivate,
176          * this behavior cannot be overrided), it give im a chance to choose remember this
177          * word or not.
178          *
179          * Input method need to notice, that the commit is already DONE, do not do extra commit.
180          */
181         CET_LostFocus,
182         /**
183          * when user switch to a different input method by hand
184          * such as ctrl+shift by default, or by ui,
185          * default behavior is reset IM.
186          */
187         CET_SwitchIM,
188         CET_ChangeByUser = CET_SwitchIM, // the old name is not accurate, but keep for compatible.
189     } FcitxIMCloseEventType;
190 
191     typedef boolean(*FcitxIMInit)(void *arg); /**< FcitxIMInit */
192     typedef void (*FcitxIMResetIM)(void *arg); /**< FcitxIMResetIM */
193     typedef INPUT_RETURN_VALUE(*FcitxIMDoInput)(void *arg, FcitxKeySym, unsigned int); /**< FcitxIMDoInput */
194     typedef INPUT_RETURN_VALUE(*FcitxIMGetCandWords)(void *arg); /**< FcitxIMGetCandWords */
195     typedef boolean(*FcitxIMPhraseTips)(void *arg); /**< FcitxIMPhraseTips */
196     typedef void (*FcitxIMSave)(void *arg); /**< FcitxIMSave */
197     typedef void (*FcitxIMReloadConfig)(void *arg); /**< FcitxIMReloadConfig */
198     typedef INPUT_RETURN_VALUE (*FcitxIMKeyBlocker)(void* arg, FcitxKeySym, unsigned int); /**< FcitxIMKeyBlocker */
199     typedef void (*FcitxIMUpdateSurroundingText)(void* arg); /**< FcitxIMKeyBlocker */
200     typedef void (*FcitxIMOnClose)(void* arg, FcitxIMCloseEventType);
201     typedef const char *(*FcitxIMGetSubModeName)(void* arg);
202 
203     /**
204      * a more fexible interface for input method
205      *
206      * @since 4.2.3
207      **/
208     typedef struct _FcitxIMIFace {
209         FcitxIMResetIM ResetIM /**< Reset input method state */;
210         FcitxIMDoInput DoInput /**< process key input */;
211         FcitxIMGetCandWords GetCandWords; /**< get candidate words */
212         FcitxIMPhraseTips PhraseTips; /**< don't use it */
213         FcitxIMSave Save; /**< force save input method data */
214         FcitxIMInit Init; /**< called when switch to this input method */
215         FcitxIMReloadConfig ReloadConfig; /**< reload configuration */
216         FcitxIMKeyBlocker KeyBlocker; /**< block unused key */
217         FcitxIMUpdateSurroundingText UpdateSurroundingText; /**< surrounding text update trigger */
218         FcitxIMDoInput DoReleaseInput; /**< process key release event */
219         FcitxIMOnClose OnClose; /**< process when im being switched away */
220         FcitxIMGetSubModeName GetSubModeName; /**< return a string owned by im */
221         void* padding[61]; /**< padding */
222     } FcitxIMIFace;
223 
224     /**
225      * Fcitx Input method instance
226      **/
227     typedef struct _FcitxIM {
228         /**
229          * The name that can be display on the UI
230          **/
231         char              *strName;
232         /**
233          * icon name used to find icon
234          **/
235         char              *strIconName;
236         /**
237          * reset im status
238          **/
239         FcitxIMResetIM ResetIM;
240         /**
241          * process key input
242          **/
243         FcitxIMDoInput DoInput;
244         /**
245          * update candidate works function
246          **/
247         FcitxIMGetCandWords GetCandWords;
248         /**
249          * phrase tips function
250          **/
251         FcitxIMPhraseTips PhraseTips;
252         /**
253          * save function
254          **/
255         FcitxIMSave Save;
256         /**
257          * init function
258          **/
259         FcitxIMInit Init;
260         /**
261          * reload config function
262          **/
263         FcitxIMReloadConfig ReloadConfig;
264 
265         void* unused; /**< unused */
266         /**
267          * the pointer to im class
268          **/
269         void* klass;
270         /**
271          * the priority order
272          **/
273         int iPriority;
274         /**
275          * Language Code
276          **/
277         char langCode[LANGCODE_LENGTH + 1];
278 
279         /**
280          * uniqueName
281          **/
282         char *uniqueName;
283 
284         /**
285          * input method initialized or not
286          */
287         boolean initialized;
288 
289         /**
290          * Fcitx Addon
291          **/
292         FcitxAddon* owner;
293         /**
294          * reload config function
295          **/
296         FcitxIMKeyBlocker KeyBlocker;
297 
298         FcitxIMUpdateSurroundingText UpdateSurroundingText; /**< called when surrounding text updated */
299 
300         FcitxIMDoInput DoReleaseInput;
301 
302         FcitxIMOnClose OnClose;
303 
304         FcitxIMGetSubModeName GetSubModeName; /**< return a string owned by im */
305         void* padding[7]; /**< padding */
306     } FcitxIM;
307 
308     /** a key event is press or release */
309     typedef enum _FcitxKeyEventType {
310         FCITX_PRESS_KEY,
311         FCITX_RELEASE_KEY
312     } FcitxKeyEventType;
313 
314     /**
315      * Global Input State, including displayed message.
316      **/
317     typedef struct _FcitxInputState FcitxInputState;
318 
319     /**
320      * create a new input state
321      *
322      * @return FcitxInputState*
323      **/
324     FcitxInputState* FcitxInputStateCreate();
325 
326     /**
327      * the string pending commit
328      *
329      * @param input input state
330      * @return char*
331      **/
332     char* FcitxInputStateGetOutputString(FcitxInputState* input);
333 
334     /**
335      * @brief get last commit string
336      *
337      * @param input input state
338      * @return const char*
339      *
340      * @since 4.2.3
341      **/
342     const char* FcitxInputStateGetLastCommitString(FcitxInputState * input);
343 
344     /**
345      * get current input method, return result can be NULL.
346      *
347      * @param instance fcitx instance
348      * @return _FcitxIM*
349      **/
350     struct _FcitxIM* FcitxInstanceGetCurrentIM(struct _FcitxInstance *instance);
351 
352     /**
353      * get input method by name
354      *
355      * @param instance fcitx instance
356      * @param index index
357      * @return _FcitxIM*
358      *
359      * @since 4.2.7
360      **/
361     struct _FcitxIM* FcitxInstanceGetIMByIndex(struct _FcitxInstance* instance, int index);
362 
363     /**
364      * get im index by im name
365      *
366      * @param instance fcitx instance
367      * @param imName im name
368      * @return int im index
369      *
370      * @since 4.2
371      **/
372     int FcitxInstanceGetIMIndexByName(struct _FcitxInstance* instance, const char* imName);
373 
374     /**
375      * get im index by im name
376      *
377      * @param instance fcitx instance
378      * @param imName im name
379      * @return int im index
380      *
381      * @since 4.2.7
382      **/
383     struct _FcitxIM* FcitxInstanceGetIMByName(struct _FcitxInstance* instance, const char* imName);
384 
385     /**
386      * enable im
387      *
388      * @param instance fcitx instance
389      * @param ic input context
390      * @param keepState keep current state or not
391      * @return void
392      **/
393     void FcitxInstanceEnableIM(struct _FcitxInstance* instance, struct _FcitxInputContext* ic, boolean keepState);
394 
395     /**
396      * End Input
397      *
398      * @param instance
399      * @param ic input context
400      * @return void
401      **/
402     void FcitxInstanceCloseIM(struct _FcitxInstance* instance, struct _FcitxInputContext* ic);
403 
404     /**
405      * Change im state between IS_ACTIVE and IS_ENG
406      *
407      * @param instance fcitx instance
408      * @param ic input context
409      * @return void
410      **/
411     void FcitxInstanceChangeIMState(struct _FcitxInstance* instance, struct _FcitxInputContext* ic);
412 
413     /**
414      * reset input state
415      *
416      * @param instance fcitx instance
417      * @return void
418      **/
419     void FcitxInstanceResetInput(struct _FcitxInstance* instance);
420 
421     /**
422      * send a close event, which can be used by standalone module which will do something link reset first.
423      *
424      * @param instance fcitx instance
425      * @param closeEvent close event type
426      * @return void
427      *
428      * @since 4.2.8.4
429      **/
430     void FcitxInstanceSendCloseEvent(struct _FcitxInstance* instance, FcitxIMCloseEventType closeEvent);
431 
432     /**
433      * clean whole input window
434      *
435      * @param instance fcitx instance
436      * @return void
437      **/
438     void FcitxInstanceCleanInputWindow(struct _FcitxInstance *instance);
439 
440     /**
441      * clean preedit string and aux up
442      *
443      * @param instance fcitx instance
444      * @return void
445      **/
446     void FcitxInstanceCleanInputWindowUp(struct _FcitxInstance *instance);
447 
448     /**
449      * clean candidate word list and aux down
450      *
451      * @param instance fcitx instance
452      * @return void
453      **/
454     void FcitxInstanceCleanInputWindowDown(struct _FcitxInstance *instance);
455 
456     /**
457      * Sometimes, we use INPUT_RETURN_VALUE not from ProcessKey, so use this function to do the correct thing.
458      *
459      * @param instance fcitx instance
460      * @param retVal input return val
461      * @return void
462      **/
463     void FcitxInstanceProcessInputReturnValue(
464         struct _FcitxInstance* instance,
465         INPUT_RETURN_VALUE retVal
466     );
467 
468     /**
469      * register a new input method
470      *
471      * @param instance fcitx instance
472      * @param imclass pointer to input method class
473      * @param uniqueName uniqueName which cannot be duplicated to others
474      * @param name input method name
475      * @param iconName icon name
476      * @param Init init callback
477      * @param ResetIM reset callback
478      * @param DoInput do input callback
479      * @param GetCandWords get candidate words callback
480      * @param PhraseTips phrase tips callback
481      * @param Save save callback
482      * @param ReloadConfig reload config callback
483      * @param KeyBlocker key blocker callback
484      * @param priority order of this input method
485      * @param langCode language code for this input method
486      * @return void
487      **/
488     void FcitxInstanceRegisterIM(struct _FcitxInstance *instance,
489                            void *imclass,
490                            const char* uniqueName,
491                            const char* name,
492                            const char* iconName,
493                            FcitxIMInit Init,
494                            FcitxIMResetIM ResetIM,
495                            FcitxIMDoInput DoInput,
496                            FcitxIMGetCandWords GetCandWords,
497                            FcitxIMPhraseTips PhraseTips,
498                            FcitxIMSave Save,
499                            FcitxIMReloadConfig ReloadConfig,
500                            FcitxIMKeyBlocker KeyBlocker,
501                            int priority,
502                            const char *langCode
503                           );
504 
505     /**
506      * register a new input method
507      *
508      * @param instance fcitx instance
509      * @param imclass pointer to input method class
510      * @param uniqueName uniqueName which cannot be duplicated to others
511      * @param name input method name
512      * @param iconName icon name
513      * @param iface interface
514      * @param priority order of this input method
515      * @param langCode language code for this input method
516      * @return void
517      *
518      * @see FcitxInstanceRegisterIMv2
519      *
520      * @since 4.2.3
521      **/
522     void FcitxInstanceRegisterIMv2(struct _FcitxInstance *instance,
523                        void *imclass,
524                        const char* uniqueName,
525                        const char* name,
526                        const char* iconName,
527                        FcitxIMIFace iface,
528                        int priority,
529                        const char *langCode
530                       );
531 
532     /**
533      * process a key event, should only used by frontend
534      *
535      * @param instance fcitx instance
536      * @param event event type
537      * @param timestamp timestamp
538      * @param sym keysym
539      * @param state key state
540      * @return INPUT_RETURN_VALUE
541      **/
542     INPUT_RETURN_VALUE FcitxInstanceProcessKey(struct _FcitxInstance* instance, FcitxKeyEventType event, long unsigned int timestamp, FcitxKeySym sym, unsigned int state);
543 
544     /**
545      * another half part for process key, will be called by FcitxInstanceProcessKey()
546      *
547      * @param instance fcitx instance
548      * @param retVal last return value
549      * @param event event type
550      * @param timestamp timestamp
551      * @param sym keysym
552      * @param state key state
553      * @return INPUT_RETURN_VALUE
554      **/
555     INPUT_RETURN_VALUE FcitxInstanceDoInputCallback(
556         struct _FcitxInstance* instance,
557         INPUT_RETURN_VALUE retVal,
558         FcitxKeyEventType event,
559         long unsigned int timestamp,
560         FcitxKeySym sym,
561         unsigned int state);
562 
563 
564     /**
565      * @brief choose candidate by index
566      *
567      * @param instance instance
568      * @param index idx
569      * @return INPUT_RETURN_VALUE
570      **/
571     void FcitxInstanceChooseCandidateByIndex(
572         struct _FcitxInstance* instance,
573         int index);
574 
575     /**
576      * send a new key event to client
577      *
578      * @param instance fcitx instance
579      * @param ic input context
580      * @param event event tpye
581      * @param sym keysym
582      * @param state key state
583      * @return void
584      **/
585     void FcitxInstanceForwardKey(struct _FcitxInstance* instance, struct _FcitxInputContext* ic, FcitxKeyEventType event, FcitxKeySym sym, unsigned int state);
586 
587     /**
588      * save all input method data
589      *
590      * @param instance fcitx instance
591      * @return void
592      **/
593     void FcitxInstanceSaveAllIM(struct _FcitxInstance* instance);
594 
595     /**
596      * reload only an addon's configuration, there are some short hand for reloading
597      * other configuration, "global" for ~/.config/fcitx/config, "profile" for
598      * ~/.config/fcitx/profile, "addon" for addon info. "ui" for current user interface
599      * Input method unique can be also used here.
600      *
601      * @param instance fcitx instance
602      * @param addon addon name
603      * @return void
604      *
605      * @since 4.2.7
606      **/
607     void FcitxInstanceReloadAddonConfig(struct _FcitxInstance* instance, const char* addon);
608 
609     /**
610      * reload all config
611      *
612      * @param instance fcitx instance
613      * @return void
614      **/
615     void FcitxInstanceReloadConfig(struct _FcitxInstance* instance);
616 
617     /**
618      * switch to input method by index, if index is zero, it will be skipped
619      *
620      * @deprecated
621      *
622      * @see FcitxInstanceSwitchIMByIndex
623      *
624      * @param instance fcitx instance
625      * @param index input method index
626      * @return void
627      **/
628     FCITX_DEPRECATED void FcitxInstanceSwitchIM(struct _FcitxInstance* instance, int index);
629 
630 
631     /**
632      * switch to a input method by name, name need to be valid, otherwise it have no effect
633      * And if the index is zero, the state will automatically change to inactive
634      *
635      * @param instance fcitx instance
636      * @param name ...
637      * @return void
638      *
639      * @since 4.2.4
640      **/
641     void FcitxInstanceSwitchIMByName(struct _FcitxInstance* instance, const char* name);
642 
643     /**
644      * switch to a input method by index, index need to be valid, otherwise it have no effect
645      * And if the object index is zero, the state will automatically change to inactive
646      * -1 means scroll forward, and -2 means scroll backward.
647      * -3 means scroll forward without first one, -4 mean scroll backward without first one.
648      *
649      *
650      * @param instance fcitx instance
651      * @param name ...
652      * @return void
653      *
654      * @since 4.2.4
655      **/
656     void FcitxInstanceSwitchIMByIndex(struct _FcitxInstance* instance, int index);
657 
658     /**
659      * check is choose key or not, if so, return the choose index
660      *
661      * @param sym keysym
662      * @param state keystate
663      * @param strChoose choose key string
664      * @return int
665      **/
666     int FcitxHotkeyCheckChooseKey(FcitxKeySym sym, unsigned int state, const char* strChoose);
667 
668     /**
669      * check is choose key or not, if so, return the choose index
670      *
671      * @param sym keysym
672      * @param state keystate
673      * @param strChoose choose key string
674      * @param candState candidate keystate
675      * @return int
676      **/
677     int FcitxHotkeyCheckChooseKeyAndModifier(FcitxKeySym sym, unsigned int state, const char* strChoose, int candState);
678 
679     /**
680      * ...
681      *
682      * @param input ...
683      * @return _FcitxCandidateWordList*
684      **/
685     struct _FcitxCandidateWordList* FcitxInputStateGetCandidateList(FcitxInputState* input);
686 
687     /**
688      * get current is in remind or not.
689      *
690      * @param input input state
691      * @return remind state
692      **/
693     boolean FcitxInputStateGetIsInRemind(FcitxInputState* input);
694 
695     /**
696      * set remind state
697      *
698      * @param input input state
699      * @param isInRemind remind state
700      * @return void
701      **/
702     void FcitxInputStateSetIsInRemind(FcitxInputState* input, boolean isInRemind);
703 
704     /**
705      * get current key will be only processed by DoInput or not.
706      *
707      * @param input input state
708      * @return DoInput Only state
709      **/
710     boolean FcitxInputStateGetIsDoInputOnly(FcitxInputState* input);
711 
712     /**
713      * set current key will be only processed by DoInput or not.
714      *
715      * @param input input state
716      * @param isDoInputOnly DoInput Only state
717      * @return void
718      **/
719     void FcitxInputStateSetIsDoInputOnly(FcitxInputState* input, boolean isDoInputOnly);
720 
721     /**
722      * get a writable raw input buffer, which is used as a hint for other module
723      *
724      * @param input input state
725      * @return char*
726      **/
727     char* FcitxInputStateGetRawInputBuffer(FcitxInputState* input);
728 
729     /**
730      * get current cursor position, offset is counted by byte in Preedit String
731      *
732      * @param input input state
733      * @return current cursor position
734      **/
735     int FcitxInputStateGetCursorPos(FcitxInputState* input);
736 
737     /**
738      * set current cursor position, offset is counted by byte in Preedit String
739      *
740      * @param input input state
741      * @param cursorPos current cursor position
742      * @return void
743      **/
744     void FcitxInputStateSetCursorPos(FcitxInputState* input, int cursorPos);
745 
746     /**
747      * get client cursor position, which is similar to cursor position, but used with client preedit
748      *
749      * @param input input state
750      * @return current client cursor position
751      **/
752     int FcitxInputStateGetClientCursorPos(FcitxInputState* input);
753 
754     /**
755      * set client cursor position, which is similar to cursor position, but used with client preedit
756      *
757      * @param input input state
758      * @param cursorPos current client cursor position
759      * @return void
760      **/
761     void FcitxInputStateSetClientCursorPos(FcitxInputState* input, int cursorPos);
762 
763     /**
764      * get auxiliary string displayed in the upper side of input panel
765      *
766      * @param input input state
767      * @return upper auxiliary string
768      **/
769     FcitxMessages* FcitxInputStateGetAuxUp(FcitxInputState* input);
770 
771     /**
772      * get auxiliary string displayed in the lower side of input panel
773      *
774      * @param input input state
775      * @return lower auxiliary string
776      **/
777     FcitxMessages* FcitxInputStateGetAuxDown(FcitxInputState* input);
778 
779     /**
780      * get preedit string which will be displayed in the input panel with a cursor
781      *
782      * @param input input state
783      * @return preedit string
784      **/
785     FcitxMessages* FcitxInputStateGetPreedit(FcitxInputState* input);
786 
787     /**
788      * get preedit string which will be displayed in the client window with a cursor
789      *
790      * @param input input state
791      * @return client preedit string
792      **/
793     FcitxMessages* FcitxInputStateGetClientPreedit(FcitxInputState* input);
794 
795     /**
796      * get current raw input buffer size
797      *
798      * @param input input state
799      * @return raw input buffer size
800      **/
801     int FcitxInputStateGetRawInputBufferSize(FcitxInputState* input);
802 
803     /**
804      * set current raw input buffer size
805      *
806      * @param input input state
807      * @param size raw input buffer size
808      * @return void
809      **/
810     void FcitxInputStateSetRawInputBufferSize(FcitxInputState* input, int size);
811 
812     /**
813      * get cursor is visible or not
814      *
815      * @param input input state
816      * @return cursor visibility
817      **/
818     boolean FcitxInputStateGetShowCursor(FcitxInputState* input);
819 
820     /**
821      * set cursor is visible or not
822      *
823      * @param input input state
824      * @param showCursor cursor visibility
825      * @return void
826      **/
827     void FcitxInputStateSetShowCursor(FcitxInputState* input, boolean showCursor);
828 
829     /**
830      * get last char is single char or not
831      *
832      * @param input input state
833      * @return int
834      **/
835     int FcitxInputStateGetLastIsSingleChar(FcitxInputState* input);
836 
837     /**
838      * set last char is single char or not
839      *
840      * @param input input state
841      * @param lastIsSingleChar ...
842      * @return void
843      **/
844     void FcitxInputStateSetLastIsSingleChar(FcitxInputState* input, int lastIsSingleChar);
845 
846     /**
847      * set keycode for current key event
848      *
849      * @param input input state
850      * @param value keycode
851      * @return void
852      **/
853     void FcitxInputStateSetKeyCode( FcitxInputState* input, uint32_t value );
854 
855     /**
856      * set keysym for current key event
857      *
858      * @param input input state
859      * @param value sym
860      * @return void
861      **/
862     void FcitxInputStateSetKeySym( FcitxInputState* input, uint32_t value );
863 
864     /**
865      * set keystate for current key state
866      *
867      * @param input input state
868      * @param state key state
869      * @return void
870      **/
871     void FcitxInputStateSetKeyState( FcitxInputState* input, uint32_t state );
872 
873     /**
874      * get keycode for current key event
875      *
876      * @param input input state
877      * @return uint32_t
878      **/
879     uint32_t FcitxInputStateGetKeyCode( FcitxInputState* input);
880 
881     /**
882      * get keysym for current key event
883      *
884      * @param input input state
885      * @return uint32_t
886      **/
887     uint32_t FcitxInputStateGetKeySym( FcitxInputState* input);
888 
889     /**
890      * get keystate for current key event
891      *
892      * @param input input state
893      * @return uint32_t
894      **/
895     uint32_t FcitxInputStateGetKeyState( FcitxInputState* input);
896 
897     /**
898      * get input method from input method list by name
899      *
900      * @param instance fcitx instance
901      * @param imas from available list or full list
902      * @param name input method name
903      * @return input method pointer
904      **/
905     FcitxIM* FcitxInstanceGetIMFromIMList(struct _FcitxInstance* instance, FcitxIMAvailableStatus imas, const char* name);
906 
907     /**
908      * update current input method list
909      *
910      * @param instance fcitx instance
911      * @return void
912      **/
913     void FcitxInstanceUpdateIMList(struct _FcitxInstance* instance);
914 
915     /**
916      * notify surrounding text changed to im
917      *
918      * @param instance instance
919      * @param ic ic
920      * @return void
921      **/
922     void FcitxInstanceNotifyUpdateSurroundingText(struct _FcitxInstance* instance, struct _FcitxInputContext* ic);
923 
924     /**
925      * an standard key blocker, block all the key that cause cursor move when raw input buffer is not empty.
926      *
927      * @param input input state
928      * @param key keysym
929      * @param state key state
930      * @return INPUT_RETURN_VALUE
931      **/
932     INPUT_RETURN_VALUE FcitxStandardKeyBlocker(FcitxInputState* input, FcitxKeySym key, unsigned int state);
933 
934     /**
935      * set local input method name
936      *
937      * @param instance Fcitx Instance
938      * @param ic input context
939      * @param imname im name
940      * @return void
941      **/
942     void FcitxInstanceSetLocalIMName(struct _FcitxInstance* instance, struct _FcitxInputContext* ic, const char* imname);
943 
944     /**
945      * unregister an im entry
946      *
947      * @param instance Fcitx Instance
948      * @param name imname
949      * @return void
950      *
951      * @since 4.2.6
952      */
953     void FcitxInstanceUnregisterIM(struct _FcitxInstance* instance, const char* name);
954 
955     /**
956      * show current input method information, notably it will use GetSubModeName to show the
957      * sub mode name
958      *
959      * There need to be no other aux preedit string, otherwise it will be rejected.
960      *
961      * @param instance Fcitx Instance
962      * @since 4.2.9.2
963      */
964     void FcitxInstanceShowCurrentIMInfo(struct _FcitxInstance* instance);
965 
966 #ifdef __cplusplus
967 }
968 #endif
969 
970 #endif
971 
972 /**
973  * @}
974  */
975 // kate: indent-mode cstyle; space-indent on; indent-width 0;
976