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 ui.h
28  *
29  * this file provides the UI component for Fcitx, fcitx doesn't provides any platform specific
30  * UI element, all UI are implemented via Fcitx's addon.
31  *
32  * For input method and module, they can register UI component and get native UI for free from
33  * Fcitx.
34  *
35  * There is two abstract UI element in Fcitx, one is Status, and the other is Menu. Both of them
36  * require a unique name in Fcitx. Usually this name is meaningful in order to increase
37  * readability.
38  *
39  * For status, due to backward compatible problem, there are two kinds of status, simple and complex
40  * one. Status have three property, short description, long description and icon name. The actual
41  * UI depends on specific UI implementation, but usually, status are displayed as a button, with
42  * an icon. Icon name can be absolute png file path. All description need to be I18N'ed by addon
43  * themselves.
44  *
45  * For menu, each menu item contains a string, like status, it need to I18N'ed before set. Though
46  * there is different type in menu item, DONOT use submenu or divline, they are not supported by
47  * specific implementation, and suppose to be only used internally.
48  *
49  * For display string, there are five field can be used to display string:
50  *  - Client Preedit
51  *  - Preedit
52  *  - AuxUp
53  *  - AuxDown
54  *  - Candidate words
55  *
56  * In spite of candidate words, other four fields are FcitxMessages pointer. FcitxMessages is
57  * basically a fixed length string array. Each string inside FcitxMessages can have a type.
58  */
59 
60 #ifndef _FCITX_UI_H_
61 #define _FCITX_UI_H_
62 
63 #include <stdarg.h>
64 #include <fcitx/fcitx.h>
65 #include <fcitx-config/fcitx-config.h>
66 #include <fcitx-utils/utf8.h>
67 #include <fcitx-utils/utarray.h>
68 
69 #ifdef __cplusplus
70 
71 extern "C" {
72 #endif
73 
74 #define MESSAGE_TYPE_COUNT 7 /**< message color type count */
75 
76 #define MESSAGE_MAX_CHARNUM (150)   /**< Maximum length per-message */
77 
78 #define MESSAGE_MAX_LENGTH  (MESSAGE_MAX_CHARNUM*UTF8_MAX_LENGTH)   /**< maximum byte per message */
79 
80 #define MAX_MESSAGE_COUNT 64 /**< maximum message string number */
81 
82     struct _FcitxAddon;
83 
84     /** fcitx menu item */
85     typedef struct _FcitxMenuItem FcitxMenuItem;
86     struct _FcitxUIMenu;
87 
88     /** fcitx menu state */
89     typedef enum _FcitxMenuState {
90         MENU_ACTIVE = 0,
91         MENU_INACTIVE = 1
92     } FcitxMenuState;
93 
94     /** fcitx menu item type */
95     typedef enum _FcitxMenuItemType {
96         MENUTYPE_SIMPLE,
97         MENUTYPE_SUBMENU,/**< unfortunately this is only used internal, don't use it in your code */
98         MENUTYPE_DIVLINE
99     } FcitxMenuItemType;
100 
101 
102     /** menu action prototype */
103     typedef boolean (*FcitxMenuActionFunction)(struct _FcitxUIMenu *arg, int index);
104     /** menu update prototype */
105     typedef void    (*FcitxUpdateMenuFunction)(struct _FcitxUIMenu *arg);
106 
107     /**
108      * a menu entry in a menu.
109      **/
110     struct _FcitxMenuItem {
111         /**
112          * The displayed string
113          **/
114         char *tipstr;
115         /**
116          * Can be used by ui to mark it's selected or not.
117          **/
118         int  isselect;
119         /**
120          * The type of menu shell
121          **/
122         FcitxMenuItemType type;
123         /**
124          * the submenu to this entry
125          **/
126         struct _FcitxUIMenu *subMenu;
127 
128         union {
129             void* data;
130             int dummy[2];
131         };
132 
133         int padding[14]; /**< padding */
134     };
135 
136     /**
137      * Fcitx Menu Component, a UI doesn't need to support it,
138      *        This struct is used by other module to register a menu.
139      **/
140     struct _FcitxUIMenu {
141         /**
142          * shell entries for this menu
143          **/
144         UT_array shell;
145         /**
146          * menu name, can be displayed on the ui
147          **/
148         char *name;
149         /**
150          * you might want to bind the menu on a status icon, but this is only a hint,
151          * depends on the ui implementation
152          **/
153         char *candStatusBind;
154         /**
155          * update the menu content
156          **/
157         FcitxUpdateMenuFunction UpdateMenu;
158         /**
159          * function for process click on a menu entry
160          **/
161         FcitxMenuActionFunction MenuAction;
162         /**
163          * private data for this menu
164          **/
165         void *priv;
166         /**
167          * ui implementation private
168          **/
169         void *uipriv[2];
170         /**
171          * this is sub menu or not
172          **/
173         boolean isSubMenu;
174         /**
175          * mark of this menu
176          **/
177         int mark;
178 
179         boolean visible; /**< menu is visible or not */
180 
181         int padding[15]; /**< padding */
182     };
183 
184     /**
185      * Fcitx Status icon to be displayed on the UI
186      **/
187     struct _FcitxUIStatus {
188         /**
189          * status name, will not displayed on the UI.
190          **/
191         char *name;
192         /**
193          * short desription for this status, can be displayed on the UI
194          **/
195         char *shortDescription;
196         /**
197          * long description for this status, can be displayed on the UI
198          **/
199         char *longDescription;
200         /**
201          * toggle function
202          **/
203         void (*toggleStatus)(void *arg);
204         /**
205          * get current value function
206          **/
207         boolean(*getCurrentStatus)(void *arg);
208         /**
209          * private data for the UI implementation
210          **/
211         void *uipriv[2];
212         /**
213          * extra argument for tooglefunction
214          **/
215         void* arg;
216         /**
217          * visible
218          */
219         boolean visible;
220 
221         int padding[16]; /**< padding */
222     };
223 
224 
225     /**
226      * Fcitx Status icon to be displayed on the UI
227      **/
228     struct _FcitxUIComplexStatus {
229         /**
230          * status name, will not displayed on the UI.
231          **/
232         char *name;
233         /**
234          * short desription for this status, can be displayed on the UI
235          **/
236         char *shortDescription;
237         /**
238          * long description for this status, can be displayed on the UI
239          **/
240         char *longDescription;
241         /**
242          * toggle function
243          **/
244         void (*toggleStatus)(void *arg);
245         /**
246          * get current value function
247          **/
248         const char*(*getIconName)(void *arg);
249         /**
250          * private data for the UI implementation
251          **/
252         void *uipriv[2];
253         /**
254          * extra argument for tooglefunction
255          **/
256         void* arg;
257         /**
258          * visible
259          */
260         boolean visible;
261 
262         int padding[16]; /**< padding */
263     };
264 
265     struct _FcitxInstance;
266 
267     /** message type and flags */
268     typedef enum _FcitxMessageType {
269         MSG_TYPE_FIRST = 0,
270         MSG_TYPE_LAST = 6,
271         MSG_TIPS = 0,           /**< Hint Text */
272         MSG_INPUT = 1,          /**< User Input */
273         MSG_INDEX = 2,          /**< Index Number, only for use internally */
274         MSG_CANDIATE_CURSOR = 3,/**< candidate cursor */
275         MSG_FIRSTCAND = MSG_CANDIATE_CURSOR,      /**< deprecated */
276         MSG_USERPHR = 4,        /**< User Phrase */
277         MSG_CODE = 5,           /**< Typed character */
278         MSG_OTHER = 6,          /**< Other Text */
279         MSG_NOUNDERLINE = (1 << 3), /**< backward compatible, no underline is a flag */
280         MSG_HIGHLIGHT = (1 << 4), /**< highlight the preedit */
281         MSG_DONOT_COMMIT_WHEN_UNFOCUS = (1 << 5), /**< backward compatible */
282         MSG_REGULAR_MASK = 0x7 /**< regular color type mask */
283     } FcitxMessageType;
284 
285     /** an array of message for display */
286     typedef struct _FcitxMessages FcitxMessages;
287     /** Fcitx Menu */
288     typedef struct _FcitxUIMenu FcitxUIMenu;
289     /** Fcitx Status, supports active/inactive */
290     typedef struct _FcitxUIStatus FcitxUIStatus;
291     /** Fcitx Complex Status, ability to use custom icon */
292     typedef struct _FcitxUIComplexStatus FcitxUIComplexStatus;
293 
294     /**
295      * user interface implementation
296      **/
297     typedef struct _FcitxUI {
298         /**
299          * construct function for this ui
300          */
301         void* (*Create)(struct _FcitxInstance*);
302         /**
303          * close the input window
304          */
305         void (*CloseInputWindow)(void *arg);
306         /**
307          * show the input window
308          */
309         void (*ShowInputWindow)(void *arg);
310         /**
311          * move the input window
312          */
313         void (*MoveInputWindow)(void *arg);
314         /**
315          * action on update status
316          */
317         void (*UpdateStatus)(void *arg, FcitxUIStatus*);
318         /**
319          * action on register status
320          */
321         void (*RegisterStatus)(void *arg, FcitxUIStatus*);
322         /**
323          * action on register menu
324          */
325         void (*RegisterMenu)(void *arg, FcitxUIMenu*);
326         /**
327          * action on focus
328          */
329         void (*OnInputFocus)(void *arg);
330         /**
331          * action on unfocus
332          */
333         void (*OnInputUnFocus)(void *arg);
334         /**
335          * action on trigger on
336          */
337         void (*OnTriggerOn)(void *arg);
338         /**
339          * action on trigger off
340          */
341         void (*OnTriggerOff)(void *arg);
342         /**
343          * display a message is ui support it
344          */
345         void (*DisplayMessage)(void *arg, char *title, char **msg, int length);
346         /**
347          * get the main window size if ui support it
348          */
349         void (*MainWindowSizeHint)(void *arg, int* x, int* y, int* w, int* h);
350         /**
351          * reload config
352          */
353         void (*ReloadConfig)(void*);
354         /**
355          * suspend to switch from/to fallback
356          */
357         void (*Suspend)(void*);
358         /**
359          * resume from suspend
360          */
361         void (*Resume)(void*);
362 
363         void (*Destroy)(void*); /**< destroy user interface addon */
364         void (*RegisterComplexStatus)(void*, FcitxUIComplexStatus*); /**< register complex status */
365         void (*UpdateComplexStatus)(void *arg, FcitxUIComplexStatus*); /**< register complext status */
366         void (*UnRegisterMenu)(void *arg, FcitxUIMenu*);
367     } FcitxUI;
368 
369     /**
370      * load user interface module
371      *
372      * @param instance fcitx instance
373      * @return void
374      **/
375     void FcitxUILoad(struct _FcitxInstance* instance);
376 
377     /**
378      * init messages
379      *
380      * @return FcitxMessages*
381      **/
382     FcitxMessages* FcitxMessagesNew();
383 
384     /**
385      * add a message string at last
386      *
387      * @param message message
388      * @param type message type
389      * @param fmt  printf fmt
390      * @param  ...
391      * @return void
392      **/
393     void FcitxMessagesAddMessageAtLast(FcitxMessages* message, FcitxMessageType type, const char *fmt, ...);
394 
395     /**
396      * add a message string at last, cat strings version
397      *
398      * @param message message
399      * @param type message type
400      * @return void
401      **/
402     void FcitxMessagesAddMessageVStringAtLast(FcitxMessages *message,
403                                                   FcitxMessageType type,
404                                                   size_t n, const char **strs);
405 #define FcitxMessagesAddMessageStringsAtLast(message, type, strs...) do { \
406         const char *__msg_str_lst[] = {strs};                           \
407         size_t __msg_str_count = sizeof(__msg_str_lst) / sizeof(char*); \
408         FcitxMessagesAddMessageVStringAtLast(message, type,         \
409                                                  __msg_str_count,       \
410                                                  __msg_str_lst);        \
411     } while (0)
412 
413     /**
414      * set a message string at position
415      *
416      * @param message message
417      * @param position position
418      * @param type message type
419      * @param fmt printf fmt
420      * @param  ...
421      * @return void
422      **/
423     void FcitxMessagesSetMessage(FcitxMessages* message, int position, int type, const char* fmt, ...);
424     /**
425      * set only message string
426      *
427      * @param message message
428      * @param position position
429      * @param fmt printf format
430      * @param  ...
431      * @return void
432      **/
433     void FcitxMessagesSetMessageText(FcitxMessages* message, int position, const char* fmt, ...);
434 
435     /**
436      * set only message string, it doesn't insert string into position,
437      * it concat all the string in strs, then replace the string at
438      * position
439      *
440      * @param message message
441      * @param position position
442      * @param n strs length
443      * @param strs string array
444      * @return void
445      *
446      * @since 4.2.7
447      **/
448     void FcitxMessagesSetMessageTextVString(FcitxMessages *message,
449                                             int position, size_t n,
450                                             const char **strs);
451 #define FcitxMessagesSetMessageTextStrings(message, position, strs...) do { \
452         const char *__msg_str_lst[] = {strs};                           \
453         size_t __msg_str_count = sizeof(__msg_str_lst) / sizeof(char*); \
454         FcitxMessagesSetMessageTextVString(message, position,       \
455                                                __msg_str_count,         \
456                                                __msg_str_lst);          \
457     } while (0)
458 
459     /**
460      * concat a string to message string at position
461      *
462      * @param message message
463      * @param position position
464      * @param text string
465      * @return void
466      **/
467     void FcitxMessagesMessageConcat(FcitxMessages* message, int position, const char* text);
468     /**
469      * concat a string to message string at last
470      *
471      * @param message message
472      * @param text string
473      * @return void
474      **/
475     void FcitxMessagesMessageConcatLast(FcitxMessages* message, const char* text);
476     /**
477      * set message string vprintf version
478      *
479      * @param message message
480      * @param position position
481      * @param type message type
482      * @param fmt printf format
483      * @param ap arguments
484      * @return void
485      **/
486     void FcitxMessagesSetMessageV(FcitxMessages* message, int position, int type, const char* fmt, va_list ap);
487     /**
488      * set message string cat strings version
489      *
490      * @param message message
491      * @param position position
492      * @param type message type
493      * @param n number of strings
494      * @param strs list of strings
495      * @return void
496      **/
497     void FcitxMessagesSetMessageStringsReal(FcitxMessages *message,
498                                             int position, int type,
499                                             size_t n, const char **strs);
500 #define FcitxMessagesSetMessageStrings(message, position, type, strs...) do { \
501         const char *__msg_str_lst[] = {strs};                           \
502         size_t __msg_str_count = sizeof(__msg_str_lst) / sizeof(char*); \
503         FcitxMessagesSetMessageStringsReal(message, position, type,     \
504                                            __msg_str_count, __msg_str_lst); \
505     } while (0)
506 
507     /**
508      * set message count
509      *
510      * @param m message
511      * @param s count
512      * @return void
513      **/
514     void FcitxMessagesSetMessageCount(FcitxMessages* m, int s);
515     /**
516      * get message count
517      *
518      * @param m message
519      * @return int
520      **/
521     int FcitxMessagesGetMessageCount(FcitxMessages* m);
522     /**
523      * get message string at index
524      *
525      * @param m message
526      * @param index index
527      * @return char*
528      **/
529     char* FcitxMessagesGetMessageString(FcitxMessages* m, int index);
530     /**
531      * get message type at index, will filter non regular type
532      *
533      * @param m message
534      * @param index index
535      * @return FcitxMessageType
536      **/
537     FcitxMessageType FcitxMessagesGetMessageType(FcitxMessages* m, int index);
538 
539     /**
540      * get message type at index, will not filter non regular type
541      *
542      * @param m message
543      * @param index index
544      * @return FcitxMessageType
545      *
546      * @see FcitxMessagesGetMessageType
547      * @since 4.2.1
548      **/
549     FcitxMessageType FcitxMessagesGetClientMessageType(FcitxMessages* m, int index);
550     /**
551      * check whether message is changed
552      *
553      * @param m message
554      * @return boolean
555      **/
556     boolean FcitxMessagesIsMessageChanged(FcitxMessages* m);
557     /**
558      * set message is changed or not
559      *
560      * @param m message
561      * @param changed changed or not
562      * @return void
563      **/
564     void FcitxMessagesSetMessageChanged(FcitxMessages* m, boolean changed);
565     /**
566      * add a new menu shell
567      *
568      * @param menu menu
569      * @param string menu text
570      * @param type menu type
571      * @param subMenu submenu pointer
572      * @return void
573      **/
574     void FcitxMenuAddMenuItem(FcitxUIMenu* menu, const char* string, FcitxMenuItemType type, FcitxUIMenu* subMenu);
575     /**
576      * add a new menu shell
577      *
578      * @param menu menu
579      * @param string menu text
580      * @param type menu type
581      * @param subMenu submenu pointer
582      * @return void
583      **/
584     void FcitxMenuAddMenuItemWithData(FcitxUIMenu* menu, const char* string, FcitxMenuItemType type, FcitxUIMenu* subMenu, void* arg);
585 
586     /**
587      * clear all menu shell
588      *
589      * @param menu menu
590      * @return void
591      **/
592     void FcitxMenuClear(FcitxUIMenu* menu);
593 
594     /**
595      * move input to cursor position
596      *
597      * @param instance fcitx instance
598      * @return void
599      **/
600     void FcitxUIMoveInputWindow(struct _FcitxInstance* instance);
601 
602     /**
603      * close input window
604      *
605      * @param instance fcitx instance
606      * @return void
607      **/
608     void FcitxUICloseInputWindow(struct _FcitxInstance* instance);
609     /**
610      * refresh a status info, since it changed outside the toggle function
611      *
612      * @param instance fcitx instance
613      * @param name status name
614      * @return void
615      **/
616     void FcitxUIRefreshStatus(struct _FcitxInstance* instance, const char* name);
617     /**
618      * toggle a user interface status
619      *
620      * @param instance fcitx instance
621      * @param name status name
622      * @return void
623      **/
624     void FcitxUIUpdateStatus(struct _FcitxInstance* instance, const char* name);
625     /**
626      * register a new ui status
627      *
628      * @param instance fcitx instance
629      * @param arg private data, pass to callback
630      * @param name name
631      * @param shortDesc short description
632      * @param longDesc long description
633      * @param toggleStatus callback for toggle status
634      * @param getStatus get current status
635      * @return void
636      **/
637     void FcitxUIRegisterStatus(struct _FcitxInstance* instance,
638                                void* arg,
639                                const char* name,
640                                const char* shortDesc,
641                                const char* longDesc,
642                                void (*toggleStatus)(void *arg),
643                                boolean(*getStatus)(void *arg));
644     /**
645      * register a new ui status
646      *
647      * @param instance fcitx instance
648      * @param arg private data, pass to callback
649      * @param name name
650      * @param shortDesc short description
651      * @param longDesc long description
652      * @param toggleStatus callback for toggle status
653      * @param getIconName get current icon name
654      * @return void
655      **/
656     void FcitxUIRegisterComplexStatus(struct _FcitxInstance* instance,
657                                       void* arg,
658                                       const char* name,
659                                       const char* shortDesc,
660                                       const char* longDesc,
661                                       void (*toggleStatus)(void *arg),
662                                       const char*(*getIconName)(void *arg));
663     /**
664      * register a new menu
665      *
666      * @param instance fcitx instance
667      * @param menu menu
668      * @return void
669      **/
670     void FcitxUIRegisterMenu(struct _FcitxInstance* instance, FcitxUIMenu* menu);
671 
672     void FcitxUIUnRegisterMenu(struct _FcitxInstance* instance, FcitxUIMenu* menu);
673 
674     /**
675      * process focus in event
676      *
677      * @param instance fcitx instance
678      * @return void
679      **/
680     void FcitxUIOnInputFocus(struct _FcitxInstance* instance);
681 
682     /**
683      * process focus out event
684      *
685      * @param instance fcitx instance
686      * @return void
687      **/
688     void FcitxUIOnInputUnFocus(struct _FcitxInstance* instance);
689 
690     /**
691      * process trigger on event
692      *
693      * @param instance fcitx instance
694      * @return void
695      **/
696     void FcitxUIOnTriggerOn(struct _FcitxInstance* instance);
697 
698     /**
699      * process trigger off event
700      *
701      * @param instance fcitx instance
702      * @return void
703      **/
704     void FcitxUIOnTriggerOff(struct _FcitxInstance* instance);
705 
706     /**
707      * if user interface support, display a message window on the screen
708      *
709      * @param instance fcitx instance
710      * @param title window title
711      * @param msg message
712      * @param length length or message
713      * @return void
714      **/
715     void FcitxUIDisplayMessage(struct _FcitxInstance *instance, char *title, char **msg, int length);
716 
717     /**
718      * get status by status name
719      *
720      * @param instance fcitx instance
721      * @param name status name
722      * @return FcitxUIStatus*
723      **/
724     FcitxUIStatus *FcitxUIGetStatusByName(struct _FcitxInstance* instance, const char* name);
725 
726     /**
727      * get menu by status name
728      *
729      * @param instance fcitx instance
730      * @param name status name
731      * @return FcitxUIMenu*
732      *
733      * @since 4.2.1
734      **/
735     FcitxUIMenu* FcitxUIGetMenuByStatusName(struct _FcitxInstance* instance, const char* name);
736 
737     /**
738      * get status by status name
739      *
740      * @param instance fcitx instance
741      * @param name status name
742      * @return FcitxUIStatus*
743      **/
744     FcitxUIComplexStatus *FcitxUIGetComplexStatusByName(struct _FcitxInstance* instance, const char* name);
745 
746 
747     /**
748      * set visibility for a status icon
749      *
750      * @param instance fcitx instance
751      * @param name name
752      * @param visible visibility
753      * @return void
754      **/
755     void FcitxUISetStatusVisable(struct _FcitxInstance* instance, const char* name, boolean visible);
756 
757     /**
758      * @brief set string for a status icon
759      *
760      * @param instance fcitx instance
761      * @param name name
762      * @param shortDesc short description
763      * @param longDesc long description
764      * @return void
765      *
766      * @since 4.2.1
767      **/
768     void FcitxUISetStatusString(struct _FcitxInstance* instance, const char* name, const char* shortDesc, const char* longDesc);
769 
770     /**
771      * update menu shell of a menu
772      *
773      * @param menu menu
774      * @return void
775      **/
776     void FcitxMenuUpdate(FcitxUIMenu* menu);
777 
778     /**
779      * check point is in rectangle or not
780      *
781      * @param x0 point x
782      * @param y0 point y
783      * @param x1 rectangle x
784      * @param y1 rectangle y
785      * @param w rectangle width
786      * @param h rectangle height
787      * @return boolean
788      **/
789     boolean FcitxUIIsInBox(int x0, int y0, int x1, int y1, int w, int h);
790 
791     /**
792      * check user interface support main window or not
793      *
794      * @param instance fcitx instance
795      * @return boolean
796      **/
797     boolean FcitxUISupportMainWindow(struct _FcitxInstance* instance);
798 
799     /**
800      * get main window geometry property if there is a main window
801      *
802      * @param instance fcitx instance
803      * @param x x
804      * @param y y
805      * @param w w
806      * @param h h
807      * @return void
808      **/
809     void FcitxUIGetMainWindowSize(struct _FcitxInstance* instance, int* x, int* y, int* w, int* h);
810 
811     /**
812      * convert new messages to old up and down style messages, return the new cursos pos
813      *
814      * @param instance fcitx instance
815      * @param msgUp messages up
816      * @param msgDown messages up
817      * @return int
818      **/
819     int FcitxUINewMessageToOldStyleMessage(struct _FcitxInstance* instance, FcitxMessages* msgUp, FcitxMessages* msgDown);
820 
821     /**
822      * convert messages to pure c string
823      *
824      * @param messages messages
825      * @return char*
826      **/
827     char* FcitxUIMessagesToCString(FcitxMessages* messages);
828 
829     /**
830      * convert candidate words to a string which can direct displayed
831      *
832      * @param instance fcitx instance
833      * @return char*
834      **/
835 
836     char* FcitxUICandidateWordToCString(struct _FcitxInstance* instance);
837 
838 
839     /**
840      * @brief commit current preedit string if any
841      *
842      * @param instance fcitx instance
843      * @return void
844      **/
845     void FcitxUICommitPreedit(struct _FcitxInstance* instance);
846 
847     /**
848      * mark input window should update
849      *
850      * @param instance fcitx instance
851      * @return void
852      **/
853     void FcitxUIUpdateInputWindow(struct _FcitxInstance* instance);
854 
855 
856     /**
857      * User interface should switch to the fallback
858      *
859      * @param instance fcitx instance
860      * @return void
861      **/
862     void FcitxUISwitchToFallback(struct _FcitxInstance* instance);
863 
864     /**
865      * User interface should resume from the fallback
866      *
867      * @param instance fcitx instance
868      * @return void
869      **/
870     void FcitxUIResumeFromFallback(struct _FcitxInstance* instance);
871 
872     /**
873      * checkk a user interface is fallback or not
874      *
875      * @param instance fcitx instance
876      * @param addon addon
877      * @return boolean
878      **/
879     boolean FcitxUIIsFallback(struct _FcitxInstance* instance, struct _FcitxAddon* addon);
880 
881     /**
882      * initialize a menu pointer
883      *
884      * @param menu menu
885      * @return void
886      **/
887     void FcitxMenuInit(FcitxUIMenu* menu);
888 
889     void FcitxMenuFinalize(FcitxUIMenu* menu);
890 
891 #ifdef __cplusplus
892 }
893 #endif
894 
895 #endif
896 
897 /**
898  * @}
899  */
900 
901 // kate: indent-mode cstyle; space-indent on; indent-width 0;
902