|
0 |
diff --git a/unix/fcitx/eim.cc b/unix/fcitx/eim.cc
|
|
1 |
new file mode 100644
|
|
2 |
index 0000000..99cab07
|
|
3 |
--- /dev/null
|
|
4 |
+++ b/unix/fcitx/eim.cc
|
|
5 |
@@ -0,0 +1,138 @@
|
|
6 |
+/***************************************************************************
|
|
7 |
+ * Copyright (C) 2012~2012 by CSSlayer *
|
|
8 |
+ * *
|
|
9 |
+ * This program is free software; you can redistribute it and/or modify *
|
|
10 |
+ * it under the terms of the GNU General Public License as published by *
|
|
11 |
+ * the Free Software Foundation; either version 2 of the License, or *
|
|
12 |
+ * (at your option) any later version. *
|
|
13 |
+ * *
|
|
14 |
+ * This program is distributed in the hope that it will be useful, *
|
|
15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
17 |
+ * GNU General Public License for more details. *
|
|
18 |
+ * *
|
|
19 |
+ * You should have received a copy of the GNU General Public License *
|
|
20 |
+ * along with this program; if not, write to the *
|
|
21 |
+ * Free Software Foundation, Inc., *
|
|
22 |
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
23 |
+ ***************************************************************************/
|
|
24 |
+
|
|
25 |
+#include <fcitx/instance.h>
|
|
26 |
+#include <fcitx/ime.h>
|
|
27 |
+#include <fcitx/hook.h>
|
|
28 |
+#include <fcitx-config/xdg.h>
|
|
29 |
+#include "fcitx_mozc.h"
|
|
30 |
+#include "mozc_connection.h"
|
|
31 |
+#include "mozc_response_parser.h"
|
|
32 |
+
|
|
33 |
+typedef struct _FcitxMozcState {
|
|
34 |
+ mozc::fcitx::FcitxMozc* mozc;
|
|
35 |
+} FcitxMozcState;
|
|
36 |
+
|
|
37 |
+
|
|
38 |
+static void* FcitxMozcCreate(FcitxInstance* instance);
|
|
39 |
+static void FcitxMozcDestroy(void *arg);
|
|
40 |
+static boolean FcitxMozcInit(void *arg); /**< FcitxMozcInit */
|
|
41 |
+static void FcitxMozcResetIM(void *arg); /**< FcitxMozcResetIM */
|
|
42 |
+static void FcitxMozcReset(void *arg); /**< FcitxMozcResetIM */
|
|
43 |
+static INPUT_RETURN_VALUE FcitxMozcDoInput(void *arg, FcitxKeySym, unsigned int); /**< FcitxMozcDoInput */
|
|
44 |
+static void FcitxMozcSave(void *arg); /**< FcitxMozcSave */
|
|
45 |
+static void FcitxMozcReloadConfig(void *arg); /**< FcitxMozcReloadConfig */
|
|
46 |
+
|
|
47 |
+extern "C" {
|
|
48 |
+
|
|
49 |
+FCITX_EXPORT_API
|
|
50 |
+FcitxIMClass ime = {
|
|
51 |
+ FcitxMozcCreate,
|
|
52 |
+ FcitxMozcDestroy
|
|
53 |
+};
|
|
54 |
+FCITX_EXPORT_API
|
|
55 |
+int ABI_VERSION = FCITX_ABI_VERSION;
|
|
56 |
+
|
|
57 |
+}
|
|
58 |
+
|
|
59 |
+static void* FcitxMozcCreate(FcitxInstance* instance)
|
|
60 |
+{
|
|
61 |
+ FcitxMozcState* mozcState = (FcitxMozcState*) fcitx_utils_malloc0(sizeof(FcitxMozcState));
|
|
62 |
+ bindtextdomain("fcitx-keyboard", LOCALEDIR);
|
|
63 |
+
|
|
64 |
+ mozcState->mozc = new mozc::fcitx::FcitxMozc(
|
|
65 |
+ instance,
|
|
66 |
+ mozc::fcitx::MozcConnection::CreateMozcConnection(),
|
|
67 |
+ new mozc::fcitx::MozcResponseParser
|
|
68 |
+ );
|
|
69 |
+
|
|
70 |
+ mozcState->mozc->SetCompositionMode(mozc::commands::HIRAGANA);
|
|
71 |
+
|
|
72 |
+ FcitxIMEventHook hk;
|
|
73 |
+ hk.arg = mozcState;
|
|
74 |
+ hk.func = FcitxMozcReset;
|
|
75 |
+
|
|
76 |
+ FcitxInstanceRegisterResetInputHook(instance, hk);
|
|
77 |
+
|
|
78 |
+ FcitxInstanceRegisterIM(instance,
|
|
79 |
+ mozcState,
|
|
80 |
+ "mozc",
|
|
81 |
+ "Mozc",
|
|
82 |
+ mozcState->mozc->GetIconFile("mozc.png").c_str(),
|
|
83 |
+ FcitxMozcInit,
|
|
84 |
+ FcitxMozcResetIM,
|
|
85 |
+ FcitxMozcDoInput,
|
|
86 |
+ NULL,
|
|
87 |
+ NULL,
|
|
88 |
+ FcitxMozcSave,
|
|
89 |
+ FcitxMozcReloadConfig,
|
|
90 |
+ NULL,
|
|
91 |
+ 5,
|
|
92 |
+ "ja"
|
|
93 |
+ );
|
|
94 |
+
|
|
95 |
+ return mozcState;
|
|
96 |
+}
|
|
97 |
+
|
|
98 |
+static void FcitxMozcDestroy(void *arg)
|
|
99 |
+{
|
|
100 |
+ FcitxMozcState* mozcState = (FcitxMozcState*) arg;
|
|
101 |
+ delete mozcState->mozc;
|
|
102 |
+ free(mozcState);
|
|
103 |
+}
|
|
104 |
+
|
|
105 |
+INPUT_RETURN_VALUE FcitxMozcDoInput(void* arg, FcitxKeySym sym, unsigned int state)
|
|
106 |
+{
|
|
107 |
+ FcitxMozcState* mozcState = (FcitxMozcState*) arg;
|
|
108 |
+ bool result = mozcState->mozc->process_key_event(sym, state);
|
|
109 |
+ if (!result)
|
|
110 |
+ return IRV_TO_PROCESS;
|
|
111 |
+ else
|
|
112 |
+ return IRV_DISPLAY_CANDWORDS;
|
|
113 |
+}
|
|
114 |
+
|
|
115 |
+boolean FcitxMozcInit(void* arg)
|
|
116 |
+{
|
|
117 |
+ FcitxMozcState* mozcState = (FcitxMozcState*) arg;
|
|
118 |
+ mozcState->mozc->init();
|
|
119 |
+ return true;
|
|
120 |
+}
|
|
121 |
+
|
|
122 |
+void FcitxMozcReloadConfig(void* arg)
|
|
123 |
+{
|
|
124 |
+
|
|
125 |
+}
|
|
126 |
+
|
|
127 |
+void FcitxMozcSave(void* arg)
|
|
128 |
+{
|
|
129 |
+ FCITX_UNUSED(arg);
|
|
130 |
+}
|
|
131 |
+
|
|
132 |
+void FcitxMozcResetIM(void* arg)
|
|
133 |
+{
|
|
134 |
+ FcitxMozcState* mozcState = (FcitxMozcState*) arg;
|
|
135 |
+ mozcState->mozc->resetim();
|
|
136 |
+}
|
|
137 |
+
|
|
138 |
+void FcitxMozcReset(void* arg)
|
|
139 |
+{
|
|
140 |
+ FcitxMozcState* mozcState = (FcitxMozcState*) arg;
|
|
141 |
+ mozcState->mozc->reset();
|
|
142 |
+
|
|
143 |
+}
|
|
144 |
diff --git a/unix/fcitx/fcitx-mozc.conf b/unix/fcitx/fcitx-mozc.conf
|
|
145 |
new file mode 100644
|
|
146 |
index 0000000..bcce806
|
|
147 |
--- /dev/null
|
|
148 |
+++ b/unix/fcitx/fcitx-mozc.conf
|
|
149 |
@@ -0,0 +1,10 @@
|
|
150 |
+[Addon]
|
|
151 |
+Name=fcitx-mozc
|
|
152 |
+GeneralName=Mozc
|
|
153 |
+Comment=Mozc support for Fcitx
|
|
154 |
+Category=InputMethod
|
|
155 |
+Enabled=True
|
|
156 |
+Library=fcitx-mozc.so
|
|
157 |
+Type=SharedLibrary
|
|
158 |
+SubConfig=
|
|
159 |
+IMRegisterMethod=ConfigFile
|
|
160 |
diff --git a/unix/fcitx/fcitx-mozc.desc b/unix/fcitx/fcitx-mozc.desc
|
|
161 |
new file mode 100644
|
|
162 |
index 0000000..c30420c
|
|
163 |
--- /dev/null
|
|
164 |
+++ b/unix/fcitx/fcitx-mozc.desc
|
|
165 |
@@ -0,0 +1,6 @@
|
|
166 |
+[Mozc/KeyboardLayout]
|
|
167 |
+Type=Enum
|
|
168 |
+Enum0=Japanese
|
|
169 |
+Enum1=America
|
|
170 |
+DefaultValue=Japanese
|
|
171 |
+Description=Keyboard layout while using Mozc
|
|
172 |
\ No newline at end of file
|
|
173 |
diff --git a/unix/fcitx/fcitx.gyp b/unix/fcitx/fcitx.gyp
|
|
174 |
new file mode 100644
|
|
175 |
index 0000000..4cf7f86
|
|
176 |
--- /dev/null
|
|
177 |
+++ b/unix/fcitx/fcitx.gyp
|
|
178 |
@@ -0,0 +1,107 @@
|
|
179 |
+#
|
|
180 |
+# Copyright (c) 2010-2012 fcitx Project http://code.google.com/p/fcitx/
|
|
181 |
+#
|
|
182 |
+# All rights reserved.
|
|
183 |
+#
|
|
184 |
+# Redistribution and use in source and binary forms, with or without
|
|
185 |
+# modification, are permitted provided that the following conditions
|
|
186 |
+# are met:
|
|
187 |
+# 1. Redistributions of source code must retain the above copyright
|
|
188 |
+# notice, this list of conditions and the following disclaimer.
|
|
189 |
+# 2. Redistributions in binary form must reproduce the above copyright
|
|
190 |
+# notice, this list of conditions and the following disclaimer in the
|
|
191 |
+# documentation and/or other materials provided with the distribution.
|
|
192 |
+# 3. Neither the name of authors nor the names of its contributors
|
|
193 |
+# may be used to endorse or promote products derived from this software
|
|
194 |
+# without specific prior written permission.
|
|
195 |
+#
|
|
196 |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
|
197 |
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
198 |
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
199 |
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
|
|
200 |
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
201 |
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
202 |
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
203 |
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
204 |
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
205 |
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
206 |
+# SUCH DAMAGE.
|
|
207 |
+#
|
|
208 |
+
|
|
209 |
+{
|
|
210 |
+ 'variables': {
|
|
211 |
+ 'relative_dir': 'unix/fcitx',
|
|
212 |
+ 'gen_out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(relative_dir)',
|
|
213 |
+ 'pkg_config_libs': [
|
|
214 |
+ 'fcitx',
|
|
215 |
+ 'fcitx-config',
|
|
216 |
+ 'fcitx-utils',
|
|
217 |
+ ],
|
|
218 |
+ 'fcitx_dep_include_dirs': [
|
|
219 |
+ ],
|
|
220 |
+ 'fcitx_dependencies': [
|
|
221 |
+ '../../base/base.gyp:base',
|
|
222 |
+ '../../client/client.gyp:client',
|
|
223 |
+ '../../ipc/ipc.gyp:ipc',
|
|
224 |
+ '../../session/session_base.gyp:ime_switch_util',
|
|
225 |
+ '../../session/session_base.gyp:session_protocol',
|
|
226 |
+ ],
|
|
227 |
+ 'fcitx_defines': [
|
|
228 |
+ 'LOCALEDIR="<!@(fcitx4-config --prefix)/share/locale/"',
|
|
229 |
+ ]
|
|
230 |
+ },
|
|
231 |
+ 'targets': [
|
|
232 |
+ {
|
|
233 |
+ 'target_name': 'gen_fcitx_mozc_i18n',
|
|
234 |
+ 'type': 'none',
|
|
235 |
+ 'actions': [
|
|
236 |
+ {
|
|
237 |
+ 'action_name': 'gen_fcitx_mozc_i18n',
|
|
238 |
+ 'inputs': [
|
|
239 |
+ './gen_fcitx_mozc_i18n.sh'
|
|
240 |
+ ],
|
|
241 |
+ 'outputs': [
|
|
242 |
+ '<(gen_out_dir)/po/zh_CN.mo',
|
|
243 |
+ '<(gen_out_dir)/po/zh_TW.mo',
|
|
244 |
+ '<(gen_out_dir)/po/ja.mo',
|
|
245 |
+ ],
|
|
246 |
+ 'action': [
|
|
247 |
+ 'sh',
|
|
248 |
+ './gen_fcitx_mozc_i18n.sh',
|
|
249 |
+ '<(gen_out_dir)/po',
|
|
250 |
+ ],
|
|
251 |
+ }],
|
|
252 |
+ },
|
|
253 |
+ {
|
|
254 |
+ 'target_name': 'fcitx-mozc',
|
|
255 |
+ 'product_prefix': '',
|
|
256 |
+ 'type': 'loadable_module',
|
|
257 |
+ 'sources': [
|
|
258 |
+ 'fcitx_mozc.cc',
|
|
259 |
+ 'fcitx_key_translator.cc',
|
|
260 |
+ 'mozc_connection.cc',
|
|
261 |
+ 'mozc_response_parser.cc',
|
|
262 |
+ 'eim.cc',
|
|
263 |
+ ],
|
|
264 |
+ 'dependencies': [
|
|
265 |
+ '<@(fcitx_dependencies)',
|
|
266 |
+ 'gen_fcitx_mozc_i18n',
|
|
267 |
+ ],
|
|
268 |
+ 'cflags': [
|
|
269 |
+ '<!@(pkg-config --cflags <@(pkg_config_libs))',
|
|
270 |
+ ],
|
|
271 |
+ 'include_dirs': [
|
|
272 |
+ '<@(fcitx_dep_include_dirs)',
|
|
273 |
+ ],
|
|
274 |
+ 'libraries': [
|
|
275 |
+ '<!@(pkg-config --libs-only-l <@(pkg_config_libs))',
|
|
276 |
+ ],
|
|
277 |
+ 'ldflags': [
|
|
278 |
+ '<!@(pkg-config --libs-only-L <@(pkg_config_libs))',
|
|
279 |
+ ],
|
|
280 |
+ 'defines': [
|
|
281 |
+ '<@(fcitx_defines)',
|
|
282 |
+ ],
|
|
283 |
+ },
|
|
284 |
+ ],
|
|
285 |
+}
|
|
286 |
diff --git a/unix/fcitx/fcitx_config.cc b/unix/fcitx/fcitx_config.cc
|
|
287 |
new file mode 100644
|
|
288 |
index 0000000..e69de29
|
|
289 |
diff --git a/unix/fcitx/fcitx_config.h b/unix/fcitx/fcitx_config.h
|
|
290 |
new file mode 100644
|
|
291 |
index 0000000..ddf9548
|
|
292 |
--- /dev/null
|
|
293 |
+++ b/unix/fcitx/fcitx_config.h
|
|
294 |
@@ -0,0 +1,28 @@
|
|
295 |
+/***************************************************************************
|
|
296 |
+ * Copyright (C) 2012~2012 by CSSlayer *
|
|
297 |
+ * *
|
|
298 |
+ * This program is free software; you can redistribute it and/or modify *
|
|
299 |
+ * it under the terms of the GNU General Public License as published by *
|
|
300 |
+ * the Free Software Foundation; either version 2 of the License, or *
|
|
301 |
+ * (at your option) any later version. *
|
|
302 |
+ * *
|
|
303 |
+ * This program is distributed in the hope that it will be useful, *
|
|
304 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
305 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
306 |
+ * GNU General Public License for more details. *
|
|
307 |
+ * *
|
|
308 |
+ * You should have received a copy of the GNU General Public License *
|
|
309 |
+ * along with this program; if not, write to the *
|
|
310 |
+ * Free Software Foundation, Inc., *
|
|
311 |
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
312 |
+ ***************************************************************************/
|
|
313 |
+
|
|
314 |
+#ifndef MOZC_UNIX_FCITX_FCITX_CONFIG_H_
|
|
315 |
+#define MOZC_UNIX_FCITX_FCITX_CONFIG_H_
|
|
316 |
+
|
|
317 |
+typedef enum _FcitxMozcLayout {
|
|
318 |
+ FcitxMozcLayout_Japanese,
|
|
319 |
+ FcitxMozcLayout_America,
|
|
320 |
+} FcitxMozcLayout;
|
|
321 |
+
|
|
322 |
+#endif
|
|
323 |
\ No newline at end of file
|
|
324 |
diff --git a/unix/fcitx/fcitx_key_translator.cc b/unix/fcitx/fcitx_key_translator.cc
|
|
325 |
new file mode 100644
|
|
326 |
index 0000000..aaece04
|
|
327 |
--- /dev/null
|
|
328 |
+++ b/unix/fcitx/fcitx_key_translator.cc
|
|
329 |
@@ -0,0 +1,581 @@
|
|
330 |
+/***************************************************************************
|
|
331 |
+ * Copyright (C) 2012~2012 by CSSlayer *
|
|
332 |
+ * *
|
|
333 |
+ * This program is free software; you can redistribute it and/or modify *
|
|
334 |
+ * it under the terms of the GNU General Public License as published by *
|
|
335 |
+ * the Free Software Foundation; either version 2 of the License, or *
|
|
336 |
+ * (at your option) any later version. *
|
|
337 |
+ * *
|
|
338 |
+ * This program is distributed in the hope that it will be useful, *
|
|
339 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
340 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
341 |
+ * GNU General Public License for more details. *
|
|
342 |
+ * *
|
|
343 |
+ * You should have received a copy of the GNU General Public License *
|
|
344 |
+ * along with this program; if not, write to the *
|
|
345 |
+ * Free Software Foundation, Inc., *
|
|
346 |
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
347 |
+ ***************************************************************************/
|
|
348 |
+
|
|
349 |
+#include "unix/fcitx/fcitx_key_translator.h"
|
|
350 |
+
|
|
351 |
+#include "base/logging.h"
|
|
352 |
+#include <fcitx/ime.h>
|
|
353 |
+
|
|
354 |
+namespace {
|
|
355 |
+
|
|
356 |
+const FcitxKeySym modifier_keys[] = {
|
|
357 |
+ FcitxKey_Alt_L,
|
|
358 |
+ FcitxKey_Alt_R,
|
|
359 |
+ FcitxKey_Caps_Lock,
|
|
360 |
+ FcitxKey_Control_L,
|
|
361 |
+ FcitxKey_Control_R,
|
|
362 |
+ FcitxKey_Hyper_L,
|
|
363 |
+ FcitxKey_Hyper_R,
|
|
364 |
+ FcitxKey_Meta_L,
|
|
365 |
+ FcitxKey_Meta_R,
|
|
366 |
+ FcitxKey_Shift_L,
|
|
367 |
+ FcitxKey_Shift_Lock,
|
|
368 |
+ FcitxKey_Shift_R,
|
|
369 |
+ FcitxKey_Super_L,
|
|
370 |
+ FcitxKey_Super_R,
|
|
371 |
+};
|
|
372 |
+
|
|
373 |
+const struct SpecialKeyMap {
|
|
374 |
+ FcitxKeySym from;
|
|
375 |
+ mozc::commands::KeyEvent::SpecialKey to;
|
|
376 |
+} sp_key_map[] = {
|
|
377 |
+ {FcitxKey_space, mozc::commands::KeyEvent::SPACE},
|
|
378 |
+ {FcitxKey_Return, mozc::commands::KeyEvent::ENTER},
|
|
379 |
+ {FcitxKey_Left, mozc::commands::KeyEvent::LEFT},
|
|
380 |
+ {FcitxKey_Right, mozc::commands::KeyEvent::RIGHT},
|
|
381 |
+ {FcitxKey_Up, mozc::commands::KeyEvent::UP},
|
|
382 |
+ {FcitxKey_Down, mozc::commands::KeyEvent::DOWN},
|
|
383 |
+ {FcitxKey_Escape, mozc::commands::KeyEvent::ESCAPE},
|
|
384 |
+ {FcitxKey_Delete, mozc::commands::KeyEvent::DEL},
|
|
385 |
+ {FcitxKey_BackSpace, mozc::commands::KeyEvent::BACKSPACE},
|
|
386 |
+ {FcitxKey_Insert, mozc::commands::KeyEvent::INSERT},
|
|
387 |
+ {FcitxKey_Henkan, mozc::commands::KeyEvent::HENKAN},
|
|
388 |
+ {FcitxKey_Muhenkan, mozc::commands::KeyEvent::MUHENKAN},
|
|
389 |
+ {FcitxKey_Hiragana, mozc::commands::KeyEvent::KANA},
|
|
390 |
+ // FcitxKey_Hiragana_Katakana requires special treatment.
|
|
391 |
+ // See FcitxKeyTranslator::NormalizeHiraganaKatakanaKeyWithShift.
|
|
392 |
+ {FcitxKey_Hiragana_Katakana, mozc::commands::KeyEvent::KANA},
|
|
393 |
+ {FcitxKey_Katakana, mozc::commands::KeyEvent::KATAKANA},
|
|
394 |
+ {FcitxKey_Eisu_toggle, mozc::commands::KeyEvent::EISU},
|
|
395 |
+ {FcitxKey_Home, mozc::commands::KeyEvent::HOME},
|
|
396 |
+ {FcitxKey_End, mozc::commands::KeyEvent::END},
|
|
397 |
+ {FcitxKey_Tab, mozc::commands::KeyEvent::TAB},
|
|
398 |
+ {FcitxKey_F1, mozc::commands::KeyEvent::F1},
|
|
399 |
+ {FcitxKey_F2, mozc::commands::KeyEvent::F2},
|
|
400 |
+ {FcitxKey_F3, mozc::commands::KeyEvent::F3},
|
|
401 |
+ {FcitxKey_F4, mozc::commands::KeyEvent::F4},
|
|
402 |
+ {FcitxKey_F5, mozc::commands::KeyEvent::F5},
|
|
403 |
+ {FcitxKey_F6, mozc::commands::KeyEvent::F6},
|
|
404 |
+ {FcitxKey_F7, mozc::commands::KeyEvent::F7},
|
|
405 |
+ {FcitxKey_F8, mozc::commands::KeyEvent::F8},
|
|
406 |
+ {FcitxKey_F9, mozc::commands::KeyEvent::F9},
|
|
407 |
+ {FcitxKey_F10, mozc::commands::KeyEvent::F10},
|
|
408 |
+ {FcitxKey_F11, mozc::commands::KeyEvent::F11},
|
|
409 |
+ {FcitxKey_F12, mozc::commands::KeyEvent::F12},
|
|
410 |
+ {FcitxKey_F13, mozc::commands::KeyEvent::F13},
|
|
411 |
+ {FcitxKey_F14, mozc::commands::KeyEvent::F14},
|
|
412 |
+ {FcitxKey_F15, mozc::commands::KeyEvent::F15},
|
|
413 |
+ {FcitxKey_F16, mozc::commands::KeyEvent::F16},
|
|
414 |
+ {FcitxKey_F17, mozc::commands::KeyEvent::F17},
|
|
415 |
+ {FcitxKey_F18, mozc::commands::KeyEvent::F18},
|
|
416 |
+ {FcitxKey_F19, mozc::commands::KeyEvent::F19},
|
|
417 |
+ {FcitxKey_F20, mozc::commands::KeyEvent::F20},
|
|
418 |
+ {FcitxKey_F21, mozc::commands::KeyEvent::F21},
|
|
419 |
+ {FcitxKey_F22, mozc::commands::KeyEvent::F22},
|
|
420 |
+ {FcitxKey_F23, mozc::commands::KeyEvent::F23},
|
|
421 |
+ {FcitxKey_F24, mozc::commands::KeyEvent::F24},
|
|
422 |
+ {FcitxKey_Page_Up, mozc::commands::KeyEvent::PAGE_UP},
|
|
423 |
+ {FcitxKey_Page_Down, mozc::commands::KeyEvent::PAGE_DOWN},
|
|
424 |
+
|
|
425 |
+ // Keypad (10-key).
|
|
426 |
+ {FcitxKey_KP_0, mozc::commands::KeyEvent::NUMPAD0},
|
|
427 |
+ {FcitxKey_KP_1, mozc::commands::KeyEvent::NUMPAD1},
|
|
428 |
+ {FcitxKey_KP_2, mozc::commands::KeyEvent::NUMPAD2},
|
|
429 |
+ {FcitxKey_KP_3, mozc::commands::KeyEvent::NUMPAD3},
|
|
430 |
+ {FcitxKey_KP_4, mozc::commands::KeyEvent::NUMPAD4},
|
|
431 |
+ {FcitxKey_KP_5, mozc::commands::KeyEvent::NUMPAD5},
|
|
432 |
+ {FcitxKey_KP_6, mozc::commands::KeyEvent::NUMPAD6},
|
|
433 |
+ {FcitxKey_KP_7, mozc::commands::KeyEvent::NUMPAD7},
|
|
434 |
+ {FcitxKey_KP_8, mozc::commands::KeyEvent::NUMPAD8},
|
|
435 |
+ {FcitxKey_KP_9, mozc::commands::KeyEvent::NUMPAD9},
|
|
436 |
+ {FcitxKey_KP_Equal, mozc::commands::KeyEvent::EQUALS}, // [=]
|
|
437 |
+ {FcitxKey_KP_Multiply, mozc::commands::KeyEvent::MULTIPLY}, // [*]
|
|
438 |
+ {FcitxKey_KP_Add, mozc::commands::KeyEvent::ADD}, // [+]
|
|
439 |
+ {FcitxKey_KP_Separator, mozc::commands::KeyEvent::SEPARATOR}, // enter
|
|
440 |
+ {FcitxKey_KP_Subtract, mozc::commands::KeyEvent::SUBTRACT}, // [-]
|
|
441 |
+ {FcitxKey_KP_Decimal, mozc::commands::KeyEvent::DECIMAL}, // [.]
|
|
442 |
+ {FcitxKey_KP_Divide, mozc::commands::KeyEvent::DIVIDE}, // [/]
|
|
443 |
+ {FcitxKey_KP_Space, mozc::commands::KeyEvent::SPACE},
|
|
444 |
+ {FcitxKey_KP_Tab, mozc::commands::KeyEvent::TAB},
|
|
445 |
+ {FcitxKey_KP_Enter, mozc::commands::KeyEvent::ENTER},
|
|
446 |
+ {FcitxKey_KP_Home, mozc::commands::KeyEvent::HOME},
|
|
447 |
+ {FcitxKey_KP_Left, mozc::commands::KeyEvent::LEFT},
|
|
448 |
+ {FcitxKey_KP_Up, mozc::commands::KeyEvent::UP},
|
|
449 |
+ {FcitxKey_KP_Right, mozc::commands::KeyEvent::RIGHT},
|
|
450 |
+ {FcitxKey_KP_Down, mozc::commands::KeyEvent::DOWN},
|
|
451 |
+ {FcitxKey_KP_Page_Up, mozc::commands::KeyEvent::PAGE_UP},
|
|
452 |
+ {FcitxKey_KP_Page_Down, mozc::commands::KeyEvent::PAGE_DOWN},
|
|
453 |
+ {FcitxKey_KP_End, mozc::commands::KeyEvent::END},
|
|
454 |
+ {FcitxKey_KP_Delete, mozc::commands::KeyEvent::DEL},
|
|
455 |
+ {FcitxKey_KP_Insert, mozc::commands::KeyEvent::INSERT},
|
|
456 |
+
|
|
457 |
+ // Shift+TAB.
|
|
458 |
+ {FcitxKey_ISO_Left_Tab, mozc::commands::KeyEvent::TAB},
|
|
459 |
+
|
|
460 |
+ // - FcitxKey_Kana_Lock? FcitxKey_Kana_Shift?
|
|
461 |
+};
|
|
462 |
+
|
|
463 |
+const struct SpecialAsciiMap {
|
|
464 |
+ uint32 from;
|
|
465 |
+ uint32 to;
|
|
466 |
+} sp_ascii_map[] = {
|
|
467 |
+ {FcitxKey_KP_Equal, '='},
|
|
468 |
+};
|
|
469 |
+
|
|
470 |
+const struct KanaMap {
|
|
471 |
+ uint32 keysym;
|
|
472 |
+ const char *kana;
|
|
473 |
+} kKanaMapJp[] = {
|
|
474 |
+ { '1' , "\xe3\x81\xac" }, // "ぬ"
|
|
475 |
+ { '!' , "\xe3\x81\xac" }, // "ぬ"
|
|
476 |
+ { '2' , "\xe3\x81\xb5" }, // "ふ"
|
|
477 |
+ { '\"', "\xe3\x81\xb5" }, // "ふ"
|
|
478 |
+ { '3' , "\xe3\x81\x82" }, // "あ"
|
|
479 |
+ { '#' , "\xe3\x81\x81" }, // "ぁ"
|
|
480 |
+ { '4' , "\xe3\x81\x86" }, // "う"
|
|
481 |
+ { '$' , "\xe3\x81\x85" }, // "ぅ"
|
|
482 |
+ { '5' , "\xe3\x81\x88" }, // "え"
|
|
483 |
+ { '%' , "\xe3\x81\x87" }, // "ぇ"
|
|
484 |
+ { '6' , "\xe3\x81\x8a" }, // "お"
|
|
485 |
+ { '&' , "\xe3\x81\x89" }, // "ぉ"
|
|
486 |
+ { '7' , "\xe3\x82\x84" }, // "や"
|
|
487 |
+ { '\'', "\xe3\x82\x83" }, // "ゃ"
|
|
488 |
+ { '8' , "\xe3\x82\x86" }, // "ゆ"
|
|
489 |
+ { '(' , "\xe3\x82\x85" }, // "ゅ"
|
|
490 |
+ { '9' , "\xe3\x82\x88" }, // "よ"
|
|
491 |
+ { ')' , "\xe3\x82\x87" }, // "ょ"
|
|
492 |
+ { '0' , "\xe3\x82\x8f" }, // "わ"
|
|
493 |
+ // Shift+0 is usually mapped to tilde by XKB.
|
|
494 |
+ { '-' , "\xe3\x81\xbb" }, // "ほ"
|
|
495 |
+ { '=' , "\xe3\x81\xbb" }, // "ほ"
|
|
496 |
+ { '^' , "\xe3\x81\xb8" }, // "へ"
|
|
497 |
+ { '~' , "\xe3\x82\x92" }, // "を"
|
|
498 |
+ { '|' , "\xe3\x83\xbc" }, // "ー"
|
|
499 |
+ { 'q' , "\xe3\x81\x9f" }, // "た"
|
|
500 |
+ { 'Q' , "\xe3\x81\x9f" }, // "た"
|
|
501 |
+ { 'w' , "\xe3\x81\xa6" }, // "て"
|
|
502 |
+ { 'W' , "\xe3\x81\xa6" }, // "て"
|
|
503 |
+ { 'e' , "\xe3\x81\x84" }, // "い"
|
|
504 |
+ { 'E' , "\xe3\x81\x83" }, // "ぃ"
|
|
505 |
+ { 'r' , "\xe3\x81\x99" }, // "す"
|
|
506 |
+ { 'R' , "\xe3\x81\x99" }, // "す"
|
|
507 |
+ { 't' , "\xe3\x81\x8b" }, // "か"
|
|
508 |
+ { 'T' , "\xe3\x81\x8b" }, // "か"
|
|
509 |
+ { 'y' , "\xe3\x82\x93" }, // "ん"
|
|
510 |
+ { 'Y' , "\xe3\x82\x93" }, // "ん"
|
|
511 |
+ { 'u' , "\xe3\x81\xaa" }, // "な"
|
|
512 |
+ { 'U' , "\xe3\x81\xaa" }, // "な"
|
|
513 |
+ { 'i' , "\xe3\x81\xab" }, // "に"
|
|
514 |
+ { 'I' , "\xe3\x81\xab" }, // "に"
|
|
515 |
+ { 'o' , "\xe3\x82\x89" }, // "ら"
|
|
516 |
+ { 'O' , "\xe3\x82\x89" }, // "ら"
|
|
517 |
+ { 'p' , "\xe3\x81\x9b" }, // "せ"
|
|
518 |
+ { 'P' , "\xe3\x81\x9b" }, // "せ"
|
|
519 |
+ { '@' , "\xe3\x82\x9b" }, // "゛"
|
|
520 |
+ { '`' , "\xe3\x82\x9b" }, // "゛"
|
|
521 |
+ { '[' , "\xe3\x82\x9c" }, // "゜"
|
|
522 |
+ { '{' , "\xe3\x80\x8c" }, // "「"
|
|
523 |
+ { 'a' , "\xe3\x81\xa1" }, // "ち"
|
|
524 |
+ { 'A' , "\xe3\x81\xa1" }, // "ち"
|
|
525 |
+ { 's' , "\xe3\x81\xa8" }, // "と"
|
|
526 |
+ { 'S' , "\xe3\x81\xa8" }, // "と"
|
|
527 |
+ { 'd' , "\xe3\x81\x97" }, // "し"
|
|
528 |
+ { 'D' , "\xe3\x81\x97" }, // "し"
|
|
529 |
+ { 'f' , "\xe3\x81\xaf" }, // "は"
|
|
530 |
+ { 'F' , "\xe3\x81\xaf" }, // "は"
|
|
531 |
+ { 'g' , "\xe3\x81\x8d" }, // "き"
|
|
532 |
+ { 'G' , "\xe3\x81\x8d" }, // "き"
|
|
533 |
+ { 'h' , "\xe3\x81\x8f" }, // "く"
|
|
534 |
+ { 'H' , "\xe3\x81\x8f" }, // "く"
|
|
535 |
+ { 'j' , "\xe3\x81\xbe" }, // "ま"
|
|
536 |
+ { 'J' , "\xe3\x81\xbe" }, // "ま"
|
|
537 |
+ { 'k' , "\xe3\x81\xae" }, // "の"
|
|
538 |
+ { 'K' , "\xe3\x81\xae" }, // "の"
|
|
539 |
+ { 'l' , "\xe3\x82\x8a" }, // "り"
|
|
540 |
+ { 'L' , "\xe3\x82\x8a" }, // "り"
|
|
541 |
+ { ';' , "\xe3\x82\x8c" }, // "れ"
|
|
542 |
+ { '+' , "\xe3\x82\x8c" }, // "れ"
|
|
543 |
+ { ':' , "\xe3\x81\x91" }, // "け"
|
|
544 |
+ { '*' , "\xe3\x81\x91" }, // "け"
|
|
545 |
+ { ']' , "\xe3\x82\x80" }, // "む"
|
|
546 |
+ { '}' , "\xe3\x80\x8d" }, // "」"
|
|
547 |
+ { 'z' , "\xe3\x81\xa4" }, // "つ"
|
|
548 |
+ { 'Z' , "\xe3\x81\xa3" }, // "っ"
|
|
549 |
+ { 'x' , "\xe3\x81\x95" }, // "さ"
|
|
550 |
+ { 'X' , "\xe3\x81\x95" }, // "さ"
|
|
551 |
+ { 'c' , "\xe3\x81\x9d" }, // "そ"
|
|
552 |
+ { 'C' , "\xe3\x81\x9d" }, // "そ"
|
|
553 |
+ { 'v' , "\xe3\x81\xb2" }, // "ひ"
|
|
554 |
+ { 'V' , "\xe3\x81\xb2" }, // "ひ"
|
|
555 |
+ { 'b' , "\xe3\x81\x93" }, // "こ"
|
|
556 |
+ { 'B' , "\xe3\x81\x93" }, // "こ"
|
|
557 |
+ { 'n' , "\xe3\x81\xbf" }, // "み"
|
|
558 |
+ { 'N' , "\xe3\x81\xbf" }, // "み"
|
|
559 |
+ { 'm' , "\xe3\x82\x82" }, // "も"
|
|
560 |
+ { 'M' , "\xe3\x82\x82" }, // "も"
|
|
561 |
+ { ',' , "\xe3\x81\xad" }, // "ね"
|
|
562 |
+ { '<' , "\xe3\x80\x81" }, // "、"
|
|
563 |
+ { '.' , "\xe3\x82\x8b" }, // "る"
|
|
564 |
+ { '>' , "\xe3\x80\x82" }, // "。"
|
|
565 |
+ { '/' , "\xe3\x82\x81" }, // "め"
|
|
566 |
+ { '?' , "\xe3\x83\xbb" }, // "・"
|
|
567 |
+ { '_' , "\xe3\x82\x8d" }, // "ろ"
|
|
568 |
+ // A backslash is handled in a special way because it is input by
|
|
569 |
+ // two different keys (the one next to Backslash and the one next
|
|
570 |
+ // to Right Shift).
|
|
571 |
+ { '\\', "" },
|
|
572 |
+}, kKanaMapUs[] = {
|
|
573 |
+ { '`' , "\xe3\x82\x8d" }, // "ろ" - Different from the Jp mapping.
|
|
574 |
+ { '~' , "\xe3\x82\x8d" }, // "ろ" - Different from the Jp mapping.
|
|
575 |
+ { '1' , "\xe3\x81\xac" }, // "ぬ"
|
|
576 |
+ { '!' , "\xe3\x81\xac" }, // "ぬ"
|
|
577 |
+ { '2' , "\xe3\x81\xb5" }, // "ふ"
|
|
578 |
+ { '@' , "\xe3\x81\xb5" }, // "ふ"
|
|
579 |
+ { '3' , "\xe3\x81\x82" }, // "あ"
|
|
580 |
+ { '#' , "\xe3\x81\x81" }, // "ぁ"
|
|
581 |
+ { '4' , "\xe3\x81\x86" }, // "う"
|
|
582 |
+ { '$' , "\xe3\x81\x85" }, // "ぅ"
|
|
583 |
+ { '5' , "\xe3\x81\x88" }, // "え"
|
|
584 |
+ { '%' , "\xe3\x81\x87" }, // "ぇ"
|
|
585 |
+ { '6' , "\xe3\x81\x8a" }, // "お"
|
|
586 |
+ { '^' , "\xe3\x81\x89" }, // "ぉ"
|
|
587 |
+ { '7' , "\xe3\x82\x84" }, // "や"
|
|
588 |
+ { '&' , "\xe3\x82\x83" }, // "ゃ"
|
|
589 |
+ { '8' , "\xe3\x82\x86" }, // "ゆ"
|
|
590 |
+ { '*' , "\xe3\x82\x85" }, // "ゅ"
|
|
591 |
+ { '9' , "\xe3\x82\x88" }, // "よ"
|
|
592 |
+ { '(' , "\xe3\x82\x87" }, // "ょ"
|
|
593 |
+ { '0' , "\xe3\x82\x8f" }, // "わ"
|
|
594 |
+ { ')' , "\xe3\x82\x92" }, // "を"
|
|
595 |
+ { '-' , "\xe3\x81\xbb" }, // "ほ"
|
|
596 |
+ { '_' , "\xe3\x83\xbc" }, // "ー" - Different from the Jp mapping.
|
|
597 |
+ { '=' , "\xe3\x81\xb8" }, // "へ"
|
|
598 |
+ { '+' , "\xe3\x81\xb8" }, // "へ"
|
|
599 |
+ { 'q' , "\xe3\x81\x9f" }, // "た"
|
|
600 |
+ { 'Q' , "\xe3\x81\x9f" }, // "た"
|
|
601 |
+ { 'w' , "\xe3\x81\xa6" }, // "て"
|
|
602 |
+ { 'W' , "\xe3\x81\xa6" }, // "て"
|
|
603 |
+ { 'e' , "\xe3\x81\x84" }, // "い"
|
|
604 |
+ { 'E' , "\xe3\x81\x83" }, // "ぃ"
|
|
605 |
+ { 'r' , "\xe3\x81\x99" }, // "す"
|
|
606 |
+ { 'R' , "\xe3\x81\x99" }, // "す"
|
|
607 |
+ { 't' , "\xe3\x81\x8b" }, // "か"
|
|
608 |
+ { 'T' , "\xe3\x81\x8b" }, // "か"
|
|
609 |
+ { 'y' , "\xe3\x82\x93" }, // "ん"
|
|
610 |
+ { 'Y' , "\xe3\x82\x93" }, // "ん"
|
|
611 |
+ { 'u' , "\xe3\x81\xaa" }, // "な"
|
|
612 |
+ { 'U' , "\xe3\x81\xaa" }, // "な"
|
|
613 |
+ { 'i' , "\xe3\x81\xab" }, // "に"
|
|
614 |
+ { 'I' , "\xe3\x81\xab" }, // "に"
|
|
615 |
+ { 'o' , "\xe3\x82\x89" }, // "ら"
|
|
616 |
+ { 'O' , "\xe3\x82\x89" }, // "ら"
|
|
617 |
+ { 'p' , "\xe3\x81\x9b" }, // "せ"
|
|
618 |
+ { 'P' , "\xe3\x81\x9b" }, // "せ"
|
|
619 |
+ { '[' , "\xe3\x82\x9b" }, // "゛"
|
|
620 |
+ { '{' , "\xe3\x82\x9b" }, // "゛"
|
|
621 |
+ { ']' , "\xe3\x82\x9c" }, // "゜"
|
|
622 |
+ { '}' , "\xe3\x80\x8c" }, // "「"
|
|
623 |
+ { '\\', "\xe3\x82\x80" }, // "む" - Different from the Jp mapping.
|
|
624 |
+ { '|' , "\xe3\x80\x8d" }, // "」" - Different from the Jp mapping.
|
|
625 |
+ { 'a' , "\xe3\x81\xa1" }, // "ち"
|
|
626 |
+ { 'A' , "\xe3\x81\xa1" }, // "ち"
|
|
627 |
+ { 's' , "\xe3\x81\xa8" }, // "と"
|
|
628 |
+ { 'S' , "\xe3\x81\xa8" }, // "と"
|
|
629 |
+ { 'd' , "\xe3\x81\x97" }, // "し"
|
|
630 |
+ { 'D' , "\xe3\x81\x97" }, // "し"
|
|
631 |
+ { 'f' , "\xe3\x81\xaf" }, // "は"
|
|
632 |
+ { 'F' , "\xe3\x81\xaf" }, // "は"
|
|
633 |
+ { 'g' , "\xe3\x81\x8d" }, // "き"
|
|
634 |
+ { 'G' , "\xe3\x81\x8d" }, // "き"
|
|
635 |
+ { 'h' , "\xe3\x81\x8f" }, // "く"
|
|
636 |
+ { 'H' , "\xe3\x81\x8f" }, // "く"
|
|
637 |
+ { 'j' , "\xe3\x81\xbe" }, // "ま"
|
|
638 |
+ { 'J' , "\xe3\x81\xbe" }, // "ま"
|
|
639 |
+ { 'k' , "\xe3\x81\xae" }, // "の"
|
|
640 |
+ { 'K' , "\xe3\x81\xae" }, // "の"
|
|
641 |
+ { 'l' , "\xe3\x82\x8a" }, // "り"
|
|
642 |
+ { 'L' , "\xe3\x82\x8a" }, // "り"
|
|
643 |
+ { ';' , "\xe3\x82\x8c" }, // "れ"
|
|
644 |
+ { ':' , "\xe3\x82\x8c" }, // "れ"
|
|
645 |
+ { '\'', "\xe3\x81\x91" }, // "け"
|
|
646 |
+ { '\"', "\xe3\x81\x91" }, // "け"
|
|
647 |
+ { 'z' , "\xe3\x81\xa4" }, // "つ"
|
|
648 |
+ { 'Z' , "\xe3\x81\xa3" }, // "っ"
|
|
649 |
+ { 'x' , "\xe3\x81\x95" }, // "さ"
|
|
650 |
+ { 'X' , "\xe3\x81\x95" }, // "さ"
|
|
651 |
+ { 'c' , "\xe3\x81\x9d" }, // "そ"
|
|
652 |
+ { 'C' , "\xe3\x81\x9d" }, // "そ"
|
|
653 |
+ { 'v' , "\xe3\x81\xb2" }, // "ひ"
|
|
654 |
+ { 'V' , "\xe3\x81\xb2" }, // "ひ"
|
|
655 |
+ { 'b' , "\xe3\x81\x93" }, // "こ"
|
|
656 |
+ { 'B' , "\xe3\x81\x93" }, // "こ"
|
|
657 |
+ { 'n' , "\xe3\x81\xbf" }, // "み"
|
|
658 |
+ { 'N' , "\xe3\x81\xbf" }, // "み"
|
|
659 |
+ { 'm' , "\xe3\x82\x82" }, // "も"
|
|
660 |
+ { 'M' , "\xe3\x82\x82" }, // "も"
|
|
661 |
+ { ',' , "\xe3\x81\xad" }, // "ね"
|
|
662 |
+ { '<' , "\xe3\x80\x81" }, // "、"
|
|
663 |
+ { '.' , "\xe3\x82\x8b" }, // "る"
|
|
664 |
+ { '>' , "\xe3\x80\x82" }, // "。"
|
|
665 |
+ { '/' , "\xe3\x82\x81" }, // "め"
|
|
666 |
+ { '?' , "\xe3\x83\xbb" }, // "・"
|
|
667 |
+};
|
|
668 |
+
|
|
669 |
+} // namespace
|
|
670 |
+
|
|
671 |
+static inline char get_ascii_code(FcitxKeySym sym)
|
|
672 |
+{
|
|
673 |
+ if (sym >= FcitxKey_space && sym <= FcitxKey_asciitilde)
|
|
674 |
+ return (char) (sym & 0xff);
|
|
675 |
+
|
|
676 |
+ if (sym >= FcitxKey_KP_0 && sym <= FcitxKey_KP_9)
|
|
677 |
+ return (char) ((sym - FcitxKey_KP_0 + FcitxKey_0) & 0xff);
|
|
678 |
+
|
|
679 |
+ if (sym == FcitxKey_Return)
|
|
680 |
+ return 0x0d;
|
|
681 |
+ if (sym == FcitxKey_Linefeed)
|
|
682 |
+ return 0x0a;
|
|
683 |
+ if (sym == FcitxKey_Tab)
|
|
684 |
+ return 0x09;
|
|
685 |
+ if (sym == FcitxKey_BackSpace)
|
|
686 |
+ return 0x08;
|
|
687 |
+ if (sym == FcitxKey_Escape)
|
|
688 |
+ return 0x1b;
|
|
689 |
+
|
|
690 |
+ return 0;
|
|
691 |
+}
|
|
692 |
+
|
|
693 |
+namespace mozc {
|
|
694 |
+
|
|
695 |
+namespace fcitx {
|
|
696 |
+
|
|
697 |
+KeyTranslator::KeyTranslator() {
|
|
698 |
+ InitializeKeyMaps();
|
|
699 |
+ input = 0;
|
|
700 |
+ layout = FcitxMozcLayout_Japanese;
|
|
701 |
+}
|
|
702 |
+
|
|
703 |
+KeyTranslator::~KeyTranslator() {
|
|
704 |
+}
|
|
705 |
+
|
|
706 |
+void KeyTranslator::Translate(
|
|
707 |
+ FcitxKeySym origsym, unsigned int origstate, mozc::config::Config::PreeditMethod method,
|
|
708 |
+ mozc::commands::KeyEvent *out_event) const {
|
|
709 |
+ FcitxKeySym sym;
|
|
710 |
+ unsigned int state;
|
|
711 |
+ NormalizeHiraganaKatakanaKeyWithShift(origsym, origstate, &sym, &state);
|
|
712 |
+ DCHECK(CanConvert(sym, state));
|
|
713 |
+ if (!CanConvert(sym, state)) {
|
|
714 |
+ LOG(ERROR) << "Can't handle the key: " << sym;
|
|
715 |
+ return;
|
|
716 |
+ }
|
|
717 |
+ DCHECK(out_event);
|
|
718 |
+ if (!out_event) {
|
|
719 |
+ return;
|
|
720 |
+ }
|
|
721 |
+ out_event->Clear();
|
|
722 |
+
|
|
723 |
+
|
|
724 |
+ if ((state & FcitxKeyState_Ctrl) != 0) {
|
|
725 |
+ out_event->add_modifier_keys(mozc::commands::KeyEvent::CTRL);
|
|
726 |
+ }
|
|
727 |
+ if ((state & FcitxKeyState_Alt) != 0) {
|
|
728 |
+ out_event->add_modifier_keys(mozc::commands::KeyEvent::ALT);
|
|
729 |
+ }
|
|
730 |
+ if (!IsAscii(sym, state) && (state & FcitxKeyState_Shift) != 0) {
|
|
731 |
+ out_event->add_modifier_keys(mozc::commands::KeyEvent::SHIFT);
|
|
732 |
+ }
|
|
733 |
+
|
|
734 |
+ mozc::commands::KeyEvent::SpecialKey sp_key;
|
|
735 |
+ uint32 sp_ascii;
|
|
736 |
+ string key_string;
|
|
737 |
+
|
|
738 |
+ if (IsSpecialKey(sym, state, &sp_key)) {
|
|
739 |
+ out_event->set_special_key(sp_key);
|
|
740 |
+ } else if (IsSpecialAscii(sym, state, &sp_ascii)) {
|
|
741 |
+ out_event->set_key_code(sp_ascii);
|
|
742 |
+ } else if (method == mozc::config::Config::KANA &&
|
|
743 |
+ IsKanaAvailable(sym, state, &key_string)) {
|
|
744 |
+ DCHECK(IsAscii(sym, state));
|
|
745 |
+ out_event->set_key_code(get_ascii_code(sym));
|
|
746 |
+ out_event->set_key_string(key_string);
|
|
747 |
+ } else {
|
|
748 |
+ DCHECK(IsAscii(sym, state));
|
|
749 |
+ out_event->set_key_code(get_ascii_code(sym));
|
|
750 |
+ }
|
|
751 |
+ return;
|
|
752 |
+}
|
|
753 |
+
|
|
754 |
+void KeyTranslator::TranslateClick(
|
|
755 |
+ int32 unique_id, mozc::commands::SessionCommand *out_command) const {
|
|
756 |
+ DCHECK(out_command);
|
|
757 |
+ if (out_command) {
|
|
758 |
+ out_command->set_type(mozc::commands::SessionCommand::SELECT_CANDIDATE);
|
|
759 |
+ out_command->set_id(unique_id);
|
|
760 |
+ }
|
|
761 |
+ return;
|
|
762 |
+}
|
|
763 |
+
|
|
764 |
+bool KeyTranslator::CanConvert(FcitxKeySym sym, unsigned int state) const {
|
|
765 |
+ if (IsModifierKey(sym, state)) {
|
|
766 |
+ VLOG(1) << "modifier key";
|
|
767 |
+ return false;
|
|
768 |
+ }
|
|
769 |
+ if (IsAscii(sym, state) || IsSpecialKey(sym, state, NULL) || IsSpecialAscii(sym, state, NULL)) {
|
|
770 |
+ return true;
|
|
771 |
+ }
|
|
772 |
+
|
|
773 |
+ char buf[64];
|
|
774 |
+ ::snprintf(
|
|
775 |
+ buf, sizeof(buf), "Key code Mozc doesn't know (0x%08x).", sym);
|
|
776 |
+ LOG(ERROR) << buf;
|
|
777 |
+ return false;
|
|
778 |
+}
|
|
779 |
+
|
|
780 |
+void KeyTranslator::InitializeKeyMaps() {
|
|
781 |
+ for (int i = 0; i < arraysize(sp_key_map); ++i) {
|
|
782 |
+ CHECK(special_key_map_.insert(make_pair(sp_key_map[i].from,
|
|
783 |
+ sp_key_map[i].to)).second);
|
|
784 |
+ }
|
|
785 |
+ for (int i = 0; i < arraysize(sp_ascii_map); ++i) {
|
|
786 |
+ CHECK(special_ascii_map_.insert(make_pair(sp_ascii_map[i].from,
|
|
787 |
+ sp_ascii_map[i].to)).second);
|
|
788 |
+ }
|
|
789 |
+ for (int i = 0; i < arraysize(modifier_keys); ++i) {
|
|
790 |
+ CHECK(modifier_keys_.insert(modifier_keys[i]).second);
|
|
791 |
+ }
|
|
792 |
+ for (int i = 0; i < arraysize(kKanaMapJp); ++i) {
|
|
793 |
+ CHECK(kana_map_jp_.insert(
|
|
794 |
+ make_pair(kKanaMapJp[i].keysym, kKanaMapJp[i].kana)).second);
|
|
795 |
+ }
|
|
796 |
+ for (int i = 0; i < arraysize(kKanaMapUs); ++i) {
|
|
797 |
+ CHECK(kana_map_us_.insert(
|
|
798 |
+ make_pair(kKanaMapUs[i].keysym, kKanaMapUs[i].kana)).second);
|
|
799 |
+ }
|
|
800 |
+}
|
|
801 |
+
|
|
802 |
+bool KeyTranslator::IsModifierKey(FcitxKeySym sym, unsigned int state) const {
|
|
803 |
+ return modifier_keys_.find(sym) != modifier_keys_.end();
|
|
804 |
+}
|
|
805 |
+
|
|
806 |
+bool KeyTranslator::IsSpecialKey(
|
|
807 |
+ FcitxKeySym sym, unsigned int state,
|
|
808 |
+ mozc::commands::KeyEvent::SpecialKey *out) const {
|
|
809 |
+ map<uint32, mozc::commands::KeyEvent::SpecialKey>::const_iterator iter =
|
|
810 |
+ special_key_map_.find(sym);
|
|
811 |
+ if (iter == special_key_map_.end()) {
|
|
812 |
+ return false;
|
|
813 |
+ }
|
|
814 |
+ if (out) {
|
|
815 |
+ *out = iter->second;
|
|
816 |
+ }
|
|
817 |
+ return true;
|
|
818 |
+}
|
|
819 |
+
|
|
820 |
+// static
|
|
821 |
+void KeyTranslator::NormalizeHiraganaKatakanaKeyWithShift(
|
|
822 |
+ FcitxKeySym origsym, unsigned int origstate, FcitxKeySym* sym, unsigned int* state) {
|
|
823 |
+ if (origsym == FcitxKey_Hiragana_Katakana) {
|
|
824 |
+ *sym = FcitxKey_Katakana;
|
|
825 |
+ *state = origstate & ~FcitxKeyState_Shift;
|
|
826 |
+ }
|
|
827 |
+ else {
|
|
828 |
+ *sym = origsym;
|
|
829 |
+ *state = origstate;
|
|
830 |
+ }
|
|
831 |
+}
|
|
832 |
+
|
|
833 |
+
|
|
834 |
+
|
|
835 |
+bool KeyTranslator::IsSpecialAscii(
|
|
836 |
+ FcitxKeySym sym, unsigned int state, uint32 *out) const {
|
|
837 |
+ map<uint32, uint32>::const_iterator iter = special_ascii_map_.find(sym);
|
|
838 |
+ if (iter == special_ascii_map_.end()) {
|
|
839 |
+ return false;
|
|
840 |
+ }
|
|
841 |
+ if (out) {
|
|
842 |
+ *out = iter->second;
|
|
843 |
+ }
|
|
844 |
+ return true;
|
|
845 |
+}
|
|
846 |
+
|
|
847 |
+void KeyTranslator::SetLayout(FcitxMozcLayout l)
|
|
848 |
+{
|
|
849 |
+ layout = l;
|
|
850 |
+}
|
|
851 |
+
|
|
852 |
+void KeyTranslator::SetInputState(FcitxInputState* i)
|
|
853 |
+{
|
|
854 |
+ input = i;
|
|
855 |
+}
|
|
856 |
+
|
|
857 |
+
|
|
858 |
+bool KeyTranslator::IsKanaAvailable(
|
|
859 |
+ FcitxKeySym sym, unsigned int state, string *out) const {
|
|
860 |
+ if ((state & FcitxKeyState_Ctrl) != 0 || (state & FcitxKeyState_Alt) != 0) {
|
|
861 |
+ return false;
|
|
862 |
+ }
|
|
863 |
+ const map<uint32, const char *> &kana_map =
|
|
864 |
+ IsJapaneseLayout(layout) ? kana_map_jp_ : kana_map_us_;
|
|
865 |
+
|
|
866 |
+ // We call get_ascii_code() to support clients that does not send the shift
|
|
867 |
+ // modifier. By calling the function, both "Shift + 3" and "#" would be
|
|
868 |
+ // normalized to '#'.
|
|
869 |
+ const char ascii_code = get_ascii_code(sym);
|
|
870 |
+
|
|
871 |
+ map<uint32, const char *>::const_iterator iter = kana_map.find(ascii_code);
|
|
872 |
+ if (iter == kana_map.end()) {
|
|
873 |
+ return false;
|
|
874 |
+ }
|
|
875 |
+ if (out) {
|
|
876 |
+ if (ascii_code == '\\' && IsJapaneseLayout(layout)) {
|
|
877 |
+ uint32_t keycode = 0;
|
|
878 |
+ if (input)
|
|
879 |
+ keycode = FcitxInputStateGetKeyCode(input);
|
|
880 |
+ if (keycode == FcitxKey_bar) {
|
|
881 |
+ *out = "\xe3\x83\xbc"; // "ー"
|
|
882 |
+ } else {
|
|
883 |
+ *out = "\xe3\x82\x8d"; // "ろ"
|
|
884 |
+ }
|
|
885 |
+ } else {
|
|
886 |
+ *out = iter->second;
|
|
887 |
+ }
|
|
888 |
+ }
|
|
889 |
+ return true;
|
|
890 |
+}
|
|
891 |
+
|
|
892 |
+/* static */
|
|
893 |
+bool KeyTranslator::IsAscii(FcitxKeySym sym, unsigned int state) {
|
|
894 |
+ // get_ascii_code(sym) returns non-zero value for SPACE, ENTER, LineFeed,
|
|
895 |
+ // TAB, BACKSPACE, ESCAPE, and Keypad codes. So we don't use it here.
|
|
896 |
+ return (sym > FcitxKey_space &&
|
|
897 |
+ // Note: Space key (0x20) is a special key in Mozc.
|
|
898 |
+ sym <= FcitxKey_asciitilde); // 0x7e.
|
|
899 |
+}
|
|
900 |
+
|
|
901 |
+/* static */
|
|
902 |
+bool KeyTranslator::IsJapaneseLayout(FcitxMozcLayout layout) {
|
|
903 |
+ // We guess that most people using the Kana input mode uses Japanese
|
|
904 |
+ // keyboards, so we prefer applying the Japanese layout.
|
|
905 |
+ return layout == FcitxMozcLayout_Japanese;
|
|
906 |
+}
|
|
907 |
+
|
|
908 |
+} // namespace fcitx
|
|
909 |
+
|
|
910 |
+} // namespace mozc
|
|
911 |
diff --git a/unix/fcitx/fcitx_key_translator.h b/unix/fcitx/fcitx_key_translator.h
|
|
912 |
new file mode 100644
|
|
913 |
index 0000000..c337974
|
|
914 |
--- /dev/null
|
|
915 |
+++ b/unix/fcitx/fcitx_key_translator.h
|
|
916 |
@@ -0,0 +1,114 @@
|
|
917 |
+/***************************************************************************
|
|
918 |
+ * Copyright (C) 2012~2012 by CSSlayer *
|
|
919 |
+ * *
|
|
920 |
+ * This program is free software; you can redistribute it and/or modify *
|
|
921 |
+ * it under the terms of the GNU General Public License as published by *
|
|
922 |
+ * the Free Software Foundation; either version 2 of the License, or *
|
|
923 |
+ * (at your option) any later version. *
|
|
924 |
+ * *
|
|
925 |
+ * This program is distributed in the hope that it will be useful, *
|
|
926 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
927 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
928 |
+ * GNU General Public License for more details. *
|
|
929 |
+ * *
|
|
930 |
+ * You should have received a copy of the GNU General Public License *
|
|
931 |
+ * along with this program; if not, write to the *
|
|
932 |
+ * Free Software Foundation, Inc., *
|
|
933 |
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
934 |
+ ***************************************************************************/
|
|
935 |
+
|
|
936 |
+#ifndef MOZC_UNIX_FCITX_FCITX_KEY_TRANSLATOR_H_
|
|
937 |
+#define MOZC_UNIX_FCITX_FCITX_KEY_TRANSLATOR_H_
|
|
938 |
+
|
|
939 |
+#include <map>
|
|
940 |
+#include <set>
|
|
941 |
+#include <string>
|
|
942 |
+
|
|
943 |
+#include <fcitx-config/hotkey.h>
|
|
944 |
+
|
|
945 |
+#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
|
|
946 |
+#include "session/commands.pb.h"
|
|
947 |
+#include "unix/fcitx/fcitx_config.h"
|
|
948 |
+#include <fcitx/ime.h>
|
|
949 |
+
|
|
950 |
+namespace mozc {
|
|
951 |
+
|
|
952 |
+namespace fcitx {
|
|
953 |
+
|
|
954 |
+// This class is responsible for converting scim::KeyEvent object (defined in
|
|
955 |
+// /usr/include/scim-1.0/scim_event.h) to IPC input for mozc_server.
|
|
956 |
+class KeyTranslator {
|
|
957 |
+public:
|
|
958 |
+ KeyTranslator();
|
|
959 |
+ ~KeyTranslator();
|
|
960 |
+
|
|
961 |
+ // Converts scim_key into Mozc key code and stores them on out_translated.
|
|
962 |
+ // scim_key must satisfy the following precondition: CanConvert(scim_key)
|
|
963 |
+ void Translate(FcitxKeySym sym,
|
|
964 |
+ unsigned int state,
|
|
965 |
+ mozc::config::Config::PreeditMethod method,
|
|
966 |
+ mozc::commands::KeyEvent *out_event) const;
|
|
967 |
+
|
|
968 |
+ // Converts 'left click on a candidate window' into Mozc message.
|
|
969 |
+ // unique_id: Unique identifier of the clicked candidate.
|
|
970 |
+ void TranslateClick(int32 unique_id,
|
|
971 |
+ mozc::commands::SessionCommand *out_command) const;
|
|
972 |
+
|
|
973 |
+ // Returns true iff scim_key can be converted to mozc::commands::Input.
|
|
974 |
+ // Note: some keys and key events, such as 'key released', 'modifier key
|
|
975 |
+ // pressed', or 'special key that Mozc doesn't know pressed' cannot be
|
|
976 |
+ // converted to mozc::commands::Input.
|
|
977 |
+ bool CanConvert(FcitxKeySym sym, unsigned int state) const;
|
|
978 |
+
|
|
979 |
+ void SetLayout(FcitxMozcLayout l);
|
|
980 |
+
|
|
981 |
+ void SetInputState(FcitxInputState* i);
|
|
982 |
+
|
|
983 |
+private:
|
|
984 |
+ // Returns true iff scim_key is modifier key such as SHIFT, ALT, or CAPSLOCK.
|
|
985 |
+ bool IsModifierKey(FcitxKeySym sym, unsigned int state) const;
|
|
986 |
+
|
|
987 |
+ // Returns true iff scim_key is special key such as ENTER, ESC, or PAGE_UP.
|
|
988 |
+ bool IsSpecialKey(FcitxKeySym sym, unsigned int state,
|
|
989 |
+ mozc::commands::KeyEvent::SpecialKey *out) const;
|
|
990 |
+
|
|
991 |
+ // Returns a normalized key event iff key is HiraganaKatakana with shift
|
|
992 |
+ // modifier. See http://code.google.com/p/mozc/issues/detail?id=136 for
|
|
993 |
+ // the background information.
|
|
994 |
+ // Otherwire returns the original key.
|
|
995 |
+ static void NormalizeHiraganaKatakanaKeyWithShift(
|
|
996 |
+ FcitxKeySym origsym, unsigned int origstate, FcitxKeySym* sym, unsigned int* state);
|
|
997 |
+
|
|
998 |
+ // Returns true iff scim_key is special key that can be converted to ASCII.
|
|
999 |
+ // For example, scim::FCITX_KEY_KP_0 (numeric keypad zero) in FCITX can be
|
|
1000 |
+ // treated as ASCII code '0' in Mozc.
|
|
1001 |
+ bool IsSpecialAscii(FcitxKeySym sym, unsigned int state, uint32 *out) const;
|
|
1002 |
+
|
|
1003 |
+ // Returns true iff scim_key is key with a kana assigned.
|
|
1004 |
+ bool IsKanaAvailable(FcitxKeySym sym, unsigned int state, string *out) const;
|
|
1005 |
+
|
|
1006 |
+ // Returns true iff scim_key is ASCII such as '0', 'A', or '!'.
|
|
1007 |
+ static bool IsAscii(FcitxKeySym sym, unsigned int state);
|
|
1008 |
+
|
|
1009 |
+ // Returns true iff kana_map_jp_ is to be used.
|
|
1010 |
+ static bool IsJapaneseLayout(FcitxMozcLayout layout);
|
|
1011 |
+
|
|
1012 |
+ // Initializes private fields.
|
|
1013 |
+ void InitializeKeyMaps();
|
|
1014 |
+
|
|
1015 |
+ map<uint32, mozc::commands::KeyEvent::SpecialKey> special_key_map_;
|
|
1016 |
+ set<uint32> modifier_keys_;
|
|
1017 |
+ map<uint32, uint32> special_ascii_map_;
|
|
1018 |
+ map<uint32, const char *> kana_map_jp_;
|
|
1019 |
+ map<uint32, const char *> kana_map_us_;
|
|
1020 |
+ FcitxInputState* input;
|
|
1021 |
+ FcitxMozcLayout layout;
|
|
1022 |
+
|
|
1023 |
+ DISALLOW_COPY_AND_ASSIGN(KeyTranslator);
|
|
1024 |
+};
|
|
1025 |
+
|
|
1026 |
+} // namespace fcitx
|
|
1027 |
+
|
|
1028 |
+} // namespace mozc
|
|
1029 |
+
|
|
1030 |
+#endif // MOZC_UNIX_FCITX_FCITX_KEY_TRANSLATOR_H_
|
|
1031 |
diff --git a/unix/fcitx/fcitx_mozc.cc b/unix/fcitx/fcitx_mozc.cc
|
|
1032 |
new file mode 100644
|
|
1033 |
index 0000000..4906e9d
|
|
1034 |
--- /dev/null
|
|
1035 |
+++ b/unix/fcitx/fcitx_mozc.cc
|
|
1036 |
@@ -0,0 +1,522 @@
|
|
1037 |
+/***************************************************************************
|
|
1038 |
+ * Copyright (C) 2012~2012 by CSSlayer *
|
|
1039 |
+ * *
|
|
1040 |
+ * This program is free software; you can redistribute it and/or modify *
|
|
1041 |
+ * it under the terms of the GNU General Public License as published by *
|
|
1042 |
+ * the Free Software Foundation; either version 2 of the License, or *
|
|
1043 |
+ * (at your option) any later version. *
|
|
1044 |
+ * *
|
|
1045 |
+ * This program is distributed in the hope that it will be useful, *
|
|
1046 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
1047 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
1048 |
+ * GNU General Public License for more details. *
|
|
1049 |
+ * *
|
|
1050 |
+ * You should have received a copy of the GNU General Public License *
|
|
1051 |
+ * along with this program; if not, write to the *
|
|
1052 |
+ * Free Software Foundation, Inc., *
|
|
1053 |
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
1054 |
+ ***************************************************************************/
|
|
1055 |
+
|
|
1056 |
+#include "unix/fcitx/fcitx_mozc.h"
|
|
1057 |
+
|
|
1058 |
+#include <string>
|
|
1059 |
+#include <fcitx/candidate.h>
|
|
1060 |
+#include <fcitx-config/xdg.h>
|
|
1061 |
+
|
|
1062 |
+#include "base/const.h"
|
|
1063 |
+#include "base/logging.h"
|
|
1064 |
+#include "base/process.h"
|
|
1065 |
+#include "base/util.h"
|
|
1066 |
+#include "unix/fcitx/mozc_connection.h"
|
|
1067 |
+#include "unix/fcitx/mozc_response_parser.h"
|
|
1068 |
+#include "unix/fcitx/fcitx_key_translator.h"
|
|
1069 |
+#include <fcitx/context.h>
|
|
1070 |
+
|
|
1071 |
+#define N_(x) (x)
|
|
1072 |
+
|
|
1073 |
+namespace
|
|
1074 |
+{
|
|
1075 |
+
|
|
1076 |
+static const std::string empty_string;
|
|
1077 |
+
|
|
1078 |
+const struct CompositionMode
|
|
1079 |
+{
|
|
1080 |
+ const char *icon;
|
|
1081 |
+ const char *label;
|
|
1082 |
+ const char *description;
|
|
1083 |
+ mozc::commands::CompositionMode mode;
|
|
1084 |
+} kPropCompositionModes[] =
|
|
1085 |
+{
|
|
1086 |
+ {
|
|
1087 |
+ "mozc-direct.png",
|
|
1088 |
+ "A",
|
|
1089 |
+ N_("Direct"),
|
|
1090 |
+ mozc::commands::DIRECT,
|
|
1091 |
+ }, {
|
|
1092 |
+ "mozc-hiragana.png",
|
|
1093 |
+ "\xe3\x81\x82", // Hiragana letter A in UTF-8.
|
|
1094 |
+ N_("Hiragana"),
|
|
1095 |
+ mozc::commands::HIRAGANA,
|
|
1096 |
+ }, {
|
|
1097 |
+ "mozc-katakana_full.png",
|
|
1098 |
+ "\xe3\x82\xa2", // Katakana letter A.
|
|
1099 |
+ N_("Full Katakana"),
|
|
1100 |
+ mozc::commands::FULL_KATAKANA,
|
|
1101 |
+ }, {
|
|
1102 |
+ "mozc-alpha_half.png",
|
|
1103 |
+ "A",
|
|
1104 |
+ N_("Half ASCII"),
|
|
1105 |
+ mozc::commands::HALF_ASCII,
|
|
1106 |
+ }, {
|
|
1107 |
+ "mozc-alpha_full.png",
|
|
1108 |
+ "\xef\xbc\xa1", // Full width ASCII letter A.
|
|
1109 |
+ N_("Full ASCII"),
|
|
1110 |
+ mozc::commands::FULL_ASCII,
|
|
1111 |
+ }, {
|
|
1112 |
+ "mozc-katakana_half.png",
|
|
1113 |
+ "\xef\xbd\xb1", // Half width Katakana letter A.
|
|
1114 |
+ N_("Half Katakana"),
|
|
1115 |
+ mozc::commands::HALF_KATAKANA,
|
|
1116 |
+ },
|
|
1117 |
+};
|
|
1118 |
+const size_t kNumCompositionModes = arraysize ( kPropCompositionModes );
|
|
1119 |
+
|
|
1120 |
+// This array must correspond with the CompositionMode enum in the
|
|
1121 |
+// mozc/session/command.proto file.
|
|
1122 |
+COMPILE_ASSERT (
|
|
1123 |
+ mozc::commands::NUM_OF_COMPOSITIONS == arraysize ( kPropCompositionModes ),
|
|
1124 |
+ bad_number_of_modes );
|
|
1125 |
+
|
|
1126 |
+} // namespace
|
|
1127 |
+
|
|
1128 |
+INPUT_RETURN_VALUE FcitxMozcGetCandidateWord(void* arg, FcitxCandidateWord* candWord)
|
|
1129 |
+{
|
|
1130 |
+ mozc::fcitx::FcitxMozc* fcitx_mozc = (mozc::fcitx::FcitxMozc*) arg;
|
|
1131 |
+ fcitx_mozc->select_candidate(candWord);
|
|
1132 |
+
|
|
1133 |
+ return IRV_DISPLAY_CANDWORDS;
|
|
1134 |
+}
|
|
1135 |
+
|
|
1136 |
+
|
|
1137 |
+namespace mozc
|
|
1138 |
+{
|
|
1139 |
+
|
|
1140 |
+namespace fcitx
|
|
1141 |
+{
|
|
1142 |
+
|
|
1143 |
+// For unittests.
|
|
1144 |
+FcitxMozc::FcitxMozc ( FcitxInstance* inst,
|
|
1145 |
+ MozcConnectionInterface *connection,
|
|
1146 |
+ MozcResponseParser *parser ) :
|
|
1147 |
+ instance(inst),
|
|
1148 |
+ input(FcitxInstanceGetInputState(inst)),
|
|
1149 |
+ connection_ ( connection ),
|
|
1150 |
+ parser_ ( parser ),
|
|
1151 |
+ composition_mode_ ( mozc::commands::HIRAGANA )
|
|
1152 |
+{
|
|
1153 |
+ VLOG ( 1 ) << "FcitxMozc created.";
|
|
1154 |
+ const bool is_vertical
|
|
1155 |
+ = false;
|
|
1156 |
+ parser_->set_use_annotation ( is_vertical );
|
|
1157 |
+ InitializeBar();
|
|
1158 |
+ InitializeMenu();
|
|
1159 |
+ SetCompositionMode( mozc::commands::HIRAGANA );
|
|
1160 |
+}
|
|
1161 |
+
|
|
1162 |
+FcitxMozc::~FcitxMozc()
|
|
1163 |
+{
|
|
1164 |
+ VLOG ( 1 ) << "FcitxMozc destroyed.";
|
|
1165 |
+}
|
|
1166 |
+
|
|
1167 |
+// This function is called from SCIM framework when users press or release a
|
|
1168 |
+// key.
|
|
1169 |
+bool FcitxMozc::process_key_event ( FcitxKeySym sym, unsigned int state )
|
|
1170 |
+{
|
|
1171 |
+
|
|
1172 |
+ if ( !connection_->CanSend ( sym, state ) )
|
|
1173 |
+ {
|
|
1174 |
+ VLOG ( 1 ) << "Mozc doesn't handle the key. Not consumed.";
|
|
1175 |
+ return false; // not consumed.
|
|
1176 |
+ }
|
|
1177 |
+
|
|
1178 |
+ string error;
|
|
1179 |
+ mozc::commands::Output raw_response;
|
|
1180 |
+ if ( !connection_->TrySendKeyEvent (
|
|
1181 |
+ sym, state, composition_mode_, &raw_response, &error ) )
|
|
1182 |
+ {
|
|
1183 |
+ // TODO(yusukes): Show |error|.
|
|
1184 |
+ return false; // not consumed.
|
|
1185 |
+ }
|
|
1186 |
+
|
|
1187 |
+ return ParseResponse ( raw_response );
|
|
1188 |
+}
|
|
1189 |
+
|
|
1190 |
+// This function is called from SCIM framework when users click the candidate
|
|
1191 |
+// window.
|
|
1192 |
+void FcitxMozc::select_candidate ( FcitxCandidateWord* candWord )
|
|
1193 |
+{
|
|
1194 |
+ int32 *id = (int32*) candWord->priv;
|
|
1195 |
+
|
|
1196 |
+ if ( *id == kBadCandidateId )
|
|
1197 |
+ {
|
|
1198 |
+ LOG ( ERROR ) << "The clicked candidate doesn't have unique ID.";
|
|
1199 |
+ return;
|
|
1200 |
+ }
|
|
1201 |
+ VLOG ( 1 ) << "select_candidate, id=" << *id;
|
|
1202 |
+
|
|
1203 |
+ string error;
|
|
1204 |
+ mozc::commands::Output raw_response;
|
|
1205 |
+ if ( !connection_->TrySendClick ( *id, &raw_response, &error ) )
|
|
1206 |
+ {
|
|
1207 |
+ LOG ( ERROR ) << "IPC failed. error=" << error;
|
|
1208 |
+ SetAuxString ( error );
|
|
1209 |
+ DrawAll();
|
|
1210 |
+ }
|
|
1211 |
+ else
|
|
1212 |
+ {
|
|
1213 |
+ ParseResponse ( raw_response );
|
|
1214 |
+ }
|
|
1215 |
+}
|
|
1216 |
+
|
|
1217 |
+// This function is called from SCIM framework.
|
|
1218 |
+void FcitxMozc::resetim()
|
|
1219 |
+{
|
|
1220 |
+ VLOG ( 1 ) << "resetim";
|
|
1221 |
+ string error;
|
|
1222 |
+ mozc::commands::Output raw_response;
|
|
1223 |
+ if ( connection_->TrySendCommand (
|
|
1224 |
+ mozc::commands::SessionCommand::REVERT, &raw_response, &error ) )
|
|
1225 |
+ {
|
|
1226 |
+ parser_->ParseResponse ( raw_response, this );
|
|
1227 |
+ }
|
|
1228 |
+ ClearAll(); // just in case.
|
|
1229 |
+ DrawAll();
|
|
1230 |
+
|
|
1231 |
+}
|
|
1232 |
+
|
|
1233 |
+void FcitxMozc::reset()
|
|
1234 |
+{
|
|
1235 |
+ FcitxIM* im = FcitxInstanceGetCurrentIM(instance);
|
|
1236 |
+ if (!im || strcmp(im->uniqueName, "mozc") != 0) {
|
|
1237 |
+ FcitxUISetStatusVisable(instance, "mozc-tool", false);
|
|
1238 |
+ FcitxUISetStatusVisable(instance, "mozc-composition-mode", false);
|
|
1239 |
+ }
|
|
1240 |
+ else {
|
|
1241 |
+ FcitxUISetStatusVisable(instance, "mozc-tool", true);
|
|
1242 |
+ FcitxUISetStatusVisable(instance, "mozc-composition-mode", true);
|
|
1243 |
+ }
|
|
1244 |
+}
|
|
1245 |
+
|
|
1246 |
+
|
|
1247 |
+// This function is called from SCIM framework when the ic gets focus.
|
|
1248 |
+void FcitxMozc::init()
|
|
1249 |
+{
|
|
1250 |
+ VLOG ( 1 ) << "focus_in";
|
|
1251 |
+ boolean flag = false;
|
|
1252 |
+ FcitxInstanceSetContext(instance, CONTEXT_DISABLE_AUTOENG, &flag);
|
|
1253 |
+ FcitxInstanceSetContext(instance, CONTEXT_DISABLE_QUICKPHRASE, &flag);
|
|
1254 |
+ FcitxInstanceSetContext(instance, CONTEXT_IM_KEYBOARD_LAYOUT, "jp");
|
|
1255 |
+ DrawAll();
|
|
1256 |
+}
|
|
1257 |
+
|
|
1258 |
+// This function is called when the ic loses focus.
|
|
1259 |
+void FcitxMozc::focus_out()
|
|
1260 |
+{
|
|
1261 |
+ VLOG ( 1 ) << "focus_out";
|
|
1262 |
+ string error;
|
|
1263 |
+ mozc::commands::Output raw_response;
|
|
1264 |
+ if ( connection_->TrySendCommand (
|
|
1265 |
+ mozc::commands::SessionCommand::REVERT, &raw_response, &error ) )
|
|
1266 |
+ {
|
|
1267 |
+ parser_->ParseResponse ( raw_response, this );
|
|
1268 |
+ }
|
|
1269 |
+ ClearAll(); // just in case.
|
|
1270 |
+ DrawAll();
|
|
1271 |
+ // TODO(yusukes): Call client::SyncData() like ibus-mozc.
|
|
1272 |
+}
|
|
1273 |
+
|
|
1274 |
+
|
|
1275 |
+bool FcitxMozc::ParseResponse ( const mozc::commands::Output &raw_response )
|
|
1276 |
+{
|
|
1277 |
+ ClearAll();
|
|
1278 |
+ const bool consumed = parser_->ParseResponse ( raw_response, this );
|
|
1279 |
+ if ( !consumed )
|
|
1280 |
+ {
|
|
1281 |
+ VLOG ( 1 ) << "The input was not consumed by Mozc.";
|
|
1282 |
+ }
|
|
1283 |
+ OpenUrl();
|
|
1284 |
+ DrawAll();
|
|
1285 |
+ return consumed;
|
|
1286 |
+}
|
|
1287 |
+
|
|
1288 |
+void FcitxMozc::SetResultString ( const std::string &result_string )
|
|
1289 |
+{
|
|
1290 |
+ FcitxInstanceCommitString(instance, FcitxInstanceGetCurrentIC(instance), result_string.c_str());
|
|
1291 |
+}
|
|
1292 |
+
|
|
1293 |
+void FcitxMozc::SetPreeditInfo ( const PreeditInfo *preedit_info )
|
|
1294 |
+{
|
|
1295 |
+ preedit_info_.reset ( preedit_info );
|
|
1296 |
+}
|
|
1297 |
+
|
|
1298 |
+void FcitxMozc::SetAuxString ( const std::string &str )
|
|
1299 |
+{
|
|
1300 |
+ aux_ = str;
|
|
1301 |
+}
|
|
1302 |
+
|
|
1303 |
+void FcitxMozc::SetCompositionMode ( mozc::commands::CompositionMode mode )
|
|
1304 |
+{
|
|
1305 |
+ composition_mode_ = mode;
|
|
1306 |
+ DCHECK(composition_mode_ < kNumCompositionModes);
|
|
1307 |
+ if (composition_mode_ < kNumCompositionModes) {
|
|
1308 |
+ FcitxUISetStatusString(instance,
|
|
1309 |
+ "mozc-composition-mode",
|
|
1310 |
+ _(kPropCompositionModes[composition_mode_].label),
|
|
1311 |
+ _(kPropCompositionModes[composition_mode_].description));
|
|
1312 |
+ }
|
|
1313 |
+}
|
|
1314 |
+
|
|
1315 |
+void FcitxMozc::SendCompositionMode(mozc::commands::CompositionMode mode)
|
|
1316 |
+{
|
|
1317 |
+ // Send the SWITCH_INPUT_MODE command.
|
|
1318 |
+ string error;
|
|
1319 |
+ mozc::commands::Output raw_response;
|
|
1320 |
+ if (connection_->TrySendCompositionMode(
|
|
1321 |
+ kPropCompositionModes[mode].mode, &raw_response, &error)) {
|
|
1322 |
+ parser_->ParseResponse(raw_response, this);
|
|
1323 |
+ }
|
|
1324 |
+}
|
|
1325 |
+
|
|
1326 |
+
|
|
1327 |
+void FcitxMozc::SetUrl ( const string &url )
|
|
1328 |
+{
|
|
1329 |
+ url_ = url;
|
|
1330 |
+}
|
|
1331 |
+
|
|
1332 |
+void FcitxMozc::ClearAll()
|
|
1333 |
+{
|
|
1334 |
+ SetPreeditInfo ( NULL );
|
|
1335 |
+ SetAuxString ( "" );
|
|
1336 |
+ FcitxCandidateWordReset(FcitxInputStateGetCandidateList(input));
|
|
1337 |
+ url_.clear();
|
|
1338 |
+}
|
|
1339 |
+
|
|
1340 |
+void FcitxMozc::DrawPreeditInfo()
|
|
1341 |
+{
|
|
1342 |
+ FcitxProfile* profile = FcitxInstanceGetProfile(instance);
|
|
1343 |
+ FcitxMessages* preedit = FcitxInputStateGetPreedit(input);
|
|
1344 |
+ FcitxMessages* clientpreedit = FcitxInputStateGetClientPreedit(input);
|
|
1345 |
+ FcitxMessagesSetMessageCount(preedit, 0);
|
|
1346 |
+ FcitxMessagesSetMessageCount(clientpreedit, 0);
|
|
1347 |
+ FcitxInputContext* ic = FcitxInstanceGetCurrentIC(instance);
|
|
1348 |
+ if ( preedit_info_.get() )
|
|
1349 |
+ {
|
|
1350 |
+ VLOG ( 1 ) << "DrawPreeditInfo: cursor=" << preedit_info_->cursor_pos;
|
|
1351 |
+
|
|
1352 |
+ if (ic && ((ic->contextCaps & CAPACITY_PREEDIT) == 0 || !profile->bUsePreedit))
|
|
1353 |
+ FcitxInputStateSetShowCursor(input, true);
|
|
1354 |
+
|
|
1355 |
+ for (int i = 0; i < preedit_info_->preedit.size(); i ++) {
|
|
1356 |
+ if (ic && ((ic->contextCaps & CAPACITY_PREEDIT) == 0 || !profile->bUsePreedit))
|
|
1357 |
+ FcitxMessagesAddMessageAtLast(preedit, preedit_info_->preedit[i].type, "%s", preedit_info_->preedit[i].str.c_str());
|
|
1358 |
+ FcitxMessagesAddMessageAtLast(clientpreedit, preedit_info_->preedit[i].type, "%s", preedit_info_->preedit[i].str.c_str());
|
|
1359 |
+ }
|
|
1360 |
+ if (ic && ((ic->contextCaps & CAPACITY_PREEDIT) == 0 || !profile->bUsePreedit))
|
|
1361 |
+ FcitxInputStateSetCursorPos(input, preedit_info_->cursor_pos);
|
|
1362 |
+ FcitxInputStateSetClientCursorPos(input, preedit_info_->cursor_pos);
|
|
1363 |
+ }
|
|
1364 |
+ else {
|
|
1365 |
+ FcitxInputStateSetShowCursor(input, true);
|
|
1366 |
+ }
|
|
1367 |
+}
|
|
1368 |
+
|
|
1369 |
+void FcitxMozc::DrawAux()
|
|
1370 |
+{
|
|
1371 |
+ FcitxMessages* auxUp = FcitxInputStateGetAuxUp(input);
|
|
1372 |
+ FcitxMessages* auxDown = FcitxInputStateGetAuxDown(input);
|
|
1373 |
+ FcitxMessagesSetMessageCount(auxUp, 0);
|
|
1374 |
+ FcitxMessagesSetMessageCount(auxDown, 0);
|
|
1375 |
+ if ( !aux_.empty() ) {
|
|
1376 |
+ FcitxMessagesAddMessageAtLast(auxUp, MSG_TIPS, "%s ", aux_.c_str());
|
|
1377 |
+ }
|
|
1378 |
+}
|
|
1379 |
+
|
|
1380 |
+void FcitxMozc::DrawAll()
|
|
1381 |
+{
|
|
1382 |
+ DrawPreeditInfo();
|
|
1383 |
+ DrawAux();
|
|
1384 |
+}
|
|
1385 |
+
|
|
1386 |
+void FcitxMozc::OpenUrl()
|
|
1387 |
+{
|
|
1388 |
+ if ( url_.empty() )
|
|
1389 |
+ {
|
|
1390 |
+ return;
|
|
1391 |
+ }
|
|
1392 |
+ mozc::Process::OpenBrowser ( url_ );
|
|
1393 |
+ url_.clear();
|
|
1394 |
+}
|
|
1395 |
+
|
|
1396 |
+static const char* GetCompositionIconName(void* arg)
|
|
1397 |
+{
|
|
1398 |
+ FcitxMozc* mozc = (FcitxMozc*) arg;
|
|
1399 |
+ return mozc->GetCurrentCompositionModeIcon().c_str();
|
|
1400 |
+}
|
|
1401 |
+
|
|
1402 |
+
|
|
1403 |
+static const char* GetMozcToolIcon(void* arg)
|
|
1404 |
+{
|
|
1405 |
+ FcitxMozc* mozc = (FcitxMozc*) arg;
|
|
1406 |
+ return mozc->GetIconFile("mozc-tool.png").c_str();
|
|
1407 |
+}
|
|
1408 |
+
|
|
1409 |
+void FcitxMozc::InitializeBar()
|
|
1410 |
+{
|
|
1411 |
+ VLOG ( 1 ) << "Registering properties";
|
|
1412 |
+
|
|
1413 |
+ FcitxUIRegisterComplexStatus(instance, this,
|
|
1414 |
+ "mozc-composition-mode",
|
|
1415 |
+ _("Composition Mode"),
|
|
1416 |
+ _("Composition Mode"),
|
|
1417 |
+ NULL,
|
|
1418 |
+ GetCompositionIconName
|
|
1419 |
+ );
|
|
1420 |
+
|
|
1421 |
+ if ( mozc::Util::FileExists ( mozc::Util::JoinPath (
|
|
1422 |
+ mozc::Util::GetServerDirectory(), mozc::kMozcTool ) ) )
|
|
1423 |
+ {
|
|
1424 |
+ FcitxUIRegisterComplexStatus(instance, this,
|
|
1425 |
+ "mozc-tool",
|
|
1426 |
+ _("Tool"),
|
|
1427 |
+ _("Tool"),
|
|
1428 |
+ NULL,
|
|
1429 |
+ GetMozcToolIcon
|
|
1430 |
+ );
|
|
1431 |
+ }
|
|
1432 |
+ FcitxUISetStatusVisable(instance, "mozc-tool", false);
|
|
1433 |
+ FcitxUISetStatusVisable(instance, "mozc-composition-mode", false);
|
|
1434 |
+}
|
|
1435 |
+
|
|
1436 |
+FcitxMozc::FcitxMozc(const mozc::fcitx::FcitxMozc& )
|
|
1437 |
+{
|
|
1438 |
+
|
|
1439 |
+}
|
|
1440 |
+
|
|
1441 |
+boolean CompositionMenuAction(struct _FcitxUIMenu *menu, int index)
|
|
1442 |
+{
|
|
1443 |
+ FcitxMozc* mozc = (FcitxMozc*) menu->priv;
|
|
1444 |
+ if (index == mozc::commands::DIRECT) {
|
|
1445 |
+ FcitxInstanceCloseIM(mozc->GetInstance(), FcitxInstanceGetCurrentIC(mozc->GetInstance()));
|
|
1446 |
+ }
|
|
1447 |
+ else {
|
|
1448 |
+ mozc->SendCompositionMode((mozc::commands::CompositionMode) index);
|
|
1449 |
+ }
|
|
1450 |
+ return true;
|
|
1451 |
+}
|
|
1452 |
+
|
|
1453 |
+void UpdateCompositionMenu(struct _FcitxUIMenu *menu)
|
|
1454 |
+{
|
|
1455 |
+ FcitxMozc* mozc = (FcitxMozc*) menu->priv;
|
|
1456 |
+ menu->mark = mozc->GetCompositionMode();
|
|
1457 |
+}
|
|
1458 |
+
|
|
1459 |
+boolean ToolMenuAction(struct _FcitxUIMenu *menu, int index)
|
|
1460 |
+{
|
|
1461 |
+ string args;
|
|
1462 |
+ switch(index) {
|
|
1463 |
+ case 0:
|
|
1464 |
+ args = "--mode=config_dialog";
|
|
1465 |
+ break;
|
|
1466 |
+ case 1:
|
|
1467 |
+ args = "--mode=dictionary_tool";
|
|
1468 |
+ break;
|
|
1469 |
+ case 2:
|
|
1470 |
+ args = "--mode=hand_writing";
|
|
1471 |
+ break;
|
|
1472 |
+ case 3:
|
|
1473 |
+ args = "--mode=character_palette";
|
|
1474 |
+ break;
|
|
1475 |
+ case 4:
|
|
1476 |
+ args = "--mode=word_register_dialog";
|
|
1477 |
+ break;
|
|
1478 |
+ case 5:
|
|
1479 |
+ args = "--mode=about_dialog";
|
|
1480 |
+ break;
|
|
1481 |
+ }
|
|
1482 |
+ mozc::Process::SpawnMozcProcess("mozc_tool", args);
|
|
1483 |
+ return true;
|
|
1484 |
+}
|
|
1485 |
+
|
|
1486 |
+void UpdateToolMenu(struct _FcitxUIMenu *menu)
|
|
1487 |
+{
|
|
1488 |
+ return;
|
|
1489 |
+}
|
|
1490 |
+
|
|
1491 |
+void FcitxMozc::InitializeMenu()
|
|
1492 |
+{
|
|
1493 |
+ FcitxMenuInit(&this->compositionMenu);
|
|
1494 |
+ compositionMenu.name = strdup(_("Composition Mode"));
|
|
1495 |
+ compositionMenu.candStatusBind = strdup("mozc-composition-mode");
|
|
1496 |
+ compositionMenu.UpdateMenu = UpdateCompositionMenu;
|
|
1497 |
+ compositionMenu.MenuAction = CompositionMenuAction;
|
|
1498 |
+ compositionMenu.priv = this;
|
|
1499 |
+ compositionMenu.isSubMenu = false;
|
|
1500 |
+ int i;
|
|
1501 |
+ for (i = 0; i < kNumCompositionModes; i ++)
|
|
1502 |
+ FcitxMenuAddMenuItem(&compositionMenu, _(kPropCompositionModes[i].description), MENUTYPE_SIMPLE, NULL);
|
|
1503 |
+
|
|
1504 |
+ FcitxUIRegisterMenu(instance, &compositionMenu);
|
|
1505 |
+
|
|
1506 |
+ FcitxMenuInit(&this->toolMenu);
|
|
1507 |
+ toolMenu.name = strdup(_("Mozc Tool"));
|
|
1508 |
+ toolMenu.candStatusBind = strdup("mozc-tool");
|
|
1509 |
+ toolMenu.UpdateMenu = UpdateToolMenu;
|
|
1510 |
+ toolMenu.MenuAction = ToolMenuAction;
|
|
1511 |
+ toolMenu.priv = this;
|
|
1512 |
+ toolMenu.isSubMenu = false;
|
|
1513 |
+ FcitxMenuAddMenuItem(&toolMenu, _("Configuration Tool"), MENUTYPE_SIMPLE, NULL);
|
|
1514 |
+ FcitxMenuAddMenuItem(&toolMenu, _("Dictionary Tool"), MENUTYPE_SIMPLE, NULL);
|
|
1515 |
+ FcitxMenuAddMenuItem(&toolMenu, _("Hand Writing"), MENUTYPE_SIMPLE, NULL);
|
|
1516 |
+ FcitxMenuAddMenuItem(&toolMenu, _("Character Palette"), MENUTYPE_SIMPLE, NULL);
|
|
1517 |
+ FcitxMenuAddMenuItem(&toolMenu, _("Add Word"), MENUTYPE_SIMPLE, NULL);
|
|
1518 |
+ FcitxMenuAddMenuItem(&toolMenu, _("About Mozc"), MENUTYPE_SIMPLE, NULL);
|
|
1519 |
+ FcitxUIRegisterMenu(instance, &toolMenu);
|
|
1520 |
+}
|
|
1521 |
+
|
|
1522 |
+FcitxInputState* FcitxMozc::GetInputState()
|
|
1523 |
+{
|
|
1524 |
+ return input;
|
|
1525 |
+}
|
|
1526 |
+
|
|
1527 |
+const std::string& FcitxMozc::GetIconFile(const std::string key)
|
|
1528 |
+{
|
|
1529 |
+ if (iconMap.count(key)) {
|
|
1530 |
+ return iconMap[key];
|
|
1531 |
+ }
|
|
1532 |
+
|
|
1533 |
+ char* retFile;
|
|
1534 |
+ FILE* fp = FcitxXDGGetFileWithPrefix("mozc/icon", key.c_str(), "r", &retFile);
|
|
1535 |
+ if (fp)
|
|
1536 |
+ fclose(fp);
|
|
1537 |
+ if (retFile) {
|
|
1538 |
+ iconMap[key] = std::string(retFile);
|
|
1539 |
+ free(retFile);
|
|
1540 |
+ }
|
|
1541 |
+ else {
|
|
1542 |
+ iconMap[key] = "";
|
|
1543 |
+ }
|
|
1544 |
+ return iconMap[key];
|
|
1545 |
+}
|
|
1546 |
+
|
|
1547 |
+
|
|
1548 |
+const std::string& FcitxMozc::GetCurrentCompositionModeIcon() {
|
|
1549 |
+ DCHECK(composition_mode_ < kNumCompositionModes);
|
|
1550 |
+ if (composition_mode_ < kNumCompositionModes) {
|
|
1551 |
+ return GetIconFile(kPropCompositionModes[composition_mode_].icon);
|
|
1552 |
+ }
|
|
1553 |
+ return empty_string;
|
|
1554 |
+}
|
|
1555 |
+
|
|
1556 |
+} // namespace fcitx
|
|
1557 |
+
|
|
1558 |
+} // namespace mozc_unix_scim
|
|
1559 |
diff --git a/unix/fcitx/fcitx_mozc.h b/unix/fcitx/fcitx_mozc.h
|
|
1560 |
new file mode 100644
|
|
1561 |
index 0000000..3c0dfb4
|
|
1562 |
--- /dev/null
|
|
1563 |
+++ b/unix/fcitx/fcitx_mozc.h
|
|
1564 |
@@ -0,0 +1,150 @@
|
|
1565 |
+/***************************************************************************
|
|
1566 |
+ * Copyright (C) 2012~2012 by CSSlayer *
|
|
1567 |
+ * *
|
|
1568 |
+ * This program is free software; you can redistribute it and/or modify *
|
|
1569 |
+ * it under the terms of the GNU General Public License as published by *
|
|
1570 |
+ * the Free Software Foundation; either version 2 of the License, or *
|
|
1571 |
+ * (at your option) any later version. *
|
|
1572 |
+ * *
|
|
1573 |
+ * This program is distributed in the hope that it will be useful, *
|
|
1574 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
1575 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
1576 |
+ * GNU General Public License for more details. *
|
|
1577 |
+ * *
|
|
1578 |
+ * You should have received a copy of the GNU General Public License *
|
|
1579 |
+ * along with this program; if not, write to the *
|
|
1580 |
+ * Free Software Foundation, Inc., *
|
|
1581 |
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
1582 |
+ ***************************************************************************/
|
|
1583 |
+
|
|
1584 |
+
|
|
1585 |
+#ifndef MOZC_UNIX_FCITX_FCITX_MOZC_H_
|
|
1586 |
+#define MOZC_UNIX_FCITX_FCITX_MOZC_H_
|
|
1587 |
+
|
|
1588 |
+#include <fcitx/instance.h>
|
|
1589 |
+#include <fcitx/candidate.h>
|
|
1590 |
+#include <fcitx-config/hotkey.h>
|
|
1591 |
+#include <libintl.h>
|
|
1592 |
+#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
|
|
1593 |
+#include "base/run_level.h"
|
|
1594 |
+#include "session/commands.pb.h"
|
|
1595 |
+
|
|
1596 |
+#define _(x) dgettext("fcitx-mozc", (x))
|
|
1597 |
+
|
|
1598 |
+INPUT_RETURN_VALUE FcitxMozcGetCandidateWord(void* arg, FcitxCandidateWord* candWord);;
|
|
1599 |
+
|
|
1600 |
+namespace mozc
|
|
1601 |
+{
|
|
1602 |
+
|
|
1603 |
+namespace fcitx
|
|
1604 |
+{
|
|
1605 |
+const int32 kBadCandidateId = -12345;
|
|
1606 |
+class IMEngineFactory;
|
|
1607 |
+class MozcConnectionInterface;
|
|
1608 |
+class MozcResponseParser;
|
|
1609 |
+class KeyTranslator;
|
|
1610 |
+
|
|
1611 |
+struct PreeditItem {
|
|
1612 |
+ std::string str;
|
|
1613 |
+ FcitxMessageType type;
|
|
1614 |
+};
|
|
1615 |
+
|
|
1616 |
+// Preedit string and its attributes.
|
|
1617 |
+struct PreeditInfo
|
|
1618 |
+{
|
|
1619 |
+ uint32 cursor_pos;
|
|
1620 |
+
|
|
1621 |
+ std::vector<PreeditItem> preedit;
|
|
1622 |
+};
|
|
1623 |
+
|
|
1624 |
+class FcitxMozc
|
|
1625 |
+{
|
|
1626 |
+public:
|
|
1627 |
+ // This constructor is used by unittests.
|
|
1628 |
+ FcitxMozc ( FcitxInstance* instance,
|
|
1629 |
+ MozcConnectionInterface *connection,
|
|
1630 |
+ MozcResponseParser *parser );
|
|
1631 |
+ virtual ~FcitxMozc();
|
|
1632 |
+
|
|
1633 |
+ bool process_key_event ( FcitxKeySym sym, unsigned int state );
|
|
1634 |
+ void select_candidate ( FcitxCandidateWord* candWord );
|
|
1635 |
+ void resetim();
|
|
1636 |
+ void reset();
|
|
1637 |
+ void init();
|
|
1638 |
+ void focus_out();
|
|
1639 |
+
|
|
1640 |
+ // Functions called by the MozcResponseParser class to update UI.
|
|
1641 |
+
|
|
1642 |
+ // Displays a 'result' (aka 'commit string') on FCITX UI.
|
|
1643 |
+ void SetResultString ( const std::string &result_string );
|
|
1644 |
+ // Displays a 'preedit' string on FCITX UI. This function takes ownership
|
|
1645 |
+ // of preedit_info. If the parameter is NULL, hides the string currently
|
|
1646 |
+ // displayed.
|
|
1647 |
+ void SetPreeditInfo ( const PreeditInfo *preedit_info );
|
|
1648 |
+ // Displays an auxiliary message (e.g., an error message, a title of
|
|
1649 |
+ // candidate window). If the string is empty (""), hides the message
|
|
1650 |
+ // currently being displayed.
|
|
1651 |
+ void SetAuxString ( const std::string &str );
|
|
1652 |
+ // Sets a current composition mode (e.g., Hankaku Katakana).
|
|
1653 |
+ void SetCompositionMode ( mozc::commands::CompositionMode mode );
|
|
1654 |
+
|
|
1655 |
+ void SendCompositionMode ( mozc::commands::CompositionMode mode );
|
|
1656 |
+
|
|
1657 |
+ // Sets the url to be opened by the default browser.
|
|
1658 |
+ void SetUrl ( const string &url );
|
|
1659 |
+
|
|
1660 |
+ const std::string& GetIconFile(const std::string key);
|
|
1661 |
+
|
|
1662 |
+ const std::string& GetCurrentCompositionModeIcon();
|
|
1663 |
+
|
|
1664 |
+ mozc::commands::CompositionMode GetCompositionMode() { return composition_mode_; }
|
|
1665 |
+
|
|
1666 |
+ FcitxInstance* GetInstance() { return instance; }
|
|
1667 |
+
|
|
1668 |
+ FcitxInputState* GetInputState();
|
|
1669 |
+
|
|
1670 |
+private:
|
|
1671 |
+ friend class FcitxMozcTest;
|
|
1672 |
+
|
|
1673 |
+ // Adds Mozc-specific icons to FCITX toolbar.
|
|
1674 |
+ void InitializeBar();
|
|
1675 |
+
|
|
1676 |
+ void InitializeMenu();
|
|
1677 |
+
|
|
1678 |
+ // Parses the response from mozc_server. Returns whether the server consumes
|
|
1679 |
+ // the input or not (true means 'consumed').
|
|
1680 |
+ bool ParseResponse ( const mozc::commands::Output &request );
|
|
1681 |
+
|
|
1682 |
+ void ClearAll();
|
|
1683 |
+ void DrawAll();
|
|
1684 |
+ void DrawPreeditInfo();
|
|
1685 |
+ void DrawAux();
|
|
1686 |
+
|
|
1687 |
+ // Open url_ with a default browser.
|
|
1688 |
+ void OpenUrl();
|
|
1689 |
+
|
|
1690 |
+ FcitxInstance* instance;
|
|
1691 |
+ FcitxInputState* input;
|
|
1692 |
+ const scoped_ptr<MozcConnectionInterface> connection_;
|
|
1693 |
+ const scoped_ptr<MozcResponseParser> parser_;
|
|
1694 |
+
|
|
1695 |
+ // Strings and a window currently displayed on FCITX UI.
|
|
1696 |
+ scoped_ptr<const PreeditInfo> preedit_info_;
|
|
1697 |
+ std::string aux_; // error tooltip, or candidate window title.
|
|
1698 |
+ string url_; // URL to be opened by a browser.
|
|
1699 |
+ mozc::commands::CompositionMode composition_mode_;
|
|
1700 |
+
|
|
1701 |
+ std::map<std::string, std::string> iconMap;
|
|
1702 |
+
|
|
1703 |
+ FcitxUIMenu compositionMenu;
|
|
1704 |
+ FcitxUIMenu toolMenu;
|
|
1705 |
+
|
|
1706 |
+ DISALLOW_COPY_AND_ASSIGN ( FcitxMozc );
|
|
1707 |
+};
|
|
1708 |
+
|
|
1709 |
+} // namespace fcitx
|
|
1710 |
+
|
|
1711 |
+} // namespace mozc
|
|
1712 |
+
|
|
1713 |
+#endif // MOZC_UNIX_FCITX_FCITX_MOZC_H_
|
|
1714 |
+
|
|
1715 |
diff --git a/unix/fcitx/gen_fcitx_mozc_i18n.sh b/unix/fcitx/gen_fcitx_mozc_i18n.sh
|
|
1716 |
new file mode 100755
|
|
1717 |
index 0000000..b730b82
|
|
1718 |
--- /dev/null
|
|
1719 |
+++ b/unix/fcitx/gen_fcitx_mozc_i18n.sh
|
|
1720 |
@@ -0,0 +1,11 @@
|
|
1721 |
+#!/bin/sh
|
|
1722 |
+objdir="$1"
|
|
1723 |
+
|
|
1724 |
+cd po || exit 1
|
|
1725 |
+
|
|
1726 |
+mkdir -p "$1"
|
|
1727 |
+
|
|
1728 |
+for pofile in *.po
|
|
1729 |
+do
|
|
1730 |
+ msgfmt "$pofile" -o "$1/${pofile/po/mo}"
|
|
1731 |
+done
|
|
1732 |
\ No newline at end of file
|
|
1733 |
diff --git a/unix/fcitx/mozc.conf b/unix/fcitx/mozc.conf
|
|
1734 |
new file mode 100644
|
|
1735 |
index 0000000..6c077e9
|
|
1736 |
--- /dev/null
|
|
1737 |
+++ b/unix/fcitx/mozc.conf
|
|
1738 |
@@ -0,0 +1,7 @@
|
|
1739 |
+[InputMethod]
|
|
1740 |
+UniqueName=mozc
|
|
1741 |
+Name=Mozc
|
|
1742 |
+IconName=/usr/share/fcitx/mozc/icon/mozc.png
|
|
1743 |
+Priority=1
|
|
1744 |
+LangCode=ja_JP
|
|
1745 |
+Parent=fcitx-mozc
|
|
1746 |
diff --git a/unix/fcitx/mozc_connection.cc b/unix/fcitx/mozc_connection.cc
|
|
1747 |
new file mode 100755
|
|
1748 |
index 0000000..cf19c66
|
|
1749 |
--- /dev/null
|
|
1750 |
+++ b/unix/fcitx/mozc_connection.cc
|
|
1751 |
@@ -0,0 +1,174 @@
|
|
1752 |
+// Copyright 2010-2012, Google Inc.
|
|
1753 |
+// All rights reserved.
|
|
1754 |
+//
|
|
1755 |
+// Redistribution and use in source and binary forms, with or without
|
|
1756 |
+// modification, are permitted provided that the following conditions are
|
|
1757 |
+// met:
|
|
1758 |
+//
|
|
1759 |
+// * Redistributions of source code must retain the above copyright
|
|
1760 |
+// notice, this list of conditions and the following disclaimer.
|
|
1761 |
+// * Redistributions in binary form must reproduce the above
|
|
1762 |
+// copyright notice, this list of conditions and the following disclaimer
|
|
1763 |
+// in the documentation and/or other materials provided with the
|
|
1764 |
+// distribution.
|
|
1765 |
+// * Neither the name of Google Inc. nor the names of its
|
|
1766 |
+// contributors may be used to endorse or promote products derived from
|
|
1767 |
+// this software without specific prior written permission.
|
|
1768 |
+//
|
|
1769 |
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
1770 |
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
1771 |
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
1772 |
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
1773 |
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
1774 |
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
1775 |
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
1776 |
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
1777 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
1778 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
1779 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1780 |
+
|
|
1781 |
+#include "unix/fcitx/mozc_connection.h"
|
|
1782 |
+
|
|
1783 |
+#include <string>
|
|
1784 |
+
|
|
1785 |
+#include "base/logging.h"
|
|
1786 |
+#include "base/util.h"
|
|
1787 |
+#include "client/client.h"
|
|
1788 |
+#include "ipc/ipc.h"
|
|
1789 |
+#include "session/commands.pb.h"
|
|
1790 |
+#include "session/ime_switch_util.h"
|
|
1791 |
+#include "unix/fcitx/fcitx_key_translator.h"
|
|
1792 |
+
|
|
1793 |
+namespace mozc {
|
|
1794 |
+namespace fcitx {
|
|
1795 |
+
|
|
1796 |
+MozcConnectionInterface::~MozcConnectionInterface() {
|
|
1797 |
+}
|
|
1798 |
+
|
|
1799 |
+MozcConnection::MozcConnection(
|
|
1800 |
+ mozc::client::ServerLauncherInterface *server_launcher,
|
|
1801 |
+ mozc::IPCClientFactoryInterface *client_factory)
|
|
1802 |
+ : translator_(new KeyTranslator),
|
|
1803 |
+ preedit_method_(mozc::config::Config::ROMAN),
|
|
1804 |
+ client_factory_(client_factory) {
|
|
1805 |
+ VLOG(1) << "MozcConnection is created";
|
|
1806 |
+ mozc::client::ClientInterface *client =
|
|
1807 |
+ mozc::client::ClientFactory::NewClient();
|
|
1808 |
+ client->SetServerLauncher(server_launcher);
|
|
1809 |
+ client->SetIPCClientFactory(client_factory_.get());
|
|
1810 |
+ client_.reset(client);
|
|
1811 |
+
|
|
1812 |
+ mozc::config::Config config;
|
|
1813 |
+ if (client_->EnsureConnection() &&
|
|
1814 |
+ client_->GetConfig(&config) && config.has_preedit_method()) {
|
|
1815 |
+ preedit_method_ = config.preedit_method();
|
|
1816 |
+ }
|
|
1817 |
+ VLOG(1)
|
|
1818 |
+ << "Current preedit method is "
|
|
1819 |
+ << (preedit_method_ == mozc::config::Config::ROMAN ? "Roman" : "Kana");
|
|
1820 |
+}
|
|
1821 |
+
|
|
1822 |
+MozcConnection::~MozcConnection() {
|
|
1823 |
+ client_->SyncData();
|
|
1824 |
+ VLOG(1) << "MozcConnection is destroyed";
|
|
1825 |
+}
|
|
1826 |
+
|
|
1827 |
+bool MozcConnection::TrySendKeyEvent(
|
|
1828 |
+ FcitxKeySym sym, unsigned int state,
|
|
1829 |
+ mozc::commands::CompositionMode composition_mode,
|
|
1830 |
+ mozc::commands::Output *out,
|
|
1831 |
+ string *out_error) const {
|
|
1832 |
+ DCHECK(out);
|
|
1833 |
+ DCHECK(out_error);
|
|
1834 |
+
|
|
1835 |
+ // Call EnsureConnection just in case MozcConnection::MozcConnection() fails
|
|
1836 |
+ // to establish the server connection.
|
|
1837 |
+ if (!client_->EnsureConnection()) {
|
|
1838 |
+ *out_error = "EnsureConnection failed";
|
|
1839 |
+ VLOG(1) << "EnsureConnection failed";
|
|
1840 |
+ return false;
|
|
1841 |
+ }
|
|
1842 |
+
|
|
1843 |
+ mozc::commands::KeyEvent event;
|
|
1844 |
+ translator_->Translate(sym, state, preedit_method_, &event);
|
|
1845 |
+
|
|
1846 |
+ if ((composition_mode == mozc::commands::DIRECT) &&
|
|
1847 |
+ !mozc::config::ImeSwitchUtil::IsDirectModeCommand(event)) {
|
|
1848 |
+ VLOG(1) << "In DIRECT mode. Not consumed.";
|
|
1849 |
+ return false; // not consumed.
|
|
1850 |
+ }
|
|
1851 |
+
|
|
1852 |
+ VLOG(1) << "TrySendKeyEvent: " << endl << event.DebugString();
|
|
1853 |
+ if (!client_->SendKey(event, out)) {
|
|
1854 |
+ *out_error = "SendKey failed";
|
|
1855 |
+ VLOG(1) << "ERROR";
|
|
1856 |
+ return false;
|
|
1857 |
+ }
|
|
1858 |
+ VLOG(1) << "OK: " << endl << out->DebugString();
|
|
1859 |
+ return true;
|
|
1860 |
+}
|
|
1861 |
+
|
|
1862 |
+bool MozcConnection::TrySendClick(int32 unique_id,
|
|
1863 |
+ mozc::commands::Output *out,
|
|
1864 |
+ string *out_error) const {
|
|
1865 |
+ DCHECK(out);
|
|
1866 |
+ DCHECK(out_error);
|
|
1867 |
+
|
|
1868 |
+ mozc::commands::SessionCommand command;
|
|
1869 |
+ translator_->TranslateClick(unique_id, &command);
|
|
1870 |
+ return TrySendCommandInternal(command, out, out_error);
|
|
1871 |
+}
|
|
1872 |
+
|
|
1873 |
+bool MozcConnection::TrySendCompositionMode(
|
|
1874 |
+ mozc::commands::CompositionMode mode,
|
|
1875 |
+ mozc::commands::Output *out,
|
|
1876 |
+ string *out_error) const {
|
|
1877 |
+ DCHECK(out);
|
|
1878 |
+ DCHECK(out_error);
|
|
1879 |
+
|
|
1880 |
+ mozc::commands::SessionCommand command;
|
|
1881 |
+ command.set_type(mozc::commands::SessionCommand::SWITCH_INPUT_MODE);
|
|
1882 |
+ command.set_composition_mode(mode);
|
|
1883 |
+ return TrySendCommandInternal(command, out, out_error);
|
|
1884 |
+}
|
|
1885 |
+
|
|
1886 |
+bool MozcConnection::TrySendCommand(
|
|
1887 |
+ mozc::commands::SessionCommand::CommandType type,
|
|
1888 |
+ mozc::commands::Output *out,
|
|
1889 |
+ string *out_error) const {
|
|
1890 |
+ DCHECK(out);
|
|
1891 |
+ DCHECK(out_error);
|
|
1892 |
+
|
|
1893 |
+ mozc::commands::SessionCommand command;
|
|
1894 |
+ command.set_type(type);
|
|
1895 |
+ return TrySendCommandInternal(command, out, out_error);
|
|
1896 |
+}
|
|
1897 |
+
|
|
1898 |
+bool MozcConnection::TrySendCommandInternal(
|
|
1899 |
+ const mozc::commands::SessionCommand& command,
|
|
1900 |
+ mozc::commands::Output *out,
|
|
1901 |
+ string *out_error) const {
|
|
1902 |
+ VLOG(1) << "TrySendCommandInternal: " << endl << command.DebugString();
|
|
1903 |
+ if (!client_->SendCommand(command, out)) {
|
|
1904 |
+ *out_error = "SendCommand failed";
|
|
1905 |
+ VLOG(1) << "ERROR";
|
|
1906 |
+ return false;
|
|
1907 |
+ }
|
|
1908 |
+ VLOG(1) << "OK: " << endl << out->DebugString();
|
|
1909 |
+ return true;
|
|
1910 |
+}
|
|
1911 |
+
|
|
1912 |
+bool MozcConnection::CanSend(FcitxKeySym sym, unsigned int state) const {
|
|
1913 |
+ return translator_->CanConvert(sym, state);
|
|
1914 |
+}
|
|
1915 |
+
|
|
1916 |
+MozcConnection *MozcConnection::CreateMozcConnection() {
|
|
1917 |
+ mozc::client::ServerLauncher *server_launcher
|
|
1918 |
+ = new mozc::client::ServerLauncher;
|
|
1919 |
+
|
|
1920 |
+ return new MozcConnection(server_launcher, new mozc::IPCClientFactory);
|
|
1921 |
+}
|
|
1922 |
+
|
|
1923 |
+} // namespace fcitx
|
|
1924 |
+
|
|
1925 |
+} // namespace mozc
|
|
1926 |
diff --git a/unix/fcitx/mozc_connection.h b/unix/fcitx/mozc_connection.h
|
|
1927 |
new file mode 100755
|
|
1928 |
index 0000000..a005e11
|
|
1929 |
--- /dev/null
|
|
1930 |
+++ b/unix/fcitx/mozc_connection.h
|
|
1931 |
@@ -0,0 +1,136 @@
|
|
1932 |
+// Copyright 2010-2012, Google Inc.
|
|
1933 |
+// All rights reserved.
|
|
1934 |
+//
|
|
1935 |
+// Redistribution and use in source and binary forms, with or without
|
|
1936 |
+// modification, are permitted provided that the following conditions are
|
|
1937 |
+// met:
|
|
1938 |
+//
|
|
1939 |
+// * Redistributions of source code must retain the above copyright
|
|
1940 |
+// notice, this list of conditions and the following disclaimer.
|
|
1941 |
+// * Redistributions in binary form must reproduce the above
|
|
1942 |
+// copyright notice, this list of conditions and the following disclaimer
|
|
1943 |
+// in the documentation and/or other materials provided with the
|
|
1944 |
+// distribution.
|
|
1945 |
+// * Neither the name of Google Inc. nor the names of its
|
|
1946 |
+// contributors may be used to endorse or promote products derived from
|
|
1947 |
+// this software without specific prior written permission.
|
|
1948 |
+//
|
|
1949 |
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
1950 |
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
1951 |
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
1952 |
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
1953 |
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
1954 |
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
1955 |
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
1956 |
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
1957 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
1958 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
1959 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1960 |
+
|
|
1961 |
+#ifndef MOZC_UNIX_FCITX_MOZC_CONNECTION_H_
|
|
1962 |
+#define MOZC_UNIX_FCITX_MOZC_CONNECTION_H_
|
|
1963 |
+
|
|
1964 |
+#include <string>
|
|
1965 |
+#include <fcitx-config/hotkey.h>
|
|
1966 |
+
|
|
1967 |
+#include "base/base.h"
|
|
1968 |
+#include "session/commands.pb.h"
|
|
1969 |
+
|
|
1970 |
+namespace mozc {
|
|
1971 |
+
|
|
1972 |
+class IPCClientInterface;
|
|
1973 |
+class IPCClientFactoryInterface;
|
|
1974 |
+
|
|
1975 |
+namespace client {
|
|
1976 |
+class ClientInterface;
|
|
1977 |
+class ServerLauncherInterface;
|
|
1978 |
+} // namespace client
|
|
1979 |
+
|
|
1980 |
+} // namespace mozc
|
|
1981 |
+
|
|
1982 |
+namespace mozc {
|
|
1983 |
+
|
|
1984 |
+namespace fcitx {
|
|
1985 |
+
|
|
1986 |
+class KeyTranslator;
|
|
1987 |
+
|
|
1988 |
+// This class is for mozc_response_parser_test.cc.
|
|
1989 |
+class MozcConnectionInterface {
|
|
1990 |
+ public:
|
|
1991 |
+ virtual ~MozcConnectionInterface();
|
|
1992 |
+
|
|
1993 |
+ virtual bool TrySendKeyEvent(FcitxKeySym sym, unsigned int state,
|
|
1994 |
+ mozc::commands::CompositionMode composition_mode,
|
|
1995 |
+ mozc::commands::Output *out,
|
|
1996 |
+ string *out_error) const = 0;
|
|
1997 |
+ virtual bool TrySendClick(int32 unique_id,
|
|
1998 |
+ mozc::commands::Output *out,
|
|
1999 |
+ string *out_error) const = 0;
|
|
2000 |
+ virtual bool TrySendCompositionMode(mozc::commands::CompositionMode mode,
|
|
2001 |
+ mozc::commands::Output *out,
|
|
2002 |
+ string *out_error) const = 0;
|
|
2003 |
+ virtual bool TrySendCommand(mozc::commands::SessionCommand::CommandType type,
|
|
2004 |
+ mozc::commands::Output *out,
|
|
2005 |
+ string *out_error) const = 0;
|
|
2006 |
+ virtual bool CanSend(FcitxKeySym sym, unsigned int state) const = 0;
|
|
2007 |
+};
|
|
2008 |
+
|
|
2009 |
+class MozcConnection : public MozcConnectionInterface {
|
|
2010 |
+ public:
|
|
2011 |
+ static const int kNoSession;
|
|
2012 |
+
|
|
2013 |
+ static MozcConnection *CreateMozcConnection();
|
|
2014 |
+ virtual ~MozcConnection();
|
|
2015 |
+
|
|
2016 |
+ // Sends key event to the server. If the IPC succeeds, returns true and the
|
|
2017 |
+ // response is stored on 'out' (and 'out_error' is not modified). If the IPC
|
|
2018 |
+ // fails, returns false and the error message is stored on 'out_error'. In
|
|
2019 |
+ // this case, 'out' is not modified.
|
|
2020 |
+ virtual bool TrySendKeyEvent(FcitxKeySym sym, unsigned int state,
|
|
2021 |
+ mozc::commands::CompositionMode composition_mode,
|
|
2022 |
+ mozc::commands::Output *out,
|
|
2023 |
+ string *out_error) const;
|
|
2024 |
+
|
|
2025 |
+ // Sends 'mouse click on the candidate window' event to the server.
|
|
2026 |
+ virtual bool TrySendClick(int32 unique_id,
|
|
2027 |
+ mozc::commands::Output *out,
|
|
2028 |
+ string *out_error) const;
|
|
2029 |
+
|
|
2030 |
+ // Sends composition mode to the server.
|
|
2031 |
+ virtual bool TrySendCompositionMode(mozc::commands::CompositionMode mode,
|
|
2032 |
+ mozc::commands::Output *out,
|
|
2033 |
+ string *out_error) const;
|
|
2034 |
+
|
|
2035 |
+ // Sends a command to the server.
|
|
2036 |
+ virtual bool TrySendCommand(mozc::commands::SessionCommand::CommandType type,
|
|
2037 |
+ mozc::commands::Output *out,
|
|
2038 |
+ string *out_error) const;
|
|
2039 |
+
|
|
2040 |
+ // Returns true iff TrySendKeyEvent() accepts the key.
|
|
2041 |
+ virtual bool CanSend(FcitxKeySym sym, unsigned int state) const;
|
|
2042 |
+
|
|
2043 |
+ private:
|
|
2044 |
+ friend class MozcConnectionTest;
|
|
2045 |
+ MozcConnection(mozc::client::ServerLauncherInterface *server_launcher,
|
|
2046 |
+ mozc::IPCClientFactoryInterface *client_factory);
|
|
2047 |
+
|
|
2048 |
+ bool TrySendCommandInternal(
|
|
2049 |
+ const mozc::commands::SessionCommand& command,
|
|
2050 |
+ mozc::commands::Output *out,
|
|
2051 |
+ string *out_error) const;
|
|
2052 |
+
|
|
2053 |
+ const scoped_ptr<KeyTranslator> translator_;
|
|
2054 |
+ mozc::config::Config::PreeditMethod preedit_method_;
|
|
2055 |
+ // Keep definition order of client_factory_ and client_.
|
|
2056 |
+ // We should delete client_ before deleting client_factory_.
|
|
2057 |
+ scoped_ptr<mozc::IPCClientFactoryInterface> client_factory_;
|
|
2058 |
+ scoped_ptr<mozc::client::ClientInterface> client_;
|
|
2059 |
+
|
|
2060 |
+ DISALLOW_COPY_AND_ASSIGN(MozcConnection);
|
|
2061 |
+};
|
|
2062 |
+
|
|
2063 |
+} // namespace fcitx
|
|
2064 |
+
|
|
2065 |
+} // namespace mozc
|
|
2066 |
+
|
|
2067 |
+#endif // MOZC_UNIX_SCIM_MOZC_CONNECTION_H_
|
|
2068 |
diff --git a/unix/fcitx/mozc_response_parser.cc b/unix/fcitx/mozc_response_parser.cc
|
|
2069 |
new file mode 100755
|
|
2070 |
index 0000000..ff2e3e3
|
|
2071 |
--- /dev/null
|
|
2072 |
+++ b/unix/fcitx/mozc_response_parser.cc
|
|
2073 |
@@ -0,0 +1,281 @@
|
|
2074 |
+// Copyright 2010-2012, Google Inc.
|
|
2075 |
+// All rights reserved.
|
|
2076 |
+//
|
|
2077 |
+// Redistribution and use in source and binary forms, with or without
|
|
2078 |
+// modification, are permitted provided that the following conditions are
|
|
2079 |
+// met:
|
|
2080 |
+//
|
|
2081 |
+// * Redistributions of source code must retain the above copyright
|
|
2082 |
+// notice, this list of conditions and the following disclaimer.
|
|
2083 |
+// * Redistributions in binary form must reproduce the above
|
|
2084 |
+// copyright notice, this list of conditions and the following disclaimer
|
|
2085 |
+// in the documentation and/or other materials provided with the
|
|
2086 |
+// distribution.
|
|
2087 |
+// * Neither the name of Google Inc. nor the names of its
|
|
2088 |
+// contributors may be used to endorse or promote products derived from
|
|
2089 |
+// this software without specific prior written permission.
|
|
2090 |
+//
|
|
2091 |
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
2092 |
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
2093 |
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
2094 |
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
2095 |
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
2096 |
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
2097 |
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
2098 |
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
2099 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
2100 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2101 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2102 |
+
|
|
2103 |
+#include "unix/fcitx/mozc_response_parser.h"
|
|
2104 |
+
|
|
2105 |
+#include <string>
|
|
2106 |
+#include <vector>
|
|
2107 |
+
|
|
2108 |
+#include "base/logging.h"
|
|
2109 |
+#include "session/commands.pb.h"
|
|
2110 |
+#include "unix/fcitx/fcitx_mozc.h"
|
|
2111 |
+#include <fcitx/candidate.h>
|
|
2112 |
+
|
|
2113 |
+namespace {
|
|
2114 |
+
|
|
2115 |
+// Returns true if the candidate window contains only suggestions.
|
|
2116 |
+bool IsSuggestion(const mozc::commands::Candidates &candidates) {
|
|
2117 |
+ return !candidates.has_focused_index();
|
|
2118 |
+}
|
|
2119 |
+
|
|
2120 |
+// Returns a position that determines a preedit cursor position _AND_ top-left
|
|
2121 |
+// position of a candidate window. Note that we can't set these two positions
|
|
2122 |
+// independently. That's a SCIM's limitation.
|
|
2123 |
+uint32 GetCursorPosition(const mozc::commands::Output &response) {
|
|
2124 |
+ if (!response.has_preedit()) {
|
|
2125 |
+ return 0;
|
|
2126 |
+ }
|
|
2127 |
+ if (response.preedit().has_highlighted_position()) {
|
|
2128 |
+ return response.preedit().highlighted_position();
|
|
2129 |
+ }
|
|
2130 |
+ return response.preedit().cursor();
|
|
2131 |
+}
|
|
2132 |
+
|
|
2133 |
+string CreateDescriptionString(const string &description) {
|
|
2134 |
+ return " [" + description + "]";
|
|
2135 |
+}
|
|
2136 |
+
|
|
2137 |
+} // namespace
|
|
2138 |
+
|
|
2139 |
+namespace mozc {
|
|
2140 |
+
|
|
2141 |
+namespace fcitx {
|
|
2142 |
+
|
|
2143 |
+MozcResponseParser::MozcResponseParser()
|
|
2144 |
+ : use_annotation_(false) {
|
|
2145 |
+}
|
|
2146 |
+
|
|
2147 |
+MozcResponseParser::~MozcResponseParser() {
|
|
2148 |
+}
|
|
2149 |
+
|
|
2150 |
+bool MozcResponseParser::ParseResponse(const mozc::commands::Output &response,
|
|
2151 |
+ FcitxMozc *fcitx_mozc) const {
|
|
2152 |
+ DCHECK(fcitx_mozc);
|
|
2153 |
+ if (!fcitx_mozc) {
|
|
2154 |
+ return false;
|
|
2155 |
+ }
|
|
2156 |
+
|
|
2157 |
+ // We should check the mode field first since the response for a
|
|
2158 |
+ // SWITCH_INPUT_MODE request only contains mode and id fields.
|
|
2159 |
+ if (response.has_mode()) {
|
|
2160 |
+ fcitx_mozc->SetCompositionMode(response.mode());
|
|
2161 |
+ }
|
|
2162 |
+
|
|
2163 |
+ if (!response.consumed()) {
|
|
2164 |
+ // The key was not consumed by Mozc.
|
|
2165 |
+ return false;
|
|
2166 |
+ }
|
|
2167 |
+
|
|
2168 |
+ if (response.has_result()) {
|
|
2169 |
+ const mozc::commands::Result &result = response.result();
|
|
2170 |
+ ParseResult(result, fcitx_mozc);
|
|
2171 |
+ }
|
|
2172 |
+
|
|
2173 |
+ // First, determine the cursor position.
|
|
2174 |
+ if (response.has_preedit()) {
|
|
2175 |
+ const mozc::commands::Preedit &preedit = response.preedit();
|
|
2176 |
+ ParsePreedit(preedit, GetCursorPosition(response), fcitx_mozc);
|
|
2177 |
+ }
|
|
2178 |
+
|
|
2179 |
+ // Then show the candidate window.
|
|
2180 |
+ if (response.has_candidates()) {
|
|
2181 |
+ const mozc::commands::Candidates &candidates = response.candidates();
|
|
2182 |
+ ParseCandidates(candidates, fcitx_mozc);
|
|
2183 |
+ }
|
|
2184 |
+
|
|
2185 |
+ if (response.has_url()) {
|
|
2186 |
+ const string &url = response.url();
|
|
2187 |
+ fcitx_mozc->SetUrl(url);
|
|
2188 |
+ }
|
|
2189 |
+
|
|
2190 |
+ return true; // mozc consumed the key.
|
|
2191 |
+}
|
|
2192 |
+
|
|
2193 |
+void MozcResponseParser::set_use_annotation(bool use_annotation) {
|
|
2194 |
+ use_annotation_ = use_annotation;
|
|
2195 |
+}
|
|
2196 |
+
|
|
2197 |
+void MozcResponseParser::ParseResult(const mozc::commands::Result &result,
|
|
2198 |
+ FcitxMozc *fcitx_mozc) const {
|
|
2199 |
+ switch (result.type()) {
|
|
2200 |
+ case mozc::commands::Result::NONE: {
|
|
2201 |
+ fcitx_mozc->SetAuxString("No result"); // not a fatal error.
|
|
2202 |
+ break;
|
|
2203 |
+ }
|
|
2204 |
+ case mozc::commands::Result::STRING: {
|
|
2205 |
+ fcitx_mozc->SetResultString(result.value());
|
|
2206 |
+ break;
|
|
2207 |
+ }
|
|
2208 |
+ }
|
|
2209 |
+}
|
|
2210 |
+
|
|
2211 |
+void MozcResponseParser::ParseCandidates(
|
|
2212 |
+ const mozc::commands::Candidates &candidates, FcitxMozc *fcitx_mozc) const {
|
|
2213 |
+ const commands::Footer &footer = candidates.footer();
|
|
2214 |
+ if (candidates.has_footer()) {
|
|
2215 |
+ string auxString;
|
|
2216 |
+ if (footer.has_label()) {
|
|
2217 |
+ // TODO(yusukes,mozc-team): label() is not localized. Currently, it's always
|
|
2218 |
+ // written in Japanese (in UTF-8).
|
|
2219 |
+ auxString += footer.label();
|
|
2220 |
+ } else if (footer.has_sub_label()) {
|
|
2221 |
+ // Windows client shows sub_label() only when label() is not specified. We
|
|
2222 |
+ // follow the policy.
|
|
2223 |
+ auxString += footer.sub_label();
|
|
2224 |
+ }
|
|
2225 |
+
|
|
2226 |
+ if (footer.has_index_visible() && footer.index_visible()) {
|
|
2227 |
+ // Max size of candidates is 200 so 128 is sufficient size for the buffer.
|
|
2228 |
+ char index_buf[128] = {0};
|
|
2229 |
+ const int result = snprintf(index_buf,
|
|
2230 |
+ sizeof(index_buf) - 1,
|
|
2231 |
+ "%s%d/%d",
|
|
2232 |
+ (auxString.empty() ? "" : " "),
|
|
2233 |
+ candidates.focused_index() + 1,
|
|
2234 |
+ candidates.size());
|
|
2235 |
+ DCHECK_GE(result, 0) << "snprintf in ComposeAuxiliaryText failed";
|
|
2236 |
+ auxString += index_buf;
|
|
2237 |
+ }
|
|
2238 |
+ fcitx_mozc->SetAuxString(auxString);
|
|
2239 |
+ }
|
|
2240 |
+
|
|
2241 |
+ FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(fcitx_mozc->GetInputState());
|
|
2242 |
+ FcitxCandidateWordReset(candList);
|
|
2243 |
+ FcitxCandidateWordSetPageSize(candList, 9);
|
|
2244 |
+ char strChoose[] = "\0\0\0\0\0\0\0\0\0\0\0";
|
|
2245 |
+
|
|
2246 |
+ int focused_index = -1;
|
|
2247 |
+ int local_index = -1;
|
|
2248 |
+ if (candidates.has_focused_index()) {
|
|
2249 |
+ focused_index = candidates.focused_index();
|
|
2250 |
+ }
|
|
2251 |
+ for (int i = 0; i < candidates.candidate_size(); ++i) {
|
|
2252 |
+ const uint32 index = candidates.candidate(i).index();
|
|
2253 |
+ if (focused_index != -1 && index == focused_index) {
|
|
2254 |
+ local_index = i;
|
|
2255 |
+ }
|
|
2256 |
+ int32* id = (int32*) fcitx_utils_malloc0(sizeof(int32));
|
|
2257 |
+ FcitxCandidateWord candWord;
|
|
2258 |
+ candWord.callback = FcitxMozcGetCandidateWord;
|
|
2259 |
+ candWord.extraType = MSG_INPUT;
|
|
2260 |
+ candWord.strExtra = NULL;
|
|
2261 |
+ candWord.priv = id;
|
|
2262 |
+ candWord.strWord = NULL;
|
|
2263 |
+ candWord.wordType = MSG_INPUT;
|
|
2264 |
+ candWord.owner = fcitx_mozc;
|
|
2265 |
+
|
|
2266 |
+ string value;
|
|
2267 |
+ if (use_annotation_ &&
|
|
2268 |
+ candidates.candidate(i).has_annotation() &&
|
|
2269 |
+ candidates.candidate(i).annotation().has_prefix()) {
|
|
2270 |
+ value = candidates.candidate(i).annotation().prefix();
|
|
2271 |
+ }
|
|
2272 |
+ value += candidates.candidate(i).value();
|
|
2273 |
+ if (use_annotation_ &&
|
|
2274 |
+ candidates.candidate(i).has_annotation() &&
|
|
2275 |
+ candidates.candidate(i).annotation().has_suffix()) {
|
|
2276 |
+ value += candidates.candidate(i).annotation().suffix();
|
|
2277 |
+ }
|
|
2278 |
+ if (use_annotation_ &&
|
|
2279 |
+ candidates.candidate(i).has_annotation() &&
|
|
2280 |
+ candidates.candidate(i).annotation().has_description()) {
|
|
2281 |
+ // Display descriptions ([HALF][KATAKANA], [GREEK], [Black square], etc).
|
|
2282 |
+ value += CreateDescriptionString(
|
|
2283 |
+ candidates.candidate(i).annotation().description());
|
|
2284 |
+ }
|
|
2285 |
+
|
|
2286 |
+ candWord.strWord = strdup(value.c_str());
|
|
2287 |
+
|
|
2288 |
+ if (candidates.candidate(i).has_id()) {
|
|
2289 |
+ const int32 cid = candidates.candidate(i).id();
|
|
2290 |
+ DCHECK_NE(kBadCandidateId, cid) << "Unexpected id is passed.";
|
|
2291 |
+ *id = cid;
|
|
2292 |
+ } else {
|
|
2293 |
+ // The parent node of the cascading window does not have an id since the
|
|
2294 |
+ // node does not contain a candidate word.
|
|
2295 |
+ *id = kBadCandidateId;
|
|
2296 |
+ }
|
|
2297 |
+ FcitxCandidateWordAppend(candList, &candWord);
|
|
2298 |
+ }
|
|
2299 |
+
|
|
2300 |
+ if (footer.has_index_visible() && footer.index_visible())
|
|
2301 |
+ FcitxCandidateWordSetChoose(candList, DIGIT_STR_CHOOSE);
|
|
2302 |
+ else
|
|
2303 |
+ FcitxCandidateWordSetChoose(candList, strChoose);
|
|
2304 |
+ FcitxCandidateWordSetFocus(candList, local_index);
|
|
2305 |
+}
|
|
2306 |
+
|
|
2307 |
+static int GetRawCursorPos(const char * str, int upos)
|
|
2308 |
+{
|
|
2309 |
+ unsigned int i;
|
|
2310 |
+ int pos = 0;
|
|
2311 |
+ for (i = 0; i < upos; i++) {
|
|
2312 |
+ pos += fcitx_utf8_char_len(fcitx_utf8_get_nth_char((char*)str, i));
|
|
2313 |
+ }
|
|
2314 |
+ return pos;
|
|
2315 |
+}
|
|
2316 |
+
|
|
2317 |
+
|
|
2318 |
+void MozcResponseParser::ParsePreedit(const mozc::commands::Preedit &preedit,
|
|
2319 |
+ uint32 position,
|
|
2320 |
+ FcitxMozc *fcitx_mozc) const {
|
|
2321 |
+ PreeditInfo *info = new PreeditInfo;
|
|
2322 |
+ std::string s;
|
|
2323 |
+
|
|
2324 |
+ for (int i = 0; i < preedit.segment_size(); ++i) {
|
|
2325 |
+ const mozc::commands::Preedit_Segment &segment = preedit.segment(i);
|
|
2326 |
+ const std::string &str = segment.value();
|
|
2327 |
+ FcitxMessageType type = MSG_INPUT;
|
|
2328 |
+
|
|
2329 |
+ switch (segment.annotation()) {
|
|
2330 |
+ case mozc::commands::Preedit_Segment::NONE:
|
|
2331 |
+ type = (FcitxMessageType) (MSG_INPUT | MSG_NOUNDERLINE);
|
|
2332 |
+ break;
|
|
2333 |
+ case mozc::commands::Preedit_Segment::UNDERLINE:
|
|
2334 |
+ type = (FcitxMessageType) (MSG_TIPS);
|
|
2335 |
+ break;
|
|
2336 |
+ case mozc::commands::Preedit_Segment::HIGHLIGHT:
|
|
2337 |
+ type = (FcitxMessageType) (MSG_CODE | MSG_NOUNDERLINE | MSG_HIGHLIGHT);
|
|
2338 |
+ break;
|
|
2339 |
+ }
|
|
2340 |
+ s += str;
|
|
2341 |
+
|
|
2342 |
+ PreeditItem item;
|
|
2343 |
+ item.type = type;
|
|
2344 |
+ item.str = str;
|
|
2345 |
+ info->preedit.push_back(item);
|
|
2346 |
+ }
|
|
2347 |
+ info->cursor_pos = GetRawCursorPos(s.c_str(), position);
|
|
2348 |
+
|
|
2349 |
+ fcitx_mozc->SetPreeditInfo(info);
|
|
2350 |
+}
|
|
2351 |
+
|
|
2352 |
+} // namespace fcitx
|
|
2353 |
+
|
|
2354 |
+} // namespace mozc
|
|
2355 |
diff --git a/unix/fcitx/mozc_response_parser.h b/unix/fcitx/mozc_response_parser.h
|
|
2356 |
new file mode 100755
|
|
2357 |
index 0000000..f924816
|
|
2358 |
--- /dev/null
|
|
2359 |
+++ b/unix/fcitx/mozc_response_parser.h
|
|
2360 |
@@ -0,0 +1,93 @@
|
|
2361 |
+// Copyright 2010-2012, Google Inc.
|
|
2362 |
+// All rights reserved.
|
|
2363 |
+//
|
|
2364 |
+// Redistribution and use in source and binary forms, with or without
|
|
2365 |
+// modification, are permitted provided that the following conditions are
|
|
2366 |
+// met:
|
|
2367 |
+//
|
|
2368 |
+// * Redistributions of source code must retain the above copyright
|
|
2369 |
+// notice, this list of conditions and the following disclaimer.
|
|
2370 |
+// * Redistributions in binary form must reproduce the above
|
|
2371 |
+// copyright notice, this list of conditions and the following disclaimer
|
|
2372 |
+// in the documentation and/or other materials provided with the
|
|
2373 |
+// distribution.
|
|
2374 |
+// * Neither the name of Google Inc. nor the names of its
|
|
2375 |
+// contributors may be used to endorse or promote products derived from
|
|
2376 |
+// this software without specific prior written permission.
|
|
2377 |
+//
|
|
2378 |
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
2379 |
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
2380 |
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
2381 |
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
2382 |
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
2383 |
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
2384 |
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
2385 |
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
2386 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
2387 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2388 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2389 |
+
|
|
2390 |
+#ifndef MOZC_UNIX_FCITX_MOZC_RESPONSE_PARSER_H_
|
|
2391 |
+#define MOZC_UNIX_FCITX_MOZC_RESPONSE_PARSER_H_
|
|
2392 |
+
|
|
2393 |
+#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
|
|
2394 |
+
|
|
2395 |
+namespace mozc
|
|
2396 |
+{
|
|
2397 |
+namespace commands
|
|
2398 |
+{
|
|
2399 |
+
|
|
2400 |
+class Candidates;
|
|
2401 |
+class Input;
|
|
2402 |
+class Output;
|
|
2403 |
+class Preedit;
|
|
2404 |
+class Result;
|
|
2405 |
+
|
|
2406 |
+} // namespace commands
|
|
2407 |
+} // namespace mozc
|
|
2408 |
+
|
|
2409 |
+namespace mozc
|
|
2410 |
+{
|
|
2411 |
+
|
|
2412 |
+namespace fcitx
|
|
2413 |
+{
|
|
2414 |
+
|
|
2415 |
+class FcitxMozc;
|
|
2416 |
+
|
|
2417 |
+// This class parses IPC response from mozc_server (mozc::commands::Output) and
|
|
2418 |
+// updates the FCITX UI.
|
|
2419 |
+class MozcResponseParser
|
|
2420 |
+{
|
|
2421 |
+public:
|
|
2422 |
+ MozcResponseParser();
|
|
2423 |
+ ~MozcResponseParser();
|
|
2424 |
+
|
|
2425 |
+ // Parses a response from Mozc server and sets persed information on fcitx_mozc
|
|
2426 |
+ // object. Returns true if response.consumed() is true. fcitx_mozc must be non
|
|
2427 |
+ // NULL. This function does not take ownership of fcitx_mozc.
|
|
2428 |
+ bool ParseResponse ( const mozc::commands::Output &response,
|
|
2429 |
+ FcitxMozc *fcitx_mozc ) const;
|
|
2430 |
+
|
|
2431 |
+ // Setter for use_annotation_. If use_annotation_ is true, ParseCandidates()
|
|
2432 |
+ // uses annotation infomation.
|
|
2433 |
+ void set_use_annotation ( bool use_annotation );
|
|
2434 |
+
|
|
2435 |
+private:
|
|
2436 |
+ void ParseResult ( const mozc::commands::Result &result,
|
|
2437 |
+ FcitxMozc *fcitx_mozc ) const;
|
|
2438 |
+ void ParseCandidates ( const mozc::commands::Candidates &candidates,
|
|
2439 |
+ FcitxMozc *fcitx_mozc ) const;
|
|
2440 |
+ void ParsePreedit ( const mozc::commands::Preedit &preedit,
|
|
2441 |
+ uint32 position,
|
|
2442 |
+ FcitxMozc *fcitx_mozc ) const;
|
|
2443 |
+
|
|
2444 |
+ bool use_annotation_;
|
|
2445 |
+
|
|
2446 |
+ DISALLOW_COPY_AND_ASSIGN ( MozcResponseParser );
|
|
2447 |
+};
|
|
2448 |
+
|
|
2449 |
+} // namespace fcitx
|
|
2450 |
+
|
|
2451 |
+} // namespace mozc
|
|
2452 |
+
|
|
2453 |
+#endif // MOZC_UNIX_FCITX_MOZC_RESPONSE_PARSER_H_
|
|
2454 |
diff --git a/unix/fcitx/po/Messages.sh b/unix/fcitx/po/Messages.sh
|
|
2455 |
new file mode 100755
|
|
2456 |
index 0000000..be34171
|
|
2457 |
--- /dev/null
|
|
2458 |
+++ b/unix/fcitx/po/Messages.sh
|
|
2459 |
@@ -0,0 +1,33 @@
|
|
2460 |
+#!/bin/sh
|
|
2461 |
+
|
|
2462 |
+BASEDIR="../" # root of translatable sources
|
|
2463 |
+PROJECT="fcitx-mozc" # project name
|
|
2464 |
+BUGADDR="fcitx-dev@googlegroups.com" # MSGID-Bugs
|
|
2465 |
+WDIR="`pwd`" # working dir
|
|
2466 |
+
|
|
2467 |
+echo "Preparing rc files"
|
|
2468 |
+
|
|
2469 |
+echo "Done preparing rc files"
|
|
2470 |
+echo "Extracting messages"
|
|
2471 |
+
|
|
2472 |
+# see above on sorting
|
|
2473 |
+
|
|
2474 |
+find "${BASEDIR}" -name '*.cc' -o -name '*.h' -o -name '*.c' | sort > "${WDIR}/infiles.list"
|
|
2475 |
+
|
|
2476 |
+xgettext --from-code=UTF-8 -k_ -kN_ --msgid-bugs-address="${BUGADDR}" --files-from=infiles.list \
|
|
2477 |
+ -D "${BASEDIR}" -D "${WDIR}" -o "${PROJECT}.pot" || \
|
|
2478 |
+ { echo "error while calling xgettext. aborting."; exit 1; }
|
|
2479 |
+echo "Done extracting messages"
|
|
2480 |
+
|
|
2481 |
+echo "Merging translations"
|
|
2482 |
+catalogs=`find . -name '*.po'`
|
|
2483 |
+for cat in $catalogs; do
|
|
2484 |
+ echo "$cat"
|
|
2485 |
+ msgmerge -o "$cat.new" "$cat" "${WDIR}/${PROJECT}.pot"
|
|
2486 |
+ mv "$cat.new" "$cat"
|
|
2487 |
+done
|
|
2488 |
+
|
|
2489 |
+echo "Done merging translations"
|
|
2490 |
+echo "Cleaning up"
|
|
2491 |
+rm "${WDIR}/infiles.list"
|
|
2492 |
+echo "Done"
|
|
2493 |
diff --git a/unix/fcitx/po/fcitx-mozc.pot b/unix/fcitx/po/fcitx-mozc.pot
|
|
2494 |
new file mode 100644
|
|
2495 |
index 0000000..7306c82
|
|
2496 |
--- /dev/null
|
|
2497 |
+++ b/unix/fcitx/po/fcitx-mozc.pot
|
|
2498 |
@@ -0,0 +1,78 @@
|
|
2499 |
+# SOME DESCRIPTIVE TITLE.
|
|
2500 |
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
2501 |
+# This file is distributed under the same license as the PACKAGE package.
|
|
2502 |
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
2503 |
+#
|
|
2504 |
+#, fuzzy
|
|
2505 |
+msgid ""
|
|
2506 |
+msgstr ""
|
|
2507 |
+"Project-Id-Version: PACKAGE VERSION\n"
|
|
2508 |
+"Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n"
|
|
2509 |
+"POT-Creation-Date: 2012-04-07 11:37+0800\n"
|
|
2510 |
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
2511 |
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
2512 |
+"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
2513 |
+"Language: \n"
|
|
2514 |
+"MIME-Version: 1.0\n"
|
|
2515 |
+"Content-Type: text/plain; charset=CHARSET\n"
|
|
2516 |
+"Content-Transfer-Encoding: 8bit\n"
|
|
2517 |
+
|
|
2518 |
+#: ../fcitx_mozc.cc:53
|
|
2519 |
+msgid "Direct"
|
|
2520 |
+msgstr ""
|
|
2521 |
+
|
|
2522 |
+#: ../fcitx_mozc.cc:58
|
|
2523 |
+msgid "Hiragana"
|
|
2524 |
+msgstr ""
|
|
2525 |
+
|
|
2526 |
+#: ../fcitx_mozc.cc:63
|
|
2527 |
+msgid "Full Katakana"
|
|
2528 |
+msgstr ""
|
|
2529 |
+
|
|
2530 |
+#: ../fcitx_mozc.cc:68
|
|
2531 |
+msgid "Half ASCII"
|
|
2532 |
+msgstr ""
|
|
2533 |
+
|
|
2534 |
+#: ../fcitx_mozc.cc:73
|
|
2535 |
+msgid "Full ASCII"
|
|
2536 |
+msgstr ""
|
|
2537 |
+
|
|
2538 |
+#: ../fcitx_mozc.cc:78
|
|
2539 |
+msgid "Half Katakana"
|
|
2540 |
+msgstr ""
|
|
2541 |
+
|
|
2542 |
+#: ../fcitx_mozc.cc:379 ../fcitx_mozc.cc:380 ../fcitx_mozc.cc:458
|
|
2543 |
+msgid "Composition Mode"
|
|
2544 |
+msgstr ""
|
|
2545 |
+
|
|
2546 |
+#: ../fcitx_mozc.cc:390 ../fcitx_mozc.cc:391
|
|
2547 |
+msgid "Tool"
|
|
2548 |
+msgstr ""
|
|
2549 |
+
|
|
2550 |
+#: ../fcitx_mozc.cc:471
|
|
2551 |
+msgid "Mozc Tool"
|
|
2552 |
+msgstr ""
|
|
2553 |
+
|
|
2554 |
+#: ../fcitx_mozc.cc:477
|
|
2555 |
+msgid "Configuration Tool"
|
|
2556 |
+msgstr ""
|
|
2557 |
+
|
|
2558 |
+#: ../fcitx_mozc.cc:478
|
|
2559 |
+msgid "Dictionary Tool"
|
|
2560 |
+msgstr ""
|
|
2561 |
+
|
|
2562 |
+#: ../fcitx_mozc.cc:479
|
|
2563 |
+msgid "Hand Writing"
|
|
2564 |
+msgstr ""
|
|
2565 |
+
|
|
2566 |
+#: ../fcitx_mozc.cc:480
|
|
2567 |
+msgid "Character Palette"
|
|
2568 |
+msgstr ""
|
|
2569 |
+
|
|
2570 |
+#: ../fcitx_mozc.cc:481
|
|
2571 |
+msgid "Add Word"
|
|
2572 |
+msgstr ""
|
|
2573 |
+
|
|
2574 |
+#: ../fcitx_mozc.cc:482
|
|
2575 |
+msgid "About Mozc"
|
|
2576 |
+msgstr ""
|
|
2577 |
diff --git a/unix/fcitx/po/ja.po b/unix/fcitx/po/ja.po
|
|
2578 |
new file mode 100644
|
|
2579 |
index 0000000..0f1798c
|
|
2580 |
--- /dev/null
|
|
2581 |
+++ b/unix/fcitx/po/ja.po
|
|
2582 |
@@ -0,0 +1,81 @@
|
|
2583 |
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
2584 |
+# This file is distributed under the same license as the PACKAGE package.
|
|
2585 |
+#
|
|
2586 |
+# Translators:
|
|
2587 |
+# <wengxt@gmail.com>, 2012.
|
|
2588 |
+msgid ""
|
|
2589 |
+msgstr ""
|
|
2590 |
+"Project-Id-Version: fcitx\n"
|
|
2591 |
+"Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n"
|
|
2592 |
+"POT-Creation-Date: 2012-04-07 11:37+0800\n"
|
|
2593 |
+"PO-Revision-Date: 2012-04-07 11:45+0800\n"
|
|
2594 |
+"Last-Translator: Weng Xuetian <wengxt@gmail.com>\n"
|
|
2595 |
+"Language-Team: Chinese Traditional <fcitx-dev@googlegroups.com>\n"
|
|
2596 |
+"language/ja_JP/)\n"
|
|
2597 |
+"Language: ja_JP\n"
|
|
2598 |
+"MIME-Version: 1.0\n"
|
|
2599 |
+"Content-Type: text/plain; charset=UTF-8\n"
|
|
2600 |
+"Content-Transfer-Encoding: 8bit\n"
|
|
2601 |
+"Plural-Forms: nplurals=1; plural=0\n"
|
|
2602 |
+"X-Generator: Lokalize 1.4\n"
|
|
2603 |
+
|
|
2604 |
+#: ../fcitx_mozc.cc:53
|
|
2605 |
+msgid "Direct"
|
|
2606 |
+msgstr "直接入力"
|
|
2607 |
+
|
|
2608 |
+#: ../fcitx_mozc.cc:58
|
|
2609 |
+msgid "Hiragana"
|
|
2610 |
+msgstr "ひらがな"
|
|
2611 |
+
|
|
2612 |
+#: ../fcitx_mozc.cc:63
|
|
2613 |
+msgid "Full Katakana"
|
|
2614 |
+msgstr "全角カタカナ"
|
|
2615 |
+
|
|
2616 |
+#: ../fcitx_mozc.cc:68
|
|
2617 |
+msgid "Half ASCII"
|
|
2618 |
+msgstr "半角英数"
|
|
2619 |
+
|
|
2620 |
+#: ../fcitx_mozc.cc:73
|
|
2621 |
+msgid "Full ASCII"
|
|
2622 |
+msgstr "全角英数"
|
|
2623 |
+
|
|
2624 |
+#: ../fcitx_mozc.cc:78
|
|
2625 |
+msgid "Half Katakana"
|
|
2626 |
+msgstr "半角カタカナ"
|
|
2627 |
+
|
|
2628 |
+#: ../fcitx_mozc.cc:379 ../fcitx_mozc.cc:380 ../fcitx_mozc.cc:458
|
|
2629 |
+msgid "Composition Mode"
|
|
2630 |
+msgstr "変換モード"
|
|
2631 |
+
|
|
2632 |
+#: ../fcitx_mozc.cc:390 ../fcitx_mozc.cc:391
|
|
2633 |
+msgid "Tool"
|
|
2634 |
+msgstr "ツールを"
|
|
2635 |
+
|
|
2636 |
+#: ../fcitx_mozc.cc:471
|
|
2637 |
+msgid "Mozc Tool"
|
|
2638 |
+msgstr "Mozc ツールを"
|
|
2639 |
+
|
|
2640 |
+#: ../fcitx_mozc.cc:477
|
|
2641 |
+msgid "Configuration Tool"
|
|
2642 |
+msgstr "設定ツールを"
|
|
2643 |
+
|
|
2644 |
+#: ../fcitx_mozc.cc:478
|
|
2645 |
+msgid "Dictionary Tool"
|
|
2646 |
+msgstr "辞書ツールを"
|
|
2647 |
+
|
|
2648 |
+#: ../fcitx_mozc.cc:479
|
|
2649 |
+msgid "Hand Writing"
|
|
2650 |
+msgstr "手書き文字認識"
|
|
2651 |
+
|
|
2652 |
+#: ../fcitx_mozc.cc:480
|
|
2653 |
+msgid "Character Palette"
|
|
2654 |
+msgstr "文字パレット"
|
|
2655 |
+
|
|
2656 |
+#: ../fcitx_mozc.cc:481
|
|
2657 |
+msgid "Add Word"
|
|
2658 |
+msgstr "単語登録"
|
|
2659 |
+
|
|
2660 |
+#: ../fcitx_mozc.cc:482
|
|
2661 |
+msgid "About Mozc"
|
|
2662 |
+msgstr "Mozc について"
|
|
2663 |
+
|
|
2664 |
diff --git a/unix/fcitx/po/zh_CN.po b/unix/fcitx/po/zh_CN.po
|
|
2665 |
new file mode 100644
|
|
2666 |
index 0000000..47612f6
|
|
2667 |
--- /dev/null
|
|
2668 |
+++ b/unix/fcitx/po/zh_CN.po
|
|
2669 |
@@ -0,0 +1,79 @@
|
|
2670 |
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
2671 |
+# This file is distributed under the same license as the PACKAGE package.
|
|
2672 |
+#
|
|
2673 |
+# Weng Xuetian <wengxt@gmail.com>, 2012.
|
|
2674 |
+msgid ""
|
|
2675 |
+msgstr ""
|
|
2676 |
+"Project-Id-Version: \n"
|
|
2677 |
+"Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n"
|
|
2678 |
+"POT-Creation-Date: 2012-04-07 11:37+0800\n"
|
|
2679 |
+"PO-Revision-Date: 2012-04-07 11:39+0800\n"
|
|
2680 |
+"Last-Translator: Weng Xuetian <wengxt@gmail.com>\n"
|
|
2681 |
+"Language-Team: Chinese Simplified <fcitx-dev@googlegroups.com>\n"
|
|
2682 |
+"Language: zh_CN\n"
|
|
2683 |
+"MIME-Version: 1.0\n"
|
|
2684 |
+"Content-Type: text/plain; charset=UTF-8\n"
|
|
2685 |
+"Content-Transfer-Encoding: 8bit\n"
|
|
2686 |
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
|
2687 |
+"X-Generator: Lokalize 1.4\n"
|
|
2688 |
+
|
|
2689 |
+#: ../fcitx_mozc.cc:53
|
|
2690 |
+msgid "Direct"
|
|
2691 |
+msgstr "直接键盘输入"
|
|
2692 |
+
|
|
2693 |
+#: ../fcitx_mozc.cc:58
|
|
2694 |
+msgid "Hiragana"
|
|
2695 |
+msgstr "平假名"
|
|
2696 |
+
|
|
2697 |
+#: ../fcitx_mozc.cc:63
|
|
2698 |
+msgid "Full Katakana"
|
|
2699 |
+msgstr "全角片假名"
|
|
2700 |
+
|
|
2701 |
+#: ../fcitx_mozc.cc:68
|
|
2702 |
+msgid "Half ASCII"
|
|
2703 |
+msgstr "半角 ASCII"
|
|
2704 |
+
|
|
2705 |
+#: ../fcitx_mozc.cc:73
|
|
2706 |
+msgid "Full ASCII"
|
|
2707 |
+msgstr "全角 ASCII"
|
|
2708 |
+
|
|
2709 |
+#: ../fcitx_mozc.cc:78
|
|
2710 |
+msgid "Half Katakana"
|
|
2711 |
+msgstr "半角片假名"
|
|
2712 |
+
|
|
2713 |
+#: ../fcitx_mozc.cc:379 ../fcitx_mozc.cc:380 ../fcitx_mozc.cc:458
|
|
2714 |
+msgid "Composition Mode"
|
|
2715 |
+msgstr "编辑模式"
|
|
2716 |
+
|
|
2717 |
+#: ../fcitx_mozc.cc:390 ../fcitx_mozc.cc:391
|
|
2718 |
+msgid "Tool"
|
|
2719 |
+msgstr "工具"
|
|
2720 |
+
|
|
2721 |
+#: ../fcitx_mozc.cc:471
|
|
2722 |
+msgid "Mozc Tool"
|
|
2723 |
+msgstr "Mozc 工具"
|
|
2724 |
+
|
|
2725 |
+#: ../fcitx_mozc.cc:477
|
|
2726 |
+msgid "Configuration Tool"
|
|
2727 |
+msgstr "配置工具"
|
|
2728 |
+
|
|
2729 |
+#: ../fcitx_mozc.cc:478
|
|
2730 |
+msgid "Dictionary Tool"
|
|
2731 |
+msgstr "词典工具"
|
|
2732 |
+
|
|
2733 |
+#: ../fcitx_mozc.cc:479
|
|
2734 |
+msgid "Hand Writing"
|
|
2735 |
+msgstr "手写输入"
|
|
2736 |
+
|
|
2737 |
+#: ../fcitx_mozc.cc:480
|
|
2738 |
+msgid "Character Palette"
|
|
2739 |
+msgstr "字符映射表"
|
|
2740 |
+
|
|
2741 |
+#: ../fcitx_mozc.cc:481
|
|
2742 |
+msgid "Add Word"
|
|
2743 |
+msgstr "添加单词"
|
|
2744 |
+
|
|
2745 |
+#: ../fcitx_mozc.cc:482
|
|
2746 |
+msgid "About Mozc"
|
|
2747 |
+msgstr "关于 Mozc"
|
|
2748 |
+
|
|
2749 |
diff --git a/unix/fcitx/po/zh_TW.po b/unix/fcitx/po/zh_TW.po
|
|
2750 |
new file mode 100644
|
|
2751 |
index 0000000..fc40fb3
|
|
2752 |
--- /dev/null
|
|
2753 |
+++ b/unix/fcitx/po/zh_TW.po
|
|
2754 |
@@ -0,0 +1,82 @@
|
|
2755 |
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
2756 |
+# This file is distributed under the same license as the PACKAGE package.
|
|
2757 |
+#
|
|
2758 |
+# Translators:
|
|
2759 |
+# Alisha <alisha.4m@gmail.com>, 2012.
|
|
2760 |
+# Weng Xuetian <wengxt@gmail.com>, 2012.
|
|
2761 |
+msgid ""
|
|
2762 |
+msgstr ""
|
|
2763 |
+"Project-Id-Version: fcitx\n"
|
|
2764 |
+"Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n"
|
|
2765 |
+"POT-Creation-Date: 2012-04-07 11:37+0800\n"
|
|
2766 |
+"PO-Revision-Date: 2012-04-07 11:46+0800\n"
|
|
2767 |
+"Last-Translator: Weng Xuetian <wengxt@gmail.com>\n"
|
|
2768 |
+"Language-Team: Chinese Traditional <fcitx-dev@googlegroups.com>\n"
|
|
2769 |
+"language/zh_TW/)\n"
|
|
2770 |
+"Language: zh_TW\n"
|
|
2771 |
+"MIME-Version: 1.0\n"
|
|
2772 |
+"Content-Type: text/plain; charset=UTF-8\n"
|
|
2773 |
+"Content-Transfer-Encoding: 8bit\n"
|
|
2774 |
+"Plural-Forms: nplurals=1; plural=0\n"
|
|
2775 |
+"X-Generator: Lokalize 1.4\n"
|
|
2776 |
+
|
|
2777 |
+#: ../fcitx_mozc.cc:53
|
|
2778 |
+msgid "Direct"
|
|
2779 |
+msgstr "直接鍵盤輸入"
|
|
2780 |
+
|
|
2781 |
+#: ../fcitx_mozc.cc:58
|
|
2782 |
+msgid "Hiragana"
|
|
2783 |
+msgstr "平假名"
|
|
2784 |
+
|
|
2785 |
+#: ../fcitx_mozc.cc:63
|
|
2786 |
+msgid "Full Katakana"
|
|
2787 |
+msgstr "全形片假名"
|
|
2788 |
+
|
|
2789 |
+#: ../fcitx_mozc.cc:68
|
|
2790 |
+msgid "Half ASCII"
|
|
2791 |
+msgstr "半形 ASCII"
|
|
2792 |
+
|
|
2793 |
+#: ../fcitx_mozc.cc:73
|
|
2794 |
+msgid "Full ASCII"
|
|
2795 |
+msgstr "全形 ASCII"
|
|
2796 |
+
|
|
2797 |
+#: ../fcitx_mozc.cc:78
|
|
2798 |
+msgid "Half Katakana"
|
|
2799 |
+msgstr "半形片假名"
|
|
2800 |
+
|
|
2801 |
+#: ../fcitx_mozc.cc:379 ../fcitx_mozc.cc:380 ../fcitx_mozc.cc:458
|
|
2802 |
+msgid "Composition Mode"
|
|
2803 |
+msgstr "編輯模式"
|
|
2804 |
+
|
|
2805 |
+#: ../fcitx_mozc.cc:390 ../fcitx_mozc.cc:391
|
|
2806 |
+msgid "Tool"
|
|
2807 |
+msgstr "工具"
|
|
2808 |
+
|
|
2809 |
+#: ../fcitx_mozc.cc:471
|
|
2810 |
+msgid "Mozc Tool"
|
|
2811 |
+msgstr "Mozc 工具"
|
|
2812 |
+
|
|
2813 |
+#: ../fcitx_mozc.cc:477
|
|
2814 |
+msgid "Configuration Tool"
|
|
2815 |
+msgstr "設定工具"
|
|
2816 |
+
|
|
2817 |
+#: ../fcitx_mozc.cc:478
|
|
2818 |
+msgid "Dictionary Tool"
|
|
2819 |
+msgstr "字典工具"
|
|
2820 |
+
|
|
2821 |
+#: ../fcitx_mozc.cc:479
|
|
2822 |
+msgid "Hand Writing"
|
|
2823 |
+msgstr "手寫輸入"
|
|
2824 |
+
|
|
2825 |
+#: ../fcitx_mozc.cc:480
|
|
2826 |
+msgid "Character Palette"
|
|
2827 |
+msgstr "字符映射表"
|
|
2828 |
+
|
|
2829 |
+#: ../fcitx_mozc.cc:481
|
|
2830 |
+msgid "Add Word"
|
|
2831 |
+msgstr "添加單詞"
|
|
2832 |
+
|
|
2833 |
+#: ../fcitx_mozc.cc:482
|
|
2834 |
+msgid "About Mozc"
|
|
2835 |
+msgstr "關於 Mozc"
|
|
2836 |
+
|