33
33
* The input method is key event centric application. When a key event comes to fcitx,
34
34
* the process handling the keyboard event can be separated into 7 phases, PreInput, DoInput, Update Candidates, Prev/Next Page
35
35
* PostInput, Hotkey, and key blocker.
37
37
* The input method engine process key event inside "DoInput".
39
39
* Each phase will change the INPUT_RETURN_VALUE, if INPUT_RETURN_VALUE is non-zero (non IRV_TO_PROCESS), the following
40
40
* phases will not run.
42
42
* If a key event goes through all phase and still the state is IRV_TO_PROCESS, it will be forwarded.
44
44
* When it comes to update candidates, if the flag contains IRV_FLAG_UPDATE_CANDIDATE_WORDS, it will trigger the GetCandWords
45
45
* of input method engine and clean up all stiring in the input window, after that, it will trigger update candidates hook.
47
* Key blocker is useful if you want to post input phase to do something, but you don't want forward key if they do nothing.
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
48
* There is an default implemention inside fcitx, it will blocks key when raw input buffer is not empty. Those keys
49
49
* contains direction key(left/right..), key will cause something input (a,b,c...), key will cause cursor move (home/end...).
51
51
* DoInput, Update Candidates, Key Blocker are belongs to input method engine, other can be registered by other addon.
53
53
#ifndef _FCITX_IME_H_
135
135
void (*Destroy)(void *arg); /**< interface for destroy all input method created by this class */
139
* Fcitx Input Method class, it can register more than one input
140
* method in create function
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 */
153
typedef enum _FcitxIMCloseEventType {
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.
158
* in some case, your implementation of OnClose should respect the value of
159
* [Output/SendTextWhenSwitchEng], when this value is true, commit something you
162
* And no matter in which case, Reset will be called after that.
164
CET_ChangeByInactivate,
166
* when using lost focus
167
* this might be variance case to case. the default behavior is to commit
168
* the preedit, and resetIM.
170
* Controlled by [Output/DontCommitPreeditWhenUnfocus], this option will not
171
* work for application switch doesn't support async commit.
173
* So OnClose is called when preedit IS committed (not like CET_ChangeByInactivate,
174
* this behavior cannot be overrided), it give im a chance to choose remember this
177
* Input method need to notice, that the commit is already DONE, do not do extra commit.
181
* when user switch to a different input method by hand
182
* such as ctrl+shift by default, or by ui,
183
* not implemented yet, default behavior is reset IM.
186
} FcitxIMCloseEventType;
138
188
typedef boolean(*FcitxIMInit)(void *arg); /**< FcitxIMInit */
139
189
typedef void (*FcitxIMResetIM)(void *arg); /**< FcitxIMResetIM */
140
190
typedef INPUT_RETURN_VALUE(*FcitxIMDoInput)(void *arg, FcitxKeySym, unsigned int); /**< FcitxIMDoInput */
144
194
typedef void (*FcitxIMReloadConfig)(void *arg); /**< FcitxIMReloadConfig */
145
195
typedef INPUT_RETURN_VALUE (*FcitxIMKeyBlocker)(void* arg, FcitxKeySym, unsigned int); /**< FcitxIMKeyBlocker */
146
196
typedef void (*FcitxIMUpdateSurroundingText)(void* arg); /**< FcitxIMKeyBlocker */
197
typedef void (*FcitxIMOnClose)(void* arg, FcitxIMCloseEventType);
149
200
* a more fexible interface for input method
160
211
FcitxIMReloadConfig ReloadConfig; /**< reload configuration */
161
212
FcitxIMKeyBlocker KeyBlocker; /**< block unused key */
162
213
FcitxIMUpdateSurroundingText UpdateSurroundingText; /**< surrounding text update trigger */
163
FcitxIMDoInput DoReleaseInput;
164
void* padding[63]; /**< padding */
214
FcitxIMDoInput DoReleaseInput; /**< process key release event */
215
FcitxIMOnClose OnClose; /**< process when im being switched away */
216
void* padding[62]; /**< padding */
290
344
struct _FcitxIM* FcitxInstanceGetCurrentIM(struct _FcitxInstance *instance);
347
* get input method by name
349
* @param instance fcitx instance
355
struct _FcitxIM* FcitxInstanceGetIMByIndex(struct _FcitxInstance* instance, int index);
358
* get im index by im name
360
* @param instance fcitx instance
361
* @param imName im name
362
* @return int im index
366
int FcitxInstanceGetIMIndexByName(struct _FcitxInstance* instance, const char* imName);
369
* get im index by im name
371
* @param instance fcitx instance
372
* @param imName im name
373
* @return int im index
377
struct _FcitxIM* FcitxInstanceGetIMByName(struct _FcitxInstance* instance, const char* imName);
295
382
* @param instance fcitx instance
489
576
void FcitxInstanceSaveAllIM(struct _FcitxInstance* instance);
579
* reload only an addon's configuration, there are some short hand for reloading
580
* other configuration, "global" for ~/.config/fcitx/config, "profile" for
581
* ~/.config/fcitx/profile, "addon" for addon info. "ui" for current user interface
582
* Input method unique can be also used here.
584
* @param instance fcitx instance
585
* @param addon addon name
590
void FcitxInstanceReloadAddonConfig(struct _FcitxInstance* instance, const char* addon);
492
593
* reload all config
494
595
* @param instance fcitx instance
526
627
* switch to a input method by index, index need to be valid, otherwise it have no effect
527
628
* And if the object index is zero, the state will automatically change to inactive
528
* -1 means scroll forward, and -2 means scroll back.
629
* -1 means scroll forward, and -2 means scroll backward.
630
* -3 means scroll forward without first one, -4 mean scroll backward without first one.
531
633
* @param instance fcitx instance
544
646
* @param strChoose choose key string
547
int FcitxHotkeyCheckChooseKey(FcitxKeySym sym, int state, const char* strChoose);
649
int FcitxHotkeyCheckChooseKey(FcitxKeySym sym, unsigned int state, const char* strChoose);
550
652
* check is choose key or not, if so, return the choose index
555
657
* @param candState candidate keystate
558
int FcitxHotkeyCheckChooseKeyAndModifier(FcitxKeySym sym, int state, const char* strChoose, int candState);
561
* get im index by im name
563
* @param instance fcitx instance
564
* @param imName im name
565
* @return int im index
569
int FcitxInstanceGetIMIndexByName(struct _FcitxInstance* instance, const char* imName);
660
int FcitxHotkeyCheckChooseKeyAndModifier(FcitxKeySym sym, unsigned int state, const char* strChoose, int candState);
827
918
* set local input method name
920
* @param instance Fcitx Instance
921
* @param ic input context
830
922
* @param imname im name
833
925
void FcitxInstanceSetLocalIMName(struct _FcitxInstance* instance, struct _FcitxInputContext* ic, const char* imname);
928
* unregister an im entry
930
* @param instance Fcitx Instance
936
void FcitxInstanceUnregisterIM(struct _FcitxInstance* instance, const char* name);
835
938
#ifdef __cplusplus