0 | 0 |
Daescription: Support fcitx
|
1 | 1 |
Author: Weng Xuetian <wengxt@gmail.com>
|
2 | |
Origin: upstream of fcitx, http://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-1.12.1599.102.1.patch
|
3 | |
Last-Update: 2014-01-17
|
|
2 |
Origin: upstream of fcitx,
|
|
3 |
http://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-1.15.1834.102.1.patch
|
|
4 |
Last-Update: 2014-08-06
|
4 | 5 |
|
5 | 6 |
diff --git a/unix/fcitx/eim.cc b/unix/fcitx/eim.cc
|
6 | 7 |
new file mode 100644
|
7 | |
index 0000000..d96a7ff
|
|
8 |
index 0000000..bc4f199
|
8 | 9 |
--- /dev/null
|
9 | 10 |
+++ b/unix/fcitx/eim.cc
|
10 | |
@@ -0,0 +1,268 @@
|
|
11 |
@@ -0,0 +1,265 @@
|
11 | 12 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
12 | 13 |
+// All rights reserved.
|
13 | 14 |
+//
|
|
37 | 38 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
38 | 39 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
39 | 40 |
+
|
40 | |
+// workaround
|
41 | |
+#define _FCITX_LOG_H_
|
42 | |
+
|
43 | 41 |
+#include <fcitx/instance.h>
|
44 | 42 |
+#include <fcitx/ime.h>
|
45 | 43 |
+#include <fcitx/hook.h>
|
|
295 | 293 |
+LoadLocal=True
|
296 | 294 |
diff --git a/unix/fcitx/fcitx.gyp b/unix/fcitx/fcitx.gyp
|
297 | 295 |
new file mode 100644
|
298 | |
index 0000000..4744279
|
|
296 |
index 0000000..fc1a49a
|
299 | 297 |
--- /dev/null
|
300 | 298 |
+++ b/unix/fcitx/fcitx.gyp
|
301 | |
@@ -0,0 +1,103 @@
|
|
299 |
@@ -0,0 +1,104 @@
|
302 | 300 |
+#
|
303 | 301 |
+# Copyright (c) 2010-2012 fcitx Project http://code.google.com/p/fcitx/
|
304 | 302 |
+#
|
|
365 | 363 |
+ '<(gen_out_dir)/po/zh_CN.mo',
|
366 | 364 |
+ '<(gen_out_dir)/po/zh_TW.mo',
|
367 | 365 |
+ '<(gen_out_dir)/po/ja.mo',
|
|
366 |
+ '<(gen_out_dir)/po/de.mo',
|
368 | 367 |
+ ],
|
369 | 368 |
+ 'action': [
|
370 | 369 |
+ 'sh',
|
|
404 | 403 |
+}
|
405 | 404 |
diff --git a/unix/fcitx/fcitx_key_event_handler.cc b/unix/fcitx/fcitx_key_event_handler.cc
|
406 | 405 |
new file mode 100644
|
407 | |
index 0000000..608c871
|
|
406 |
index 0000000..0685b5c
|
408 | 407 |
--- /dev/null
|
409 | 408 |
+++ b/unix/fcitx/fcitx_key_event_handler.cc
|
410 | |
@@ -0,0 +1,246 @@
|
|
409 |
@@ -0,0 +1,243 @@
|
411 | 410 |
+// Copyright 2010-2012, Google Inc.
|
412 | 411 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
413 | 412 |
+// All rights reserved.
|
|
437 | 436 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
438 | 437 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
439 | 438 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
440 | |
+
|
441 | |
+// workaround
|
442 | |
+#define _FCITX_LOG_H_
|
443 | 439 |
+
|
444 | 440 |
+#include "unix/fcitx/fcitx_key_event_handler.h"
|
445 | 441 |
+
|
|
656 | 652 |
+} // namespace mozc
|
657 | 653 |
diff --git a/unix/fcitx/fcitx_key_event_handler.h b/unix/fcitx/fcitx_key_event_handler.h
|
658 | 654 |
new file mode 100644
|
659 | |
index 0000000..bc3043b
|
|
655 |
index 0000000..77a7ca2
|
660 | 656 |
--- /dev/null
|
661 | 657 |
+++ b/unix/fcitx/fcitx_key_event_handler.h
|
662 | 658 |
@@ -0,0 +1,79 @@
|
|
694 | 690 |
+#define MOZC_UNIX_FCITX_KEY_EVENT_HANDLER_H_
|
695 | 691 |
+
|
696 | 692 |
+#include <set>
|
|
693 |
+#include <memory>
|
697 | 694 |
+
|
698 | 695 |
+#include "base/port.h"
|
699 | |
+#include "base/scoped_ptr.h"
|
700 | 696 |
+#include "config/config.pb.h"
|
701 | 697 |
+#include "session/commands.pb.h"
|
702 | 698 |
+#include "unix/fcitx/fcitx_key_translator.h"
|
|
724 | 720 |
+ bool ProcessModifiers(bool is_key_up, uint32 keyval,
|
725 | 721 |
+ commands::KeyEvent *key_event);
|
726 | 722 |
+
|
727 | |
+ scoped_ptr<KeyTranslator> key_translator_;
|
|
723 |
+ std::unique_ptr<KeyTranslator> key_translator_;
|
728 | 724 |
+ // Non modifier key is pressed or not after all keys are released.
|
729 | 725 |
+ bool is_non_modifier_key_pressed_;
|
730 | 726 |
+ // Currently pressed modifier keys. It is set of keyval.
|
|
741 | 737 |
+#endif // MOZC_UNIX_FCITX_KEY_EVENT_HANDLER_H_
|
742 | 738 |
diff --git a/unix/fcitx/fcitx_key_translator.cc b/unix/fcitx/fcitx_key_translator.cc
|
743 | 739 |
new file mode 100644
|
744 | |
index 0000000..e0ccd12
|
|
740 |
index 0000000..0a3425a
|
745 | 741 |
--- /dev/null
|
746 | 742 |
+++ b/unix/fcitx/fcitx_key_translator.cc
|
747 | |
@@ -0,0 +1,524 @@
|
|
743 |
@@ -0,0 +1,521 @@
|
748 | 744 |
+// Copyright 2010-2012, Google Inc.
|
749 | 745 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
750 | 746 |
+// All rights reserved.
|
|
774 | 770 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
775 | 771 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
776 | 772 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
777 | |
+
|
778 | |
+// workaround
|
779 | |
+#define _FCITX_LOG_H_
|
780 | 773 |
+
|
781 | 774 |
+#include "unix/fcitx/fcitx_key_translator.h"
|
782 | 775 |
+
|
|
1238 | 1231 |
+ // to return an appropriate string. See the following IBus issue for
|
1239 | 1232 |
+ // details: http://code.google.com/p/ibus/issues/detail?id=52
|
1240 | 1233 |
+ if (keyval == '\\' && layout_is_jp) {
|
1241 | |
+ if (keycode == FcitxKey_bar) {
|
|
1234 |
+ if (keycode == 132 || keycode == 133) {
|
1242 | 1235 |
+ *out = "\xe3\x83\xbc"; // "ー"
|
1243 | 1236 |
+ } else {
|
1244 | 1237 |
+ *out = "\xe3\x82\x8d"; // "ろ"
|
|
1271 | 1264 |
+} // namespace mozc
|
1272 | 1265 |
diff --git a/unix/fcitx/fcitx_key_translator.h b/unix/fcitx/fcitx_key_translator.h
|
1273 | 1266 |
new file mode 100644
|
1274 | |
index 0000000..b3a6f18
|
|
1267 |
index 0000000..af77ba3
|
1275 | 1268 |
--- /dev/null
|
1276 | 1269 |
+++ b/unix/fcitx/fcitx_key_translator.h
|
1277 | 1270 |
@@ -0,0 +1,121 @@
|
|
1314 | 1307 |
+
|
1315 | 1308 |
+#include <fcitx-config/hotkey.h>
|
1316 | 1309 |
+
|
1317 | |
+#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
|
|
1310 |
+#include "base/port.h"
|
1318 | 1311 |
+#include "session/commands.pb.h"
|
1319 | 1312 |
+#include <fcitx/ime.h>
|
1320 | 1313 |
+
|
|
1398 | 1391 |
+#endif // MOZC_UNIX_FCITX_FCITX_KEY_TRANSLATOR_H_
|
1399 | 1392 |
diff --git a/unix/fcitx/fcitx_mozc.cc b/unix/fcitx/fcitx_mozc.cc
|
1400 | 1393 |
new file mode 100644
|
1401 | |
index 0000000..5499fde
|
|
1394 |
index 0000000..5122c19
|
1402 | 1395 |
--- /dev/null
|
1403 | 1396 |
+++ b/unix/fcitx/fcitx_mozc.cc
|
1404 | |
@@ -0,0 +1,566 @@
|
|
1397 |
@@ -0,0 +1,561 @@
|
1405 | 1398 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
1406 | 1399 |
+// All rights reserved.
|
1407 | 1400 |
+//
|
|
1430 | 1423 |
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
1431 | 1424 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
1432 | 1425 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1433 | |
+
|
1434 | |
+// workaround
|
1435 | |
+#define _FCITX_LOG_H_
|
1436 | 1426 |
+
|
1437 | 1427 |
+#include "unix/fcitx/fcitx_mozc.h"
|
1438 | 1428 |
+
|
|
1540 | 1530 |
+ InitializeBar();
|
1541 | 1531 |
+ InitializeMenu();
|
1542 | 1532 |
+ SetCompositionMode( mozc::commands::HIRAGANA );
|
1543 | |
+
|
1544 | |
+ commands::Capability capability;
|
1545 | |
+ capability.set_text_deletion(commands::Capability::DELETE_PRECEDING_TEXT);
|
1546 | |
+ GetClient()->set_client_capability(capability);
|
1547 | 1533 |
+}
|
1548 | 1534 |
+
|
1549 | 1535 |
+FcitxMozc::~FcitxMozc()
|
|
1620 | 1606 |
+ else {
|
1621 | 1607 |
+ FcitxUISetStatusVisable(instance, "mozc-tool", true);
|
1622 | 1608 |
+ FcitxUISetStatusVisable(instance, "mozc-composition-mode", true);
|
|
1609 |
+ connection_->UpdatePreeditMethod();
|
1623 | 1610 |
+ }
|
1624 | 1611 |
+}
|
1625 | 1612 |
+
|
|
1643 | 1630 |
+// This function is called from SCIM framework when the ic gets focus.
|
1644 | 1631 |
+void FcitxMozc::init()
|
1645 | 1632 |
+{
|
1646 | |
+ VLOG ( 1 ) << "focus_in";
|
|
1633 |
+ VLOG ( 1 ) << "init";
|
1647 | 1634 |
+ boolean flag = true;
|
1648 | 1635 |
+ FcitxInstanceSetContext(instance, CONTEXT_DISABLE_AUTOENG, &flag);
|
1649 | 1636 |
+ FcitxInstanceSetContext(instance, CONTEXT_DISABLE_QUICKPHRASE, &flag);
|
1650 | 1637 |
+ FcitxInstanceSetContext(instance, CONTEXT_IM_KEYBOARD_LAYOUT, "jp");
|
1651 | 1638 |
+ FcitxInstanceSetContext(instance, "CONTEXT_DISABLE_AUTO_FIRST_CANDIDATE_HIGHTLIGHT", &flag);
|
1652 | 1639 |
+
|
|
1640 |
+ connection_->UpdatePreeditMethod();
|
1653 | 1641 |
+ DrawAll();
|
1654 | 1642 |
+}
|
1655 | 1643 |
+
|
|
1970 | 1958 |
+} // namespace mozc_unix_scim
|
1971 | 1959 |
diff --git a/unix/fcitx/fcitx_mozc.h b/unix/fcitx/fcitx_mozc.h
|
1972 | 1960 |
new file mode 100644
|
1973 | |
index 0000000..b3a5128
|
|
1961 |
index 0000000..726fc22
|
1974 | 1962 |
--- /dev/null
|
1975 | 1963 |
+++ b/unix/fcitx/fcitx_mozc.h
|
1976 | |
@@ -0,0 +1,173 @@
|
|
1964 |
@@ -0,0 +1,176 @@
|
1977 | 1965 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
1978 | 1966 |
+// All rights reserved.
|
1979 | 1967 |
+//
|
|
2006 | 1994 |
+#ifndef MOZC_UNIX_FCITX_FCITX_MOZC_H_
|
2007 | 1995 |
+#define MOZC_UNIX_FCITX_FCITX_MOZC_H_
|
2008 | 1996 |
+
|
|
1997 |
+#include <memory>
|
|
1998 |
+
|
2009 | 1999 |
+#include <fcitx/instance.h>
|
2010 | 2000 |
+#include <fcitx/candidate.h>
|
2011 | 2001 |
+#include <fcitx-config/hotkey.h>
|
2012 | 2002 |
+#include <libintl.h>
|
2013 | |
+#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
|
|
2003 |
+
|
|
2004 |
+#include "base/port.h"
|
2014 | 2005 |
+#include "base/run_level.h"
|
2015 | 2006 |
+#include "session/commands.pb.h"
|
2016 | 2007 |
+#include "client/client_interface.h"
|
|
2122 | 2113 |
+
|
2123 | 2114 |
+ FcitxInstance* instance;
|
2124 | 2115 |
+ FcitxInputState* input;
|
2125 | |
+ const scoped_ptr<MozcConnectionInterface> connection_;
|
2126 | |
+ const scoped_ptr<MozcResponseParser> parser_;
|
|
2116 |
+ const std::unique_ptr<MozcConnectionInterface> connection_;
|
|
2117 |
+ const std::unique_ptr<MozcResponseParser> parser_;
|
2127 | 2118 |
+
|
2128 | 2119 |
+ // Strings and a window currently displayed on FCITX UI.
|
2129 | |
+ scoped_ptr<const PreeditInfo> preedit_info_;
|
|
2120 |
+ std::unique_ptr<const PreeditInfo> preedit_info_;
|
2130 | 2121 |
+ std::string aux_; // error tooltip, or candidate window title.
|
2131 | 2122 |
+ string url_; // URL to be opened by a browser.
|
2132 | 2123 |
+ mozc::commands::CompositionMode composition_mode_;
|
|
2149 | 2140 |
+
|
2150 | 2141 |
diff --git a/unix/fcitx/gen_fcitx_mozc_i18n.sh b/unix/fcitx/gen_fcitx_mozc_i18n.sh
|
2151 | 2142 |
new file mode 100755
|
2152 | |
index 0000000..b730b82
|
|
2143 |
index 0000000..97ff4a4
|
2153 | 2144 |
--- /dev/null
|
2154 | 2145 |
+++ b/unix/fcitx/gen_fcitx_mozc_i18n.sh
|
2155 | |
@@ -0,0 +1,11 @@
|
|
2146 |
@@ -0,0 +1,10 @@
|
2156 | 2147 |
+#!/bin/sh
|
|
2148 |
+
|
2157 | 2149 |
+objdir="$1"
|
2158 | 2150 |
+
|
2159 | |
+cd po || exit 1
|
2160 | |
+
|
2161 | 2151 |
+mkdir -p "$1"
|
2162 | 2152 |
+
|
2163 | |
+for pofile in *.po
|
|
2153 |
+for pofile in po/*.po
|
2164 | 2154 |
+do
|
2165 | |
+ msgfmt "$pofile" -o "$1/${pofile/po/mo}"
|
|
2155 |
+ msgfmt "$pofile" -o "$1/`basename ${pofile} .po`.mo"
|
2166 | 2156 |
+done
|
2167 | |
\ No newline at end of file
|
2168 | 2157 |
diff --git a/unix/fcitx/mozc.conf b/unix/fcitx/mozc.conf
|
2169 | 2158 |
new file mode 100644
|
2170 | 2159 |
index 0000000..ad19230
|
|
2180 | 2169 |
+Parent=fcitx-mozc
|
2181 | 2170 |
diff --git a/unix/fcitx/mozc_connection.cc b/unix/fcitx/mozc_connection.cc
|
2182 | 2171 |
new file mode 100755
|
2183 | |
index 0000000..65fc446
|
|
2172 |
index 0000000..f2692e7
|
2184 | 2173 |
--- /dev/null
|
2185 | 2174 |
+++ b/unix/fcitx/mozc_connection.cc
|
2186 | |
@@ -0,0 +1,196 @@
|
|
2175 |
@@ -0,0 +1,209 @@
|
2187 | 2176 |
+// Copyright 2010-2012, Google Inc.
|
2188 | 2177 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
2189 | 2178 |
+// All rights reserved.
|
|
2214 | 2203 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2215 | 2204 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2216 | 2205 |
+
|
2217 | |
+// workaround
|
2218 | |
+#define _FCITX_LOG_H_
|
2219 | |
+
|
2220 | 2206 |
+#include "unix/fcitx/mozc_connection.h"
|
2221 | 2207 |
+
|
2222 | 2208 |
+#include <string>
|
|
2237 | 2223 |
+MozcConnectionInterface::~MozcConnectionInterface() {
|
2238 | 2224 |
+}
|
2239 | 2225 |
+
|
|
2226 |
+mozc::client::ClientInterface* CreateAndConfigureClient() {
|
|
2227 |
+ mozc::client::ClientInterface *client = client::ClientFactory::NewClient();
|
|
2228 |
+ // Currently client capability is fixed.
|
|
2229 |
+ commands::Capability capability;
|
|
2230 |
+ capability.set_text_deletion(commands::Capability::DELETE_PRECEDING_TEXT);
|
|
2231 |
+ client->set_client_capability(capability);
|
|
2232 |
+ return client;
|
|
2233 |
+}
|
|
2234 |
+
|
2240 | 2235 |
+MozcConnection::MozcConnection(
|
2241 | 2236 |
+ mozc::client::ServerLauncherInterface *server_launcher,
|
2242 | 2237 |
+ mozc::IPCClientFactoryInterface *client_factory)
|
|
2244 | 2239 |
+ preedit_method_(mozc::config::Config::ROMAN),
|
2245 | 2240 |
+ client_factory_(client_factory) {
|
2246 | 2241 |
+ VLOG(1) << "MozcConnection is created";
|
2247 | |
+ mozc::client::ClientInterface *client =
|
2248 | |
+ mozc::client::ClientFactory::NewClient();
|
|
2242 |
+ mozc::client::ClientInterface *client = CreateAndConfigureClient();
|
2249 | 2243 |
+ client->SetServerLauncher(server_launcher);
|
2250 | 2244 |
+ client->SetIPCClientFactory(client_factory_.get());
|
2251 | 2245 |
+ client_.reset(client);
|
2252 | 2246 |
+
|
2253 | |
+ mozc::config::Config config;
|
2254 | |
+ if (client_->EnsureConnection() &&
|
2255 | |
+ client_->GetConfig(&config) && config.has_preedit_method()) {
|
2256 | |
+ preedit_method_ = config.preedit_method();
|
|
2247 |
+ if (client_->EnsureConnection()) {
|
|
2248 |
+ UpdatePreeditMethod();
|
2257 | 2249 |
+ }
|
2258 | 2250 |
+ VLOG(1)
|
2259 | 2251 |
+ << "Current preedit method is "
|
|
2263 | 2255 |
+MozcConnection::~MozcConnection() {
|
2264 | 2256 |
+ client_->SyncData();
|
2265 | 2257 |
+ VLOG(1) << "MozcConnection is destroyed";
|
|
2258 |
+}
|
|
2259 |
+
|
|
2260 |
+void MozcConnection::UpdatePreeditMethod() {
|
|
2261 |
+ mozc::config::Config config;
|
|
2262 |
+ if (!client_->GetConfig(&config)) {
|
|
2263 |
+ LOG(ERROR) << "GetConfig failed";
|
|
2264 |
+ return;
|
|
2265 |
+ }
|
|
2266 |
+ preedit_method_ = config.has_preedit_method() ?
|
|
2267 |
+ config.preedit_method() : config::Config::ROMAN;
|
2266 | 2268 |
+}
|
2267 | 2269 |
+
|
2268 | 2270 |
+bool MozcConnection::TrySendKeyEvent(
|
|
2382 | 2384 |
+} // namespace mozc
|
2383 | 2385 |
diff --git a/unix/fcitx/mozc_connection.h b/unix/fcitx/mozc_connection.h
|
2384 | 2386 |
new file mode 100755
|
2385 | |
index 0000000..d454632
|
|
2387 |
index 0000000..183c5bd
|
2386 | 2388 |
--- /dev/null
|
2387 | 2389 |
+++ b/unix/fcitx/mozc_connection.h
|
2388 | |
@@ -0,0 +1,147 @@
|
|
2390 |
@@ -0,0 +1,152 @@
|
2389 | 2391 |
+// Copyright 2010-2012, Google Inc.
|
2390 | 2392 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
2391 | 2393 |
+// All rights reserved.
|
|
2420 | 2422 |
+#define MOZC_UNIX_FCITX_MOZC_CONNECTION_H_
|
2421 | 2423 |
+
|
2422 | 2424 |
+#include <string>
|
|
2425 |
+#include <memory>
|
|
2426 |
+
|
2423 | 2427 |
+#include <fcitx-config/hotkey.h>
|
2424 | 2428 |
+#include <fcitx/instance.h>
|
2425 | 2429 |
+
|
2426 | |
+#include "base/base.h"
|
|
2430 |
+#include "base/port.h"
|
2427 | 2431 |
+#include "session/commands.pb.h"
|
2428 | 2432 |
+#include "unix/fcitx/fcitx_key_event_handler.h"
|
2429 | 2433 |
+
|
|
2471 | 2475 |
+ mozc::commands::Output *out,
|
2472 | 2476 |
+ string *out_error) const = 0;
|
2473 | 2477 |
+ virtual mozc::client::ClientInterface* GetClient() = 0;
|
|
2478 |
+ virtual void UpdatePreeditMethod() = 0;
|
2474 | 2479 |
+};
|
2475 | 2480 |
+
|
2476 | 2481 |
+class MozcConnection : public MozcConnectionInterface {
|
|
2513 | 2518 |
+
|
2514 | 2519 |
+ virtual mozc::client::ClientInterface* GetClient();
|
2515 | 2520 |
+
|
|
2521 |
+ virtual void UpdatePreeditMethod();
|
|
2522 |
+
|
2516 | 2523 |
+ private:
|
2517 | 2524 |
+ friend class MozcConnectionTest;
|
2518 | 2525 |
+ MozcConnection(mozc::client::ServerLauncherInterface *server_launcher,
|
2519 | 2526 |
+ mozc::IPCClientFactoryInterface *client_factory);
|
2520 | 2527 |
+
|
2521 | |
+ const scoped_ptr<KeyEventHandler> handler_;
|
|
2528 |
+ const std::unique_ptr<KeyEventHandler> handler_;
|
2522 | 2529 |
+ mozc::config::Config::PreeditMethod preedit_method_;
|
2523 | 2530 |
+ // Keep definition order of client_factory_ and client_.
|
2524 | 2531 |
+ // We should delete client_ before deleting client_factory_.
|
2525 | |
+ scoped_ptr<mozc::IPCClientFactoryInterface> client_factory_;
|
2526 | |
+ scoped_ptr<mozc::client::ClientInterface> client_;
|
|
2532 |
+ std::unique_ptr<mozc::IPCClientFactoryInterface> client_factory_;
|
|
2533 |
+ std::unique_ptr<mozc::client::ClientInterface> client_;
|
2527 | 2534 |
+
|
2528 | 2535 |
+ DISALLOW_COPY_AND_ASSIGN(MozcConnection);
|
2529 | 2536 |
+};
|
|
2535 | 2542 |
+#endif // MOZC_UNIX_SCIM_MOZC_CONNECTION_H_
|
2536 | 2543 |
diff --git a/unix/fcitx/mozc_response_parser.cc b/unix/fcitx/mozc_response_parser.cc
|
2537 | 2544 |
new file mode 100755
|
2538 | |
index 0000000..e1d2739
|
|
2545 |
index 0000000..289037b
|
2539 | 2546 |
--- /dev/null
|
2540 | 2547 |
+++ b/unix/fcitx/mozc_response_parser.cc
|
2541 | |
@@ -0,0 +1,456 @@
|
|
2548 |
@@ -0,0 +1,448 @@
|
2542 | 2549 |
+// Copyright 2010-2012, Google Inc.
|
2543 | 2550 |
+// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
|
2544 | 2551 |
+// All rights reserved.
|
|
2569 | 2576 |
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2570 | 2577 |
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2571 | 2578 |
+
|
2572 | |
+// workaround
|
2573 | |
+#define _FCITX_LOG_H_
|
2574 | |
+
|
2575 | 2579 |
+#include "unix/fcitx/mozc_response_parser.h"
|
2576 | 2580 |
+
|
2577 | 2581 |
+#include <string>
|
|
2586 | 2590 |
+#include <fcitx/candidate.h>
|
2587 | 2591 |
+
|
2588 | 2592 |
+namespace {
|
2589 | |
+
|
2590 | |
+// Returns true if the candidate window contains only suggestions.
|
2591 | |
+bool IsSuggestion(const mozc::commands::Candidates &candidates) {
|
2592 | |
+ return !candidates.has_focused_index();
|
2593 | |
+}
|
2594 | 2593 |
+
|
2595 | 2594 |
+// Returns a position that determines a preedit cursor position _AND_ top-left
|
2596 | 2595 |
+// position of a candidate window. Note that we can't set these two positions
|
|
2997 | 2996 |
+} // namespace mozc
|
2998 | 2997 |
diff --git a/unix/fcitx/mozc_response_parser.h b/unix/fcitx/mozc_response_parser.h
|
2999 | 2998 |
new file mode 100755
|
3000 | |
index 0000000..0975055
|
|
2999 |
index 0000000..beeef70
|
3001 | 3000 |
--- /dev/null
|
3002 | 3001 |
+++ b/unix/fcitx/mozc_response_parser.h
|
3003 | 3002 |
@@ -0,0 +1,97 @@
|
|
3034 | 3033 |
+#ifndef MOZC_UNIX_FCITX_MOZC_RESPONSE_PARSER_H_
|
3035 | 3034 |
+#define MOZC_UNIX_FCITX_MOZC_RESPONSE_PARSER_H_
|
3036 | 3035 |
+
|
3037 | |
+#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
|
|
3036 |
+#include "base/port.h"
|
3038 | 3037 |
+
|
3039 | 3038 |
+namespace mozc
|
3040 | 3039 |
+{
|
|
3621 | 3620 |
+msgstr "按下 Ctrl+Alt+H 顯示用法。"
|
3622 | 3621 |
diff --git a/unix/fcitx/surrounding_text_util.cc b/unix/fcitx/surrounding_text_util.cc
|
3623 | 3622 |
new file mode 100644
|
3624 | |
index 0000000..df7ff32
|
|
3623 |
index 0000000..8b4bfc6
|
3625 | 3624 |
--- /dev/null
|
3626 | 3625 |
+++ b/unix/fcitx/surrounding_text_util.cc
|
3627 | |
@@ -0,0 +1,251 @@
|
|
3626 |
@@ -0,0 +1,242 @@
|
3628 | 3627 |
+// Copyright 2010-2013, Google Inc.
|
3629 | 3628 |
+// All rights reserved.
|
3630 | 3629 |
+//
|
|
3661 | 3660 |
+#include <fcitx/instance.h>
|
3662 | 3661 |
+#include <fcitx/module/clipboard/fcitx-clipboard.h>
|
3663 | 3662 |
+
|
3664 | |
+#include "base/base.h"
|
|
3663 |
+#include "base/port.h"
|
3665 | 3664 |
+#include "base/logging.h"
|
3666 | 3665 |
+#include "base/util.h"
|
3667 | 3666 |
+
|
|
3854 | 3853 |
+ return false;
|
3855 | 3854 |
+ }
|
3856 | 3855 |
+
|
3857 | |
+ const uint32 selection_start = min(cursor_pos, anchor_pos);
|
3858 | |
+ const uint32 selection_length = abs(info->relative_selected_length);
|
3859 | |
+
|
3860 | |
+ if (selection_start > surrounding_text.length()) {
|
3861 | |
+ return false;
|
3862 | |
+ }
|
3863 | |
+ if (selection_start + selection_length > surrounding_text.length()) {
|
3864 | |
+ return false;
|
3865 | |
+ }
|
3866 | |
+
|
3867 | |
+ info->preceding_text = surrounding_text.substr(0, selection_start);
|
3868 | |
+ Util::SubString(surrounding_text,
|
3869 | |
+ selection_start,
|
3870 | |
+ selection_length,
|
3871 | |
+ &info->selection_text);
|
3872 | |
+ info->following_text = surrounding_text.substr(
|
3873 | |
+ selection_start + selection_length);
|
|
3856 |
+ const size_t selection_start = min(cursor_pos, anchor_pos);
|
|
3857 |
+ const size_t selection_length = abs(info->relative_selected_length);
|
|
3858 |
+ Util::SubStringPiece(surrounding_text, 0, selection_start)
|
|
3859 |
+ .CopyToString(&info->preceding_text);
|
|
3860 |
+ Util::SubStringPiece(surrounding_text, selection_start, selection_length)
|
|
3861 |
+ .CopyToString(&info->selection_text);
|
|
3862 |
+ Util::SubStringPiece(surrounding_text, selection_start + selection_length)
|
|
3863 |
+ .CopyToString(&info->following_text);
|
3874 | 3864 |
+ return true;
|
3875 | 3865 |
+}
|
3876 | 3866 |
+
|