~ubuntu-branches/ubuntu/trusty/fcitx/trusty-proposed

« back to all changes in this revision

Viewing changes to src/lib/fcitx/ime.h

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-02-10 17:03:56 UTC
  • mfrom: (1.3.18) (33.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130210170356-2yuv6xy3ed378kn0
Tags: 1:4.2.7-1
* New upstream release.
* New binary packages:
  - fcitx-libs-gclient: D-Bus client library for Glib
  - fcitx-libs-qt: D-Bus client library for Qt
  - fcitx-module-quickphrase-editor: Quick Phrase editor module

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
36
 
 * 
 
36
 *
37
37
 * The input method engine process key event inside "DoInput".
38
 
 * 
 
38
 *
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.
41
 
 * 
 
41
 *
42
42
 * If a key event goes through all phase and still the state is IRV_TO_PROCESS, it will be forwarded.
43
 
 * 
 
43
 *
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.
46
 
 * 
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.
 
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
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...).
50
 
 * 
 
50
 *
51
51
 * DoInput, Update Candidates, Key Blocker are belongs to input method engine, other can be registered by other addon.
52
52
 */
53
53
#ifndef _FCITX_IME_H_
135
135
        void  (*Destroy)(void *arg); /**< interface for destroy all input method created by this class */
136
136
    } FcitxIMClass;
137
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_ChangeByInactivate,
 
165
        /**
 
166
         * when using lost focus
 
167
         * this might be variance case to case. the default behavior is to commit
 
168
         * the preedit, and resetIM.
 
169
         *
 
170
         * Controlled by [Output/DontCommitPreeditWhenUnfocus], this option will not
 
171
         * work for application switch doesn't support async commit.
 
172
         *
 
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
 
175
         * word or not.
 
176
         *
 
177
         * Input method need to notice, that the commit is already DONE, do not do extra commit.
 
178
         */
 
179
        CET_LostFocus,
 
180
        /**
 
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.
 
184
         */
 
185
        CET_ChangeByUser,
 
186
    } FcitxIMCloseEventType;
 
187
 
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);
147
198
 
148
199
    /**
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 */
165
217
    } FcitxIMIFace;
166
218
 
167
219
    /**
242
294
 
243
295
        FcitxIMDoInput DoReleaseInput;
244
296
 
 
297
        FcitxIMOnClose OnClose;
 
298
 
245
299
        void* padding[8]; /**< padding */
246
300
    } FcitxIM;
247
301
 
282
336
    const char* FcitxInputStateGetLastCommitString(FcitxInputState * input);
283
337
 
284
338
    /**
285
 
     * get current input method
 
339
     * get current input method, return result can be NULL.
286
340
     *
287
341
     * @param instance fcitx instance
288
342
     * @return _FcitxIM*
290
344
    struct _FcitxIM* FcitxInstanceGetCurrentIM(struct _FcitxInstance *instance);
291
345
 
292
346
    /**
 
347
     * get input method by name
 
348
     *
 
349
     * @param instance fcitx instance
 
350
     * @param index index
 
351
     * @return _FcitxIM*
 
352
     *
 
353
     * @since 4.2.7
 
354
     **/
 
355
    struct _FcitxIM* FcitxInstanceGetIMByIndex(struct _FcitxInstance* instance, int index);
 
356
 
 
357
    /**
 
358
     * get im index by im name
 
359
     *
 
360
     * @param instance fcitx instance
 
361
     * @param imName im name
 
362
     * @return int im index
 
363
     *
 
364
     * @since 4.2
 
365
     **/
 
366
    int FcitxInstanceGetIMIndexByName(struct _FcitxInstance* instance, const char* imName);
 
367
 
 
368
    /**
 
369
     * get im index by im name
 
370
     *
 
371
     * @param instance fcitx instance
 
372
     * @param imName im name
 
373
     * @return int im index
 
374
     *
 
375
     * @since 4.2.7
 
376
     **/
 
377
    struct _FcitxIM* FcitxInstanceGetIMByName(struct _FcitxInstance* instance, const char* imName);
 
378
 
 
379
    /**
293
380
     * enable im
294
381
     *
295
382
     * @param instance fcitx instance
489
576
    void FcitxInstanceSaveAllIM(struct _FcitxInstance* instance);
490
577
 
491
578
    /**
 
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.
 
583
     *
 
584
     * @param instance fcitx instance
 
585
     * @param addon addon name
 
586
     * @return void
 
587
     *
 
588
     * @since 4.2.7
 
589
     **/
 
590
    void FcitxInstanceReloadAddonConfig(struct _FcitxInstance* instance, const char* addon);
 
591
 
 
592
    /**
492
593
     * reload all config
493
594
     *
494
595
     * @param instance fcitx instance
507
608
     * @param index input method index
508
609
     * @return void
509
610
     **/
510
 
    void FcitxInstanceSwitchIM(struct _FcitxInstance* instance, int index);
 
611
    FCITX_DEPRECATED void FcitxInstanceSwitchIM(struct _FcitxInstance* instance, int index);
511
612
 
512
613
 
513
614
    /**
525
626
    /**
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.
529
631
     *
530
632
     *
531
633
     * @param instance fcitx instance
544
646
     * @param strChoose choose key string
545
647
     * @return int
546
648
     **/
547
 
    int FcitxHotkeyCheckChooseKey(FcitxKeySym sym, int state, const char* strChoose);
 
649
    int FcitxHotkeyCheckChooseKey(FcitxKeySym sym, unsigned int state, const char* strChoose);
548
650
 
549
651
    /**
550
652
     * check is choose key or not, if so, return the choose index
555
657
     * @param candState candidate keystate
556
658
     * @return int
557
659
     **/
558
 
    int FcitxHotkeyCheckChooseKeyAndModifier(FcitxKeySym sym, int state, const char* strChoose, int candState);
559
 
 
560
 
    /**
561
 
     * get im index by im name
562
 
     *
563
 
     * @param instance fcitx instance
564
 
     * @param imName im name
565
 
     * @return int im index
566
 
     *
567
 
     * @since 4.2
568
 
     **/
569
 
    int FcitxInstanceGetIMIndexByName(struct _FcitxInstance* instance, const char* imName);
 
660
    int FcitxHotkeyCheckChooseKeyAndModifier(FcitxKeySym sym, unsigned int state, const char* strChoose, int candState);
570
661
 
571
662
    /**
572
663
     * ...
826
917
    /**
827
918
     * set local input method name
828
919
     *
829
 
     * @param ic name
 
920
     * @param instance Fcitx Instance
 
921
     * @param ic input context
830
922
     * @param imname im name
831
923
     * @return void
832
924
     **/
833
925
    void FcitxInstanceSetLocalIMName(struct _FcitxInstance* instance, struct _FcitxInputContext* ic, const char* imname);
834
926
 
 
927
    /**
 
928
     * unregister an im entry
 
929
     *
 
930
     * @param instance Fcitx Instance
 
931
     * @param name imname
 
932
     * @return void
 
933
     *
 
934
     * @since 4.2.6
 
935
     */
 
936
    void FcitxInstanceUnregisterIM(struct _FcitxInstance* instance, const char* name);
 
937
 
835
938
#ifdef __cplusplus
836
939
}
837
940
#endif