1 /***************************************************************************
2  *   Copyright (C) 2002~2005 by Yuking                                     *
3  *   yuking_net@sohu.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  * @file   ime-internal.h
22  * @date   2008-1-16
23  *
24  *  Private Header for Input Method
25  *
26  */
27 
28 #ifndef _FCITX_IME_INTERNAL_H_
29 #define _FCITX_IME_INTERNAL_H_
30 
31 #include "fcitx-config/hotkey.h"
32 #include "ime.h"
33 #include "frontend.h"
34 #include "fcitx-utils/utarray.h"
35 
36 struct _FcitxInputContext;
37 struct _FcitxInstance;
38 
39 typedef enum _KEY_RELEASED {
40     KR_OTHER = 0,
41     KR_SWITCH,
42     KR_2ND_SELECTKEY,
43     KR_3RD_SELECTKEY,
44     KR_SWITCH_IM,
45     KR_SWITCH_IM_REVERSE,
46     KR_TRIGGER,
47     KR_ACTIVATE,
48     KR_DEACTIVATE
49 } KEY_RELEASED;
50 
51 struct _FcitxInputState {
52     long unsigned int lastKeyPressedTime;
53     boolean bIsDoInputOnly;
54     KEY_RELEASED keyReleased;
55     int iCodeInputCount;
56     char strCodeInput[MAX_USER_INPUT * UTF8_MAX_LENGTH + 1];
57     char strStringGet[MAX_USER_INPUT * UTF8_MAX_LENGTH + 1];
58     char strLastCommit[MAX_USER_INPUT * UTF8_MAX_LENGTH + 1];
59     boolean bIsInRemind;
60 
61     time_t dummy;
62     int iCursorPos;
63     int iClientCursorPos;
64     boolean bShowCursor;
65     int dummy2;
66     int lastIsSingleHZ;
67     boolean bLastIsNumber;
68     boolean dummy3;
69 
70     /* the ui message part, if there is something in it, then it will be shown */
71     struct _FcitxCandidateWordList* candList;
72     FcitxMessages* msgPreedit;
73     FcitxMessages* msgAuxUp;
74     FcitxMessages* msgAuxDown;
75     FcitxMessages* msgClientPreedit;
76 
77     uint32_t keycode;
78     uint32_t keysym;
79     uint32_t keystate;
80 
81     int padding[60];
82 };
83 
84 struct _FcitxIMEntry {
85     FcitxGenericConfig config;
86     char* uniqueName;
87     char* name;
88     char* iconName;
89     int priority;
90     char* langCode;
91     char* parent;
92 };
93 
94 typedef struct _FcitxIMEntry FcitxIMEntry;
95 
96 void FcitxInstanceInitIM(struct _FcitxInstance* instance);
97 
98 void FcitxInstanceInitBuiltInHotkey(struct _FcitxInstance* instance);
99 
100 void FcitxInstanceDoPhraseTips(struct _FcitxInstance* instance);
101 
102 boolean FcitxInstanceLoadAllIM(struct _FcitxInstance* instance);
103 
104 void FcitxInstanceInitIMMenu(struct _FcitxInstance* instance);
105 
106 void FcitxInstanceShowInputSpeed(struct _FcitxInstance* instance, boolean force);
107 
108 INPUT_RETURN_VALUE ImProcessEnter(void *arg);
109 
110 INPUT_RETURN_VALUE ImProcessEscape(void *arg);
111 
112 INPUT_RETURN_VALUE ImProcessRemind(void *arg);
113 
114 INPUT_RETURN_VALUE ImProcessReload(void *arg);
115 
116 INPUT_RETURN_VALUE ImProcessSaveAll(void *arg);
117 
118 INPUT_RETURN_VALUE ImSwitchEmbeddedPreedit(void *arg);
119 
120 boolean IMIsInIMNameList(UT_array* imList, FcitxIM* ime);
121 
122 void FcitxInstanceLoadIM(struct _FcitxInstance* instance, FcitxAddon* addon);
123 
124 void FcitxInstanceSwitchIMInternal(struct _FcitxInstance* instance, int index, boolean skipZero, boolean updateGlobal, boolean userSwitchIM);
125 
126 FcitxConfigFileDesc* GetIMConfigDesc();
127 
128 int IMPriorityCmp(const void *a, const void *b);
129 
130 boolean FcitxInstanceUpdateCurrentIM(struct _FcitxInstance* instance, boolean force, boolean userSwitchIM);
131 
132 void HideInputSpeed(void* arg);
133 
134 boolean FcitxInstanceCheckICFromSameApplication (struct  _FcitxInstance* instance, FcitxInputContext* rec, FcitxInputContext* ic);
135 
136 void FcitxInstanceReloadAddon(struct _FcitxInstance* instance);
137 
138 #endif
139 
140 // kate: indent-mode cstyle; space-indent on; indent-width 0;
141