diff options
| author | Inokinoki <veyx.shaw@gmail.com> | 2020-09-01 10:25:14 +0200 |
|---|---|---|
| committer | Peng Wu <alexepico@gmail.com> | 2020-09-02 11:40:12 +0800 |
| commit | 04aa7f052d2d911349c79cae6d922e3f65d24752 (patch) | |
| tree | 3f3504beaf453d2c089133250c23967ccf4b67ad | |
| parent | 3de68dd731aeae11e1930a1f25ecdad3b2cc50d8 (diff) | |
| download | ibus-libpinyin-04aa7f052d2d911349c79cae6d922e3f65d24752.tar.gz ibus-libpinyin-04aa7f052d2d911349c79cae6d922e3f65d24752.tar.xz ibus-libpinyin-04aa7f052d2d911349c79cae6d922e3f65d24752.zip | |
Enable Cloud Input for Full Pinyin mode
Co-authored-by: lianna07 <liannaxu07@gmail.com>
| -rw-r--r-- | configure.ac | 21 | ||||
| -rw-r--r-- | src/Makefile.am | 24 | ||||
| -rw-r--r-- | src/PYPPhoneticEditor.cc | 14 | ||||
| -rw-r--r-- | src/PYPPhoneticEditor.h | 9 |
4 files changed, 68 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 24fc841..9c0114f 100644 --- a/configure.ac +++ b/configure.ac @@ -181,6 +181,26 @@ fi AM_CONDITIONAL(IBUS_BUILD_LUA_EXTENSION, [test x"$enable_lua_extension" = x"yes"]) +# --enable-cloud-input-mode +AC_ARG_ENABLE(cloud-input-mode, + AC_HELP_STRING([--enable-cloud-input-mode], + [add cloud candidates]), + [enable_cloud_input_mode=$enableval], + [enable_cloud_input_mode=no] +) +if test x"$enable_cloud_input_mode" = x"yes"; then + # check soup + PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.26]) + AC_SUBST(LIBSOUP_CFLAGS) + AC_SUBST(LIBSOUP_LIBS) + + # check json-glib + PKG_CHECK_MODULES(JSONGLIB, [json-glib-1.0 >= 1.0]) + AC_SUBST(JSONGLIB_CFLAGS) + AC_SUBST(JSONGLIB_LIBS) +fi +AM_CONDITIONAL(ENABLE_CLOUD_INPUT_MODE, test x"$enable_cloud_input_mode" = x"yes") + # --disable-english-input-mode AC_ARG_ENABLE(english-input-mode, AS_HELP_STRING([--disable-english-input-mode], @@ -226,6 +246,7 @@ Build options: Use opencc $enable_opencc Use libpinyin $enable_libpinyin Build lua extension $enable_lua_extension + Build cloud input mode $enable_cloud_input_mode Build stroke input mode $enable_stroke_input_mode Build english input mode $enable_english_input_mode ]) diff --git a/src/Makefile.am b/src/Makefile.am index 1bd4ffa..d8a6802 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,6 +105,15 @@ ibus_engine_libpinyin_c_sources += \ $(NULL) endif +if ENABLE_CLOUD_INPUT_MODE +ibus_engine_libpinyin_h_sources += \ + PYPCloudCandidates.h \ + $(NULL) +ibus_engine_libpinyin_c_sources += \ + PYPCloudCandidates.cc \ + $(NULL) +endif + if IBUS_BUILD_STROKE_INPUT_MODE ibus_engine_libpinyin_c_sources += PYStrokeEditor.cc endif @@ -169,6 +178,21 @@ if IBUS_BUILD_LUA_EXTENSION $(NULL) endif +if ENABLE_CLOUD_INPUT_MODE +ibus_engine_libpinyin_CXXFLAGS += \ + @LIBSOUP_CFLAGS@ \ + @JSONGLIB_CFLAGS@ \ + -DENABLE_CLOUD_INPUT_MODE \ + $(NULL) +endif + +if ENABLE_CLOUD_INPUT_MODE +ibus_engine_libpinyin_LDADD += \ + @LIBSOUP_LIBS@ \ + @JSONGLIB_LIBS@ \ + $(NULL) +endif + if IBUS_BUILD_ENGLISH_INPUT_MODE ibus_engine_libpinyin_CXXFLAGS += \ -DIBUS_BUILD_ENGLISH_INPUT_MODE \ diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc index 7b37e6f..8910045 100644 --- a/src/PYPPhoneticEditor.cc +++ b/src/PYPPhoneticEditor.cc @@ -37,6 +37,9 @@ PhoneticEditor::PhoneticEditor (PinyinProperties &props, m_lua_converter_candidates (this), #endif m_emoji_candidates (this), +#ifdef ENABLE_CLOUD_INPUT_MODE + m_cloud_candidates(this), +#endif m_traditional_candidates (this, config) { } @@ -239,6 +242,12 @@ PhoneticEditor::updateCandidates (void) } #endif +#ifdef ENABLE_CLOUD_INPUT_MODE + /* keep me behind the other kinds of candidates which are inserted after n-gram candidates */ + if(m_config.enableCloudInput ()) + m_cloud_candidates.processCandidates (m_candidates); +#endif + if (!m_props.modeSimp ()) m_traditional_candidates.processCandidates (m_candidates); @@ -367,6 +376,11 @@ PhoneticEditor::selectCandidateInternal (EnhancedCandidate & candidate) case CANDIDATE_TRADITIONAL_CHINESE: return m_traditional_candidates.selectCandidate (candidate); +#ifdef ENABLE_CLOUD_INPUT_MODE + case CANDIDATE_CLOUD_INPUT: + return m_cloud_candidates.selectCandidate (candidate); +#endif + #ifdef IBUS_BUILD_LUA_EXTENSION case CANDIDATE_LUA_TRIGGER: return m_lua_trigger_candidates.selectCandidate (candidate); diff --git a/src/PYPPhoneticEditor.h b/src/PYPPhoneticEditor.h index 45500b5..ecc9eb7 100644 --- a/src/PYPPhoneticEditor.h +++ b/src/PYPPhoneticEditor.h @@ -39,10 +39,15 @@ #include "PYPEmojiCandidates.h" +#ifdef ENABLE_CLOUD_INPUT_MODE +#include "PYPCloudCandidates.h" +#endif + namespace PY { class PhoneticEditor : public Editor { friend class LibPinyinCandidates; + friend class CloudCandidates; public: PhoneticEditor (PinyinProperties & props, Config & config); @@ -125,6 +130,10 @@ protected: EmojiCandidates m_emoji_candidates; TraditionalCandidates m_traditional_candidates; + +#ifdef ENABLE_CLOUD_INPUT_MODE + CloudCandidates m_cloud_candidates; +#endif }; }; |
