Codebase list mozc / e1ee7d0
Update fcitx-mozc.patch Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org> Nobuhiro Iwamatsu 9 years ago
2 changed file(s) with 87 addition(s) and 108 deletion(s). Raw diff Collapse all Expand all
00 Daescription: Support fcitx
11 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
45
56 diff --git a/unix/fcitx/eim.cc b/unix/fcitx/eim.cc
67 new file mode 100644
7 index 0000000..d96a7ff
8 index 0000000..bc4f199
89 --- /dev/null
910 +++ b/unix/fcitx/eim.cc
10 @@ -0,0 +1,268 @@
11 @@ -0,0 +1,265 @@
1112 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
1213 +// All rights reserved.
1314 +//
3738 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3839 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3940 +
40 +// workaround
41 +#define _FCITX_LOG_H_
42 +
4341 +#include <fcitx/instance.h>
4442 +#include <fcitx/ime.h>
4543 +#include <fcitx/hook.h>
295293 +LoadLocal=True
296294 diff --git a/unix/fcitx/fcitx.gyp b/unix/fcitx/fcitx.gyp
297295 new file mode 100644
298 index 0000000..4744279
296 index 0000000..fc1a49a
299297 --- /dev/null
300298 +++ b/unix/fcitx/fcitx.gyp
301 @@ -0,0 +1,103 @@
299 @@ -0,0 +1,104 @@
302300 +#
303301 +# Copyright (c) 2010-2012 fcitx Project http://code.google.com/p/fcitx/
304302 +#
365363 + '<(gen_out_dir)/po/zh_CN.mo',
366364 + '<(gen_out_dir)/po/zh_TW.mo',
367365 + '<(gen_out_dir)/po/ja.mo',
366 + '<(gen_out_dir)/po/de.mo',
368367 + ],
369368 + 'action': [
370369 + 'sh',
404403 +}
405404 diff --git a/unix/fcitx/fcitx_key_event_handler.cc b/unix/fcitx/fcitx_key_event_handler.cc
406405 new file mode 100644
407 index 0000000..608c871
406 index 0000000..0685b5c
408407 --- /dev/null
409408 +++ b/unix/fcitx/fcitx_key_event_handler.cc
410 @@ -0,0 +1,246 @@
409 @@ -0,0 +1,243 @@
411410 +// Copyright 2010-2012, Google Inc.
412411 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
413412 +// All rights reserved.
437436 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
438437 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
439438 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
440 +
441 +// workaround
442 +#define _FCITX_LOG_H_
443439 +
444440 +#include "unix/fcitx/fcitx_key_event_handler.h"
445441 +
656652 +} // namespace mozc
657653 diff --git a/unix/fcitx/fcitx_key_event_handler.h b/unix/fcitx/fcitx_key_event_handler.h
658654 new file mode 100644
659 index 0000000..bc3043b
655 index 0000000..77a7ca2
660656 --- /dev/null
661657 +++ b/unix/fcitx/fcitx_key_event_handler.h
662658 @@ -0,0 +1,79 @@
694690 +#define MOZC_UNIX_FCITX_KEY_EVENT_HANDLER_H_
695691 +
696692 +#include <set>
693 +#include <memory>
697694 +
698695 +#include "base/port.h"
699 +#include "base/scoped_ptr.h"
700696 +#include "config/config.pb.h"
701697 +#include "session/commands.pb.h"
702698 +#include "unix/fcitx/fcitx_key_translator.h"
724720 + bool ProcessModifiers(bool is_key_up, uint32 keyval,
725721 + commands::KeyEvent *key_event);
726722 +
727 + scoped_ptr<KeyTranslator> key_translator_;
723 + std::unique_ptr<KeyTranslator> key_translator_;
728724 + // Non modifier key is pressed or not after all keys are released.
729725 + bool is_non_modifier_key_pressed_;
730726 + // Currently pressed modifier keys. It is set of keyval.
741737 +#endif // MOZC_UNIX_FCITX_KEY_EVENT_HANDLER_H_
742738 diff --git a/unix/fcitx/fcitx_key_translator.cc b/unix/fcitx/fcitx_key_translator.cc
743739 new file mode 100644
744 index 0000000..e0ccd12
740 index 0000000..0a3425a
745741 --- /dev/null
746742 +++ b/unix/fcitx/fcitx_key_translator.cc
747 @@ -0,0 +1,524 @@
743 @@ -0,0 +1,521 @@
748744 +// Copyright 2010-2012, Google Inc.
749745 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
750746 +// All rights reserved.
774770 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
775771 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
776772 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
777 +
778 +// workaround
779 +#define _FCITX_LOG_H_
780773 +
781774 +#include "unix/fcitx/fcitx_key_translator.h"
782775 +
12381231 + // to return an appropriate string. See the following IBus issue for
12391232 + // details: http://code.google.com/p/ibus/issues/detail?id=52
12401233 + if (keyval == '\\' && layout_is_jp) {
1241 + if (keycode == FcitxKey_bar) {
1234 + if (keycode == 132 || keycode == 133) {
12421235 + *out = "\xe3\x83\xbc"; // "ー"
12431236 + } else {
12441237 + *out = "\xe3\x82\x8d"; // "ろ"
12711264 +} // namespace mozc
12721265 diff --git a/unix/fcitx/fcitx_key_translator.h b/unix/fcitx/fcitx_key_translator.h
12731266 new file mode 100644
1274 index 0000000..b3a6f18
1267 index 0000000..af77ba3
12751268 --- /dev/null
12761269 +++ b/unix/fcitx/fcitx_key_translator.h
12771270 @@ -0,0 +1,121 @@
13141307 +
13151308 +#include <fcitx-config/hotkey.h>
13161309 +
1317 +#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
1310 +#include "base/port.h"
13181311 +#include "session/commands.pb.h"
13191312 +#include <fcitx/ime.h>
13201313 +
13981391 +#endif // MOZC_UNIX_FCITX_FCITX_KEY_TRANSLATOR_H_
13991392 diff --git a/unix/fcitx/fcitx_mozc.cc b/unix/fcitx/fcitx_mozc.cc
14001393 new file mode 100644
1401 index 0000000..5499fde
1394 index 0000000..5122c19
14021395 --- /dev/null
14031396 +++ b/unix/fcitx/fcitx_mozc.cc
1404 @@ -0,0 +1,566 @@
1397 @@ -0,0 +1,561 @@
14051398 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
14061399 +// All rights reserved.
14071400 +//
14301423 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14311424 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14321425 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1433 +
1434 +// workaround
1435 +#define _FCITX_LOG_H_
14361426 +
14371427 +#include "unix/fcitx/fcitx_mozc.h"
14381428 +
15401530 + InitializeBar();
15411531 + InitializeMenu();
15421532 + 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);
15471533 +}
15481534 +
15491535 +FcitxMozc::~FcitxMozc()
16201606 + else {
16211607 + FcitxUISetStatusVisable(instance, "mozc-tool", true);
16221608 + FcitxUISetStatusVisable(instance, "mozc-composition-mode", true);
1609 + connection_->UpdatePreeditMethod();
16231610 + }
16241611 +}
16251612 +
16431630 +// This function is called from SCIM framework when the ic gets focus.
16441631 +void FcitxMozc::init()
16451632 +{
1646 + VLOG ( 1 ) << "focus_in";
1633 + VLOG ( 1 ) << "init";
16471634 + boolean flag = true;
16481635 + FcitxInstanceSetContext(instance, CONTEXT_DISABLE_AUTOENG, &flag);
16491636 + FcitxInstanceSetContext(instance, CONTEXT_DISABLE_QUICKPHRASE, &flag);
16501637 + FcitxInstanceSetContext(instance, CONTEXT_IM_KEYBOARD_LAYOUT, "jp");
16511638 + FcitxInstanceSetContext(instance, "CONTEXT_DISABLE_AUTO_FIRST_CANDIDATE_HIGHTLIGHT", &flag);
16521639 +
1640 + connection_->UpdatePreeditMethod();
16531641 + DrawAll();
16541642 +}
16551643 +
19701958 +} // namespace mozc_unix_scim
19711959 diff --git a/unix/fcitx/fcitx_mozc.h b/unix/fcitx/fcitx_mozc.h
19721960 new file mode 100644
1973 index 0000000..b3a5128
1961 index 0000000..726fc22
19741962 --- /dev/null
19751963 +++ b/unix/fcitx/fcitx_mozc.h
1976 @@ -0,0 +1,173 @@
1964 @@ -0,0 +1,176 @@
19771965 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
19781966 +// All rights reserved.
19791967 +//
20061994 +#ifndef MOZC_UNIX_FCITX_FCITX_MOZC_H_
20071995 +#define MOZC_UNIX_FCITX_FCITX_MOZC_H_
20081996 +
1997 +#include <memory>
1998 +
20091999 +#include <fcitx/instance.h>
20102000 +#include <fcitx/candidate.h>
20112001 +#include <fcitx-config/hotkey.h>
20122002 +#include <libintl.h>
2013 +#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
2003 +
2004 +#include "base/port.h"
20142005 +#include "base/run_level.h"
20152006 +#include "session/commands.pb.h"
20162007 +#include "client/client_interface.h"
21222113 +
21232114 + FcitxInstance* instance;
21242115 + 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_;
21272118 +
21282119 + // Strings and a window currently displayed on FCITX UI.
2129 + scoped_ptr<const PreeditInfo> preedit_info_;
2120 + std::unique_ptr<const PreeditInfo> preedit_info_;
21302121 + std::string aux_; // error tooltip, or candidate window title.
21312122 + string url_; // URL to be opened by a browser.
21322123 + mozc::commands::CompositionMode composition_mode_;
21492140 +
21502141 diff --git a/unix/fcitx/gen_fcitx_mozc_i18n.sh b/unix/fcitx/gen_fcitx_mozc_i18n.sh
21512142 new file mode 100755
2152 index 0000000..b730b82
2143 index 0000000..97ff4a4
21532144 --- /dev/null
21542145 +++ b/unix/fcitx/gen_fcitx_mozc_i18n.sh
2155 @@ -0,0 +1,11 @@
2146 @@ -0,0 +1,10 @@
21562147 +#!/bin/sh
2148 +
21572149 +objdir="$1"
21582150 +
2159 +cd po || exit 1
2160 +
21612151 +mkdir -p "$1"
21622152 +
2163 +for pofile in *.po
2153 +for pofile in po/*.po
21642154 +do
2165 + msgfmt "$pofile" -o "$1/${pofile/po/mo}"
2155 + msgfmt "$pofile" -o "$1/`basename ${pofile} .po`.mo"
21662156 +done
2167 \ No newline at end of file
21682157 diff --git a/unix/fcitx/mozc.conf b/unix/fcitx/mozc.conf
21692158 new file mode 100644
21702159 index 0000000..ad19230
21802169 +Parent=fcitx-mozc
21812170 diff --git a/unix/fcitx/mozc_connection.cc b/unix/fcitx/mozc_connection.cc
21822171 new file mode 100755
2183 index 0000000..65fc446
2172 index 0000000..f2692e7
21842173 --- /dev/null
21852174 +++ b/unix/fcitx/mozc_connection.cc
2186 @@ -0,0 +1,196 @@
2175 @@ -0,0 +1,209 @@
21872176 +// Copyright 2010-2012, Google Inc.
21882177 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
21892178 +// All rights reserved.
22142203 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22152204 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22162205 +
2217 +// workaround
2218 +#define _FCITX_LOG_H_
2219 +
22202206 +#include "unix/fcitx/mozc_connection.h"
22212207 +
22222208 +#include <string>
22372223 +MozcConnectionInterface::~MozcConnectionInterface() {
22382224 +}
22392225 +
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 +
22402235 +MozcConnection::MozcConnection(
22412236 + mozc::client::ServerLauncherInterface *server_launcher,
22422237 + mozc::IPCClientFactoryInterface *client_factory)
22442239 + preedit_method_(mozc::config::Config::ROMAN),
22452240 + client_factory_(client_factory) {
22462241 + VLOG(1) << "MozcConnection is created";
2247 + mozc::client::ClientInterface *client =
2248 + mozc::client::ClientFactory::NewClient();
2242 + mozc::client::ClientInterface *client = CreateAndConfigureClient();
22492243 + client->SetServerLauncher(server_launcher);
22502244 + client->SetIPCClientFactory(client_factory_.get());
22512245 + client_.reset(client);
22522246 +
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();
22572249 + }
22582250 + VLOG(1)
22592251 + << "Current preedit method is "
22632255 +MozcConnection::~MozcConnection() {
22642256 + client_->SyncData();
22652257 + 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;
22662268 +}
22672269 +
22682270 +bool MozcConnection::TrySendKeyEvent(
23822384 +} // namespace mozc
23832385 diff --git a/unix/fcitx/mozc_connection.h b/unix/fcitx/mozc_connection.h
23842386 new file mode 100755
2385 index 0000000..d454632
2387 index 0000000..183c5bd
23862388 --- /dev/null
23872389 +++ b/unix/fcitx/mozc_connection.h
2388 @@ -0,0 +1,147 @@
2390 @@ -0,0 +1,152 @@
23892391 +// Copyright 2010-2012, Google Inc.
23902392 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
23912393 +// All rights reserved.
24202422 +#define MOZC_UNIX_FCITX_MOZC_CONNECTION_H_
24212423 +
24222424 +#include <string>
2425 +#include <memory>
2426 +
24232427 +#include <fcitx-config/hotkey.h>
24242428 +#include <fcitx/instance.h>
24252429 +
2426 +#include "base/base.h"
2430 +#include "base/port.h"
24272431 +#include "session/commands.pb.h"
24282432 +#include "unix/fcitx/fcitx_key_event_handler.h"
24292433 +
24712475 + mozc::commands::Output *out,
24722476 + string *out_error) const = 0;
24732477 + virtual mozc::client::ClientInterface* GetClient() = 0;
2478 + virtual void UpdatePreeditMethod() = 0;
24742479 +};
24752480 +
24762481 +class MozcConnection : public MozcConnectionInterface {
25132518 +
25142519 + virtual mozc::client::ClientInterface* GetClient();
25152520 +
2521 + virtual void UpdatePreeditMethod();
2522 +
25162523 + private:
25172524 + friend class MozcConnectionTest;
25182525 + MozcConnection(mozc::client::ServerLauncherInterface *server_launcher,
25192526 + mozc::IPCClientFactoryInterface *client_factory);
25202527 +
2521 + const scoped_ptr<KeyEventHandler> handler_;
2528 + const std::unique_ptr<KeyEventHandler> handler_;
25222529 + mozc::config::Config::PreeditMethod preedit_method_;
25232530 + // Keep definition order of client_factory_ and client_.
25242531 + // 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_;
25272534 +
25282535 + DISALLOW_COPY_AND_ASSIGN(MozcConnection);
25292536 +};
25352542 +#endif // MOZC_UNIX_SCIM_MOZC_CONNECTION_H_
25362543 diff --git a/unix/fcitx/mozc_response_parser.cc b/unix/fcitx/mozc_response_parser.cc
25372544 new file mode 100755
2538 index 0000000..e1d2739
2545 index 0000000..289037b
25392546 --- /dev/null
25402547 +++ b/unix/fcitx/mozc_response_parser.cc
2541 @@ -0,0 +1,456 @@
2548 @@ -0,0 +1,448 @@
25422549 +// Copyright 2010-2012, Google Inc.
25432550 +// Copyright 2012~2013, Weng Xuetian <wengxt@gmail.com>
25442551 +// All rights reserved.
25692576 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25702577 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25712578 +
2572 +// workaround
2573 +#define _FCITX_LOG_H_
2574 +
25752579 +#include "unix/fcitx/mozc_response_parser.h"
25762580 +
25772581 +#include <string>
25862590 +#include <fcitx/candidate.h>
25872591 +
25882592 +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 +}
25942593 +
25952594 +// Returns a position that determines a preedit cursor position _AND_ top-left
25962595 +// position of a candidate window. Note that we can't set these two positions
29972996 +} // namespace mozc
29982997 diff --git a/unix/fcitx/mozc_response_parser.h b/unix/fcitx/mozc_response_parser.h
29992998 new file mode 100755
3000 index 0000000..0975055
2999 index 0000000..beeef70
30013000 --- /dev/null
30023001 +++ b/unix/fcitx/mozc_response_parser.h
30033002 @@ -0,0 +1,97 @@
30343033 +#ifndef MOZC_UNIX_FCITX_MOZC_RESPONSE_PARSER_H_
30353034 +#define MOZC_UNIX_FCITX_MOZC_RESPONSE_PARSER_H_
30363035 +
3037 +#include "base/base.h" // for DISALLOW_COPY_AND_ASSIGN.
3036 +#include "base/port.h"
30383037 +
30393038 +namespace mozc
30403039 +{
36213620 +msgstr "按下 Ctrl+Alt+H 顯示用法。"
36223621 diff --git a/unix/fcitx/surrounding_text_util.cc b/unix/fcitx/surrounding_text_util.cc
36233622 new file mode 100644
3624 index 0000000..df7ff32
3623 index 0000000..8b4bfc6
36253624 --- /dev/null
36263625 +++ b/unix/fcitx/surrounding_text_util.cc
3627 @@ -0,0 +1,251 @@
3626 @@ -0,0 +1,242 @@
36283627 +// Copyright 2010-2013, Google Inc.
36293628 +// All rights reserved.
36303629 +//
36613660 +#include <fcitx/instance.h>
36623661 +#include <fcitx/module/clipboard/fcitx-clipboard.h>
36633662 +
3664 +#include "base/base.h"
3663 +#include "base/port.h"
36653664 +#include "base/logging.h"
36663665 +#include "base/util.h"
36673666 +
38543853 + return false;
38553854 + }
38563855 +
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);
38743864 + return true;
38753865 +}
38763866 +
+0
-11
debian/patches/fix_build_mo_of_fcitx less more
0 --- a/unix/fcitx/gen_fcitx_mozc_i18n.sh 2013-09-13 06:26:44.836849462 -0400
1 +++ b/unix/fcitx/gen_fcitx_mozc_i18n.sh 2013-09-13 06:27:01.408641126 -0400
2 @@ -7,5 +7,5 @@
3
4 for pofile in *.po
5 do
6 - msgfmt "$pofile" -o "$1/${pofile/po/mo}"
7 -done
8 \ No newline at end of file
9 + msgfmt "$pofile" -o "$1/`basename ${pofile} .po`.mo"
10 +done