├── po ├── POTFILES.skip ├── LINGUAS ├── POTFILES.in ├── Makevars ├── ibus-libzhuyin.pot └── ru.po ├── AUTHORS ├── ChangeLog ├── README ├── data ├── easysymbol.txt ├── ibus-setup-libzhuyin.desktop.in ├── model │ ├── table.conf.in │ └── Makefile.am ├── usersymbol.txt ├── libzhuyin.appdata.xml ├── icons │ ├── Makefile.am │ ├── half.svg │ └── full.svg ├── Makefile.am └── com.github.libzhuyin.ibus-libzhuyin.gschema.xml ├── README.md ├── scripts ├── php_2_py.php └── update-tradsimp-table.py ├── .github └── workflows │ └── make-check.yml ├── setup ├── config.py.in ├── ibus-setup-libzhuyin.in └── Makefile.am ├── src ├── ZYTypes.h ├── ZYRawEditor.h ├── ZYTradSimpConverter.h ├── libzhuyin.xml.in.in ├── ZYBus.h ├── ZYObject.h ├── ZYZEnhancedEditor.h ├── ZYSymbolLookup.h ├── ZYSymbols.h ├── ZYZBuiltinSymbolSection.h ├── ZYZBopomofoSymbolSection.h ├── ZYZUserSymbolShownSection.h ├── ZYZPhoneticSection.h ├── ZYZPinyinEditor.h ├── ZYZZhuyinEditor.h ├── ZYZUserSymbolListAllSection.h ├── ZYZConfig.h ├── ZYZSymbolSection.h ├── ZYPointer.h ├── ZYLibZhuyin.h ├── ZYFallbackEditor.h ├── ZYText.h ├── ZYZZhuyinEngine.h ├── ZYZhuyinProperties.h ├── ZYEnhancedText.h ├── ZYSymbolLookup.cc ├── ZYZBuiltinSymbolSection.cc ├── ZYZBopomofoSymbolSection.cc ├── ZYLookupTable.h ├── ZYZUserSymbolShownSection.cc ├── ZYProperty.h ├── ZYZEnhancedEditor.cc ├── ZYSignal.h ├── ZYUtil.h ├── ZYZUserSymbolListAllSection.cc ├── ZYConfig.cc ├── ZYZPhoneticSection.cc ├── ZYEditor.cc ├── ZYEngine.h ├── ZYString.h ├── ZYFallbackEditor.cc ├── Makefile.am ├── ZYTradSimpConverter.cc ├── ZYConfig.h ├── ZYZPhoneticEditor.h ├── ZYMain.cc ├── ZYEditor.h ├── ZYZhuyinProperties.cc └── ZYLibZhuyin.cc ├── Makefile.am ├── autogen.sh ├── ibus-libzhuyin.spec.in ├── NEWS ├── m4 └── as-version.m4 └── configure.ac /po/POTFILES.skip: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Peng Wu 2013 2 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | zh_CN 2 | zh_HK 3 | de 4 | zh_TW 5 | ka 6 | el 7 | es 8 | ru 9 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2022-08-24 gettextize 2 | 3 | * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.21. 4 | 5 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | src/ZYZhuyinProperties.cc 2 | src/ZYMain.cc 3 | setup/main.py 4 | setup/config.py 5 | setup/ibus-libzhuyin-preferences.ui 6 | data/ibus-setup-libzhuyin.desktop.in 7 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ibus-libzhuyin 2 | 3 | New Zhuyin engine based on libzhuyin for IBus 4 | 5 | Description 6 | It includes a Chinese Zhuyin (Bopomofo) input method based on libzhuyin for IBus. 7 | -------------------------------------------------------------------------------- /data/easysymbol.txt: -------------------------------------------------------------------------------- 1 | Q 〔 2 | W 〕 3 | A 【 4 | S 】 5 | Z 《 6 | X 》 7 | E { 8 | R } 9 | D 「 10 | F 」 11 | C 『 12 | V 』 13 | T ‘ 14 | Y ’ 15 | G “ 16 | H ” 17 | B 〝 18 | N 〞 19 | U + 20 | I - 21 | O × 22 | P ÷ 23 | J ≠ 24 | K ≒ 25 | L Orz 26 | M … 27 | -------------------------------------------------------------------------------- /data/ibus-setup-libzhuyin.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=IBus LibZhuyin Setup 3 | Comment=Set ibus-libzhuyin Preferences 4 | Exec=@libexecdir@/ibus-setup-libzhuyin 5 | Icon=@pkgdatadir@/icons/ibus-zhuyin.svg 6 | NoDisplay=true 7 | Type=Application 8 | StartupNotify=true 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ibus-libzhuyin 2 | 3 | New Zhuyin engine based on libzhuyin for IBus 4 | 5 | ## Description 6 | It includes a Chinese Zhuyin (Bopomofo) input method based on libzhuyin for IBus. 7 | 8 | ## Development 9 | 10 | ``` 11 | # dnf install ibus ibus-devel libpinyin libpinyin-devel opencc opencc-devel 12 | $ ./autogen.sh 13 | ``` 14 | ## License 15 | 16 | [GNU General Public License v2.0](./COPYING) 17 | -------------------------------------------------------------------------------- /data/model/table.conf.in: -------------------------------------------------------------------------------- 1 | binary format version:6 2 | model data version:11 3 | lambda parameter:0.136866 4 | 5 | source table format:zhuyin 6 | database format:@DATABASE_FORMAT@ 7 | 8 | default RESERVED NULL NULL NULL NOT_USED 9 | default TSI_DICTIONARY tsi.table tsi.bin tsi.dbin SYSTEM_FILE 10 | default NETWORK_DICTIONARY NULL NULL network.bin USER_FILE 11 | default USER_DICTIONARY NULL NULL user.bin USER_FILE 12 | -------------------------------------------------------------------------------- /data/usersymbol.txt: -------------------------------------------------------------------------------- 1 | … 2 | ※ 3 | 標點符號=,。?!、;:…・—「」()《》『』〈〉~_﹏ 4 | 常用符號=‥﹐﹒˙·‘’“”〝〞‵′〃~$%@&#* 5 | 左右括號=()「」〔〕{}〈〉『』《》【】﹙﹚﹝﹞﹛﹜ 6 | 上下括號=︵︶﹁﹂︹︺︷︸︿﹀﹃﹄︽︾︻︼ 7 | 希臘字母=αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ 8 | 數學符號=+-×÷=≠≒∞±√<>﹤﹥≦≧∩∪ˇ⊥∠∟⊿㏒㏑∫∮∵∴╳﹢ 9 | 特殊圖形=↑↓←→↖↗↙↘㊣◎○●⊕⊙○●△▲☆★◇◆□■▽▼§¥〒¢£※♀♂ 10 | Unicode=♨☀☁☂☃♠♥♣♦♩♪♫♬☺☻ 11 | 單線框=├─┼┴┬┤┌┐╞═╪╡│▕└┘╭╮╰╯ 12 | 雙線框=╔╦╗╠═╬╣╓╥╖╒╤╕║╚╩╝╟╫╢╙╨╜╞╪╡╘╧╛ 13 | 填色方塊=_ˍ▁▂▃▄▅▆▇█▏▎▍▌▋▊▉◢◣◥◤ 14 | 線段=﹣﹦≡|∣∥–︱—︳╴¯ ̄﹉﹊﹍﹎﹋﹌﹏︴∕﹨╱╲/\ 15 | -------------------------------------------------------------------------------- /scripts/php_2_py.php: -------------------------------------------------------------------------------- 1 | $val) { 12 | echo " u\"", $key, "\": u\"", $val, "\",\n"; 13 | } 14 | echo "}\n"; 15 | echo "\n"; 16 | } 17 | 18 | printDict("zh2Hant", ZhConversion::$zh2Hant); 19 | printDict("zh2Hans", ZhConversion::$zh2Hans); 20 | printDict("zh2TW", ZhConversion::$zh2TW); 21 | printDict("zh2HK", ZhConversion::$zh2HK); 22 | printDict("zh2CN", ZhConversion::$zh2CN); 23 | # printDict("zh2SG", ZhConversion::$zh2SG); 24 | ?> 25 | -------------------------------------------------------------------------------- /.github/workflows/make-check.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-22.04 13 | 14 | container: 15 | image: fedora:rawhide 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: install build dependency 20 | run: sudo dnf install -y gcc-c++ gettext-devel libtool pkgconfig sqlite-devel ibus-devel libpinyin-devel python3-devel libpinyin-tools make gnome-common which wget 21 | - name: autoconf 22 | run: ./autogen.sh 23 | - name: configure 24 | run: ./configure 25 | - name: make 26 | run: make 27 | - name: make check 28 | run: make check 29 | - name: make distcheck 30 | run: make distcheck 31 | -------------------------------------------------------------------------------- /setup/config.py.in: -------------------------------------------------------------------------------- 1 | # vim:set et ts=4 sts=4: 2 | # 3 | # ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | # 5 | # Copyright (c) 2013-2014 Peng Wu 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2, or (at your option) 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | 21 | import gettext 22 | 23 | gettext.install("ibus-libzhuyin") 24 | 25 | def get_version(): 26 | return "@VERSION@" 27 | 28 | def get_longname(): 29 | return _("New Zhuyin") 30 | -------------------------------------------------------------------------------- /data/libzhuyin.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.github.libzhuyin 4 | CC0-1.0 5 | Zhuyin 6 | Chinese Zhuyin and Pinyin input method 7 | 8 |

9 | The Zhuyin input method is designed for entering Chinese text by 10 | using Zhuyin or Pinyin. 11 |

12 |

13 | Input methods are typing systems allowing users to input complex languages. 14 | They are necessary because these contain too many characters to simply be laid 15 | out on a traditional keyboard. 16 |

17 |
18 | https://github.com/libzhuyin/ibus-libzhuyin 19 | GNOME 20 | The GNOME Project 21 | https://code.google.com/p/ibus/issues/list 22 | https://www.gnome.org/friends/ 23 | https://code.google.com/p/ibus/wiki/FAQ 24 | alexepico_AT_gmail.com 25 |
26 | -------------------------------------------------------------------------------- /src/ZYTypes.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_TYPES_H_ 22 | #define __ZY_TYPES_H_ 23 | 24 | #include 25 | 26 | namespace ZY { 27 | 28 | 29 | #define MAX_UTF8_LEN 6 30 | #define MAX_PHRASE_LEN 16 31 | 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/ZYRawEditor.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_RAW_EDITOR_ 22 | #define __ZY_RAW_EDITOR_ 23 | 24 | #include "ZYEditor.h" 25 | 26 | namespace ZY { 27 | 28 | class RawEditor : public Editor { 29 | public: 30 | RawEditor (ZhuyinProperties &props, Config & config) 31 | : Editor (props, config) { } 32 | }; 33 | 34 | }; 35 | #endif 36 | -------------------------------------------------------------------------------- /src/ZYTradSimpConverter.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_TRAD_SIMP_CONVERTER_H_ 23 | #define __ZY_TRAD_SIMP_CONVERTER_H_ 24 | 25 | #include 26 | 27 | namespace ZY { 28 | 29 | class String; 30 | 31 | class TradSimpConverter { 32 | public: 33 | static void tradToSimp (const gchar * in, String &out); 34 | }; 35 | 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /setup/ibus-setup-libzhuyin.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:set noet ts=4: 3 | # 4 | # ibus-tmpl - The Input Bus template project 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2, or (at your option) 11 | # any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | 22 | prefix=@prefix@ 23 | exec_prefix=@exec_prefix@ 24 | datarootdir=@datarootdir@ 25 | pkgdatadir=@prefix@/share/@PACKAGE@ 26 | export IBUS_PREFIX=@prefix@ 27 | export IBUS_DATAROOTDIR=@datarootdir@ 28 | export IBUS_LOCALEDIR=@localedir@ 29 | export IBUS_PKGDATADIR=@prefix@/share/@PACKAGE@ 30 | cd @prefix@/share/@PACKAGE@/setup/ 31 | exec @PYTHON@ main.py $@ 32 | 33 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | # 5 | # Copyright (c) 2014 Peng Wu 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2, or (at your option) 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | 21 | SUBDIRS = src setup data po 22 | 23 | ACLOCAL_AMFLAGS = -I m4 24 | 25 | # Remove doc directory on uninstall 26 | uninstall-local: 27 | -rm -r $(docdir) 28 | 29 | EXTRA_DIST = \ 30 | autogen.sh \ 31 | ibus-libzhuyin.spec.in \ 32 | $(NULL) 33 | 34 | noinst_DIST = \ 35 | $(NULL) 36 | 37 | DISTCLEANFILES = \ 38 | po/stamp-it \ 39 | $(NULL) 40 | -------------------------------------------------------------------------------- /src/libzhuyin.xml.in.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.freedesktop.IBus.Libzhuyin 5 | Libzhuyin Component 6 | ${libexecdir}/ibus-engine-libzhuyin --ibus 7 | @VERSION@ 8 | Peng Wu <alexepico@gmail.com> 9 | GPL 10 | https://github.com/libzhuyin/ibus-libzhuyin 11 | ibus-libzhuyin 12 | 13 | 14 | 15 | libzhuyin 16 | zh_TW 17 | GPL 18 | 19 | Peng Wu <alexepico@gmail.com> 20 | Peng Huang <shawn.p.huang@gmail.com> 21 | ... 22 | 23 | ${pkgdatadir}/icons/ibus-zhuyin.svg 24 | default 25 | New Zhuyin 26 | New Zhuyin input method 27 | 99 28 | 29 | ${libexecdir}/ibus-setup-libzhuyin zhuyin 30 | ibus-libzhuyin 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /data/icons/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | # 5 | # Copyright (c) 2014 Peng Wu 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2, or (at your option) 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | 21 | 22 | icons_DATA = \ 23 | ibus-zhuyin.svg \ 24 | chinese.svg \ 25 | english.svg \ 26 | full.svg \ 27 | full-punct.svg \ 28 | half.svg \ 29 | half-punct.svg \ 30 | simp-chinese.svg \ 31 | trad-chinese.svg \ 32 | $(NULL) 33 | 34 | iconsdir = $(pkgdatadir)/icons 35 | 36 | EXTRA_DIST = \ 37 | $(icons_DATA) \ 38 | $(NULL) 39 | 40 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to generate all the initial makefiles, etc. 3 | 4 | test -n "$srcdir" || srcdir=$(dirname "$0") 5 | test -n "$srcdir" || srcdir=. 6 | 7 | olddir=$(pwd) 8 | 9 | cd "$srcdir" 10 | 11 | PKG_NAME="ibus-libzhuyin" 12 | 13 | (test -f configure.ac && test -f README ) || { 14 | echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" 15 | echo " top-level $PKG_NAME directory" 16 | exit 1 17 | } 18 | 19 | if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then 20 | echo "*** WARNING: I am going to run 'configure' with no arguments." >&2 21 | echo "*** If you wish to pass any to it, please specify them on the" >&2 22 | echo "*** '$0' command line." >&2 23 | echo "" >&2 24 | fi 25 | 26 | glib-gettextize --force --copy || exit 1 27 | 28 | autoreconf --verbose --force --install || exit 1 29 | 30 | (test -f ChangeLog) || { 31 | touch ChangeLog 32 | } 33 | 34 | cd "$olddir" 35 | 36 | CFLAGS=${CFLAGS-"-Wall -Werror"} 37 | 38 | ACLOCAL_FLAGS="$ACLOCAL_FLAGS" 39 | REQUIRED_AUTOMAKE_VERSION=1.8 40 | 41 | cd "$olddir" 42 | if [ "$NOCONFIGURE" = "" ]; then 43 | $srcdir/configure "$@" || exit 1 44 | 45 | if [ "$1" = "--help" ]; then 46 | exit 0 47 | else 48 | echo "Now type 'make' to compile $PKG_NAME" || exit 1 49 | fi 50 | else 51 | echo "Skipping configure process." 52 | fi 53 | -------------------------------------------------------------------------------- /src/ZYBus.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_BUS_H_ 22 | #define __ZY_BUS_H_ 23 | 24 | #include 25 | #include "ZYObject.h" 26 | 27 | namespace ZY { 28 | 29 | class Bus : Object { 30 | public: 31 | Bus (void) : Object (ibus_bus_new ()) { } 32 | 33 | bool isConnected (void) 34 | { 35 | return ibus_bus_is_connected (*this); 36 | } 37 | 38 | operator IBusBus * (void) const 39 | { 40 | return get (); 41 | } 42 | }; 43 | 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /src/ZYObject.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_OBJECT_H_ 22 | #define __ZY_OBJECT_H_ 23 | 24 | #include 25 | #include "ZYPointer.h" 26 | 27 | namespace ZY { 28 | 29 | class Object { 30 | protected: 31 | template 32 | Object (T *p) : m_p ((GObject *)p) 33 | { 34 | g_assert (get () != NULL); 35 | } 36 | 37 | operator GObject * (void) const 38 | { 39 | return m_p; 40 | } 41 | 42 | template 43 | T * get (void) const 44 | { 45 | return (T *) (GObject *) m_p; 46 | } 47 | 48 | private: 49 | Pointer m_p; 50 | }; 51 | 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /setup/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | # 5 | # Copyright (c) 2014 Peng Wu 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2, or (at your option) 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | 21 | setup_libzhuyin_PYTHON = \ 22 | main.py \ 23 | config.py \ 24 | ibus-libzhuyin-preferences.ui \ 25 | $(NULL) 26 | 27 | setup_libzhuyindir = $(datadir)/ibus-libzhuyin/setup 28 | 29 | libexec_SCRIPTS = \ 30 | ibus-setup-libzhuyin \ 31 | $(NULL) 32 | 33 | CLEANFILES = \ 34 | *.pyc \ 35 | $(NULL) 36 | 37 | EXTRA_DIST = \ 38 | config.py.in \ 39 | ibus-setup-libzhuyin.in \ 40 | $(NULL) 41 | 42 | 43 | test-libzhuyin: 44 | $(ENV) DBUS_DEBUG=true \ 45 | IBUS_LOCALEDIR=@localedir@ \ 46 | IBUS_PKGDATADIR=$(pkgdatadir) \ 47 | PYTHONPATH=$(abs_top_srcdir):$(pyexecdir) \ 48 | $(PYTHON) $(srcdir)/main.py 49 | 50 | -------------------------------------------------------------------------------- /src/ZYZEnhancedEditor.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_ENHANCED_EDITOR_H_ 23 | #define __ZY_LIB_ZHUYIN_ENHANCED_EDITOR_H_ 24 | 25 | #include 26 | #include "ZYLookupTable.h" 27 | #include "ZYEditor.h" 28 | 29 | namespace ZY { 30 | 31 | class EnhancedEditor : public Editor { 32 | /** 33 | * enhance the editor logicics to support enhanced text format. 34 | */ 35 | public: 36 | EnhancedEditor (ZhuyinProperties & prop, Config & config); 37 | virtual ~EnhancedEditor (void); 38 | 39 | virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); 40 | virtual void update (void); 41 | virtual void reset (void); 42 | }; 43 | 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/ZYSymbolLookup.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_SYMBOL_LOOKUP_H_ 23 | #define __ZY_SYMBOL_LOOKUP_H_ 24 | 25 | #include "ZYString.h" 26 | #include 27 | #include 28 | 29 | namespace ZY { 30 | 31 | class SymbolLookup { 32 | private: 33 | typedef std::vector symbol_vec_t; 34 | 35 | public: 36 | SymbolLookup () {} 37 | virtual ~SymbolLookup () {} 38 | 39 | gboolean loadFromFile (const char * filename); 40 | 41 | String find(const String index); 42 | const std::vector & getIndexes() { return m_indexes; } 43 | 44 | void dumpInfo (); 45 | protected: 46 | symbol_vec_t m_indexes; 47 | symbol_vec_t m_symbols; 48 | }; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/ZYSymbols.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_SYMBOLS_H_ 23 | #define __ZY_SYMBOLS_H_ 24 | 25 | #include "ZYString.h" 26 | #include 27 | 28 | namespace ZY { 29 | 30 | bool 31 | is_easy_symbol(const gint key); 32 | 33 | int 34 | find_lookup_key (const String & symbol); 35 | 36 | int 37 | get_choice_list (const gint key, gchar ** & choices); 38 | 39 | bool 40 | is_special_symbol (const gint key); 41 | 42 | bool 43 | convert_special_symbol (const gint key, String & punct); 44 | 45 | bool 46 | is_full_width_symbol (const gint key); 47 | 48 | bool 49 | convert_full_width_symbol (const gint key, String & english); 50 | 51 | #define BUILTIN_SYMBOL_TYPE "builtin" 52 | #define BOPOMOFO_SYMBOL_TYPE "bopomofo" 53 | 54 | 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /ibus-libzhuyin.spec.in: -------------------------------------------------------------------------------- 1 | Name: @PACKAGE_NAME@ 2 | Version: @PACKAGE_VERSION@ 3 | Release: 1%{?dist} 4 | Summary: New Zhuyin engine based on libzhuyin for IBus 5 | License: GPLv2+ 6 | Group: System Environment/Libraries 7 | URL: https://github.com/libzhuyin/ibus-libzhuyin 8 | Source0: http://downloads.sourceforge.net/libzhuyin/ibus-libzhuyin/%{name}-%{version}.tar.gz 9 | 10 | BuildRequires: gettext-devel 11 | BuildRequires: libtool 12 | BuildRequires: pkgconfig 13 | BuildRequires: sqlite-devel 14 | BuildRequires: opencc-devel 15 | BuildRequires: ibus-devel >= 1.3 16 | BuildRequires: libpinyin-devel >= 2.0.91 17 | 18 | # Requires(post): sqlite 19 | 20 | Requires: ibus >= 1.3.0 21 | 22 | %description 23 | It includes a Chinese Zhuyin (Bopomofo) input method based on libzhuyin for IBus. 24 | 25 | %prep 26 | %setup -q 27 | 28 | %build 29 | %configure --disable-static \ 30 | --enable-opencc \ 31 | --disable-boost 32 | 33 | # make -C po update-gmo 34 | make %{?_smp_mflags} 35 | 36 | %install 37 | rm -rf $RPM_BUILD_ROOT 38 | make DESTDIR=${RPM_BUILD_ROOT} install 39 | 40 | %find_lang %{name} 41 | 42 | %clean 43 | rm -rf $RPM_BUILD_ROOT 44 | 45 | %files -f %{name}.lang 46 | %defattr(-,root,root,-) 47 | %doc AUTHORS COPYING README 48 | %{_libexecdir}/ibus-engine-libzhuyin 49 | %{_libexecdir}/ibus-setup-libzhuyin 50 | %{_datadir}/@PACKAGE@/phrases.txt 51 | %{_datadir}/@PACKAGE@/icons 52 | %{_datadir}/@PACKAGE@/setup 53 | %dir %{_datadir}/@PACKAGE@ 54 | %dir %{_datadir}/@PACKAGE@/db 55 | %{_datadir}/ibus/component/* 56 | %{_libdir}/ibus-libzhuyin/ 57 | 58 | %changelog 59 | * Fri Jun 01 2012 Peng Wu - @VERSION@-1 60 | - The first version. 61 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | version 1.10.4 2 | * bug fixes 3 | 4 | version 1.10.3 5 | * bug fixes 6 | 7 | version 1.10.2 8 | * bug fixes 9 | 10 | version 1.10.1 11 | * fix setup dialog 12 | 13 | version 1.10.0 14 | * bug fixes 15 | 16 | version 1.9.92 17 | * update zhuyin data 18 | 19 | version 1.9.91 20 | * support libpinyin 2.4.92 21 | 22 | version 1.9.1 23 | * fixes page up and page down shortcut key 24 | * fixes special symbols 25 | * fixes escape handling 26 | * fixes numpad 27 | 28 | version 1.9.0 29 | * fixes special symbol 30 | * add need-tone option 31 | 32 | version 1.8.93 33 | * fixes Space handling 34 | 35 | version 1.8.92 36 | * fixes easy symbol and user symbol 37 | 38 | version 1.8.91 39 | * migrate to use GSettings 40 | 41 | version 1.8.3 42 | * translate input method name in ibus menu 43 | 44 | version 1.8.2 45 | * fixes cursor move 46 | 47 | version 1.8.1 48 | * fixes application shortcut issue 49 | * fixes numpad issue 50 | 51 | version 1.8.0 52 | * bump version 53 | 54 | version 1.7.91 55 | * merge libzhuyin data 56 | 57 | version 1.7.10 58 | * fix issue 33 - fixes full/half width symbol input problem 59 | 60 | version 1.7.9 61 | * fix issue 31 - full width punctuation input with wrong symbol 62 | * fix issue 32 - full/half width shortcut key switch with extra space output 63 | 64 | version 1.7.8 65 | * combine English/Punctuation modes into one mode. 66 | 67 | version 1.7.7 68 | * bug fixes. 69 | * update translations. 70 | 71 | version 1.7.4 72 | * add option - "Use Space Key to Show Candidates". 73 | * add option - "Show Candidates After the Cursor". 74 | * use zhuyin_valid_zhuyin_keys method. 75 | 76 | version 1.7.1 77 | * migrate setup dialog to python 3.x. 78 | * support gnome-software. 79 | 80 | version 1.7.0 81 | * the first release of 1.7.x series. 82 | -------------------------------------------------------------------------------- /src/ZYZBuiltinSymbolSection.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_BUILTIN_SYMBOL_SECTION_H_ 23 | #define __ZY_LIB_ZHUYIN_BUILTIN_SYMBOL_SECTION_H_ 24 | 25 | #include "ZYZSymbolSection.h" 26 | #include 27 | 28 | namespace ZY { 29 | 30 | class ZhuyinProperties; 31 | 32 | class BuiltinSymbolSection : public SymbolSection { 33 | typedef std::vector::iterator iterator_t; 34 | 35 | public: 36 | BuiltinSymbolSection (PhoneticEditor & editor, 37 | ZhuyinProperties & props); 38 | virtual ~BuiltinSymbolSection (); 39 | 40 | public: 41 | virtual bool initCandidates (zhuyin_instance_t * instance, 42 | const String & lookup); 43 | virtual bool fillLookupTableByPage (); 44 | virtual int selectCandidate (guint index); 45 | 46 | protected: 47 | std::vector m_candidates; 48 | }; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/ZYZBopomofoSymbolSection.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_BOPOMOFO_SYMBOL_SECTION_H_ 23 | #define __ZY_LIB_ZHUYIN_BOPOMOFO_SYMBOL_SECTION_H_ 24 | 25 | #include "ZYZSymbolSection.h" 26 | #include 27 | 28 | namespace ZY { 29 | 30 | class ZhuyinProperties; 31 | 32 | class BopomofoSymbolSection : public SymbolSection { 33 | typedef std::vector::iterator iterator_t; 34 | 35 | public: 36 | BopomofoSymbolSection (PhoneticEditor & editor, 37 | ZhuyinProperties & props); 38 | virtual ~BopomofoSymbolSection (); 39 | 40 | public: 41 | virtual bool initCandidates (zhuyin_instance_t * instance, 42 | const String & lookup); 43 | virtual bool fillLookupTableByPage (); 44 | virtual int selectCandidate (guint index); 45 | 46 | protected: 47 | std::vector m_candidates; 48 | }; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/ZYZUserSymbolShownSection.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_USER_SYMBOL_SHOWN_SECTION_H_ 23 | #define __ZY_LIB_ZHUYIN_USER_SYMBOL_SHOWN_SECTION_H_ 24 | 25 | #include "ZYZSymbolSection.h" 26 | #include 27 | 28 | namespace ZY { 29 | 30 | class ZhuyinProperties; 31 | 32 | class UserSymbolShownSection: public SymbolSection { 33 | typedef std::vector::iterator iterator_t; 34 | 35 | public: 36 | UserSymbolShownSection (PhoneticEditor & editor, 37 | ZhuyinProperties & props); 38 | virtual ~UserSymbolShownSection (); 39 | 40 | public: 41 | virtual bool initCandidates (zhuyin_instance_t * instance, 42 | const String & lookup); 43 | virtual bool fillLookupTableByPage (); 44 | virtual int selectCandidate (guint index); 45 | 46 | protected: 47 | std::vector m_candidates; 48 | }; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/ZYZPhoneticSection.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_PHONETIC_SECTION_H_ 23 | #define __ZY_LIB_ZHUYIN_PHONETIC_SECTION_H_ 24 | 25 | #include 26 | #include "ZYString.h" 27 | #include "ZYZPhoneticEditor.h" 28 | 29 | namespace ZY { 30 | 31 | class PhoneticSection { 32 | public: 33 | PhoneticSection (PhoneticEditor & editor, ZhuyinProperties & props); 34 | virtual ~PhoneticSection (); 35 | 36 | public: 37 | virtual bool initCandidates (zhuyin_instance_t * instance, 38 | int cursor); 39 | virtual bool fillLookupTableByPage (); 40 | virtual int selectCandidate (guint index); 41 | 42 | protected: 43 | LookupTable & getLookupTable () { return m_editor.m_lookup_table; } 44 | 45 | protected: 46 | PhoneticEditor & m_editor; 47 | ZhuyinProperties & m_props; 48 | 49 | /* other variables. */ 50 | zhuyin_instance_t * m_instance; 51 | int m_cursor; 52 | }; 53 | 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/ZYZPinyinEditor.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_PINYIN_EDITOR_H_ 23 | #define __ZY_LIB_ZHUYIN_PINYIN_EDITOR_H_ 24 | 25 | #include "ZYZPhoneticEditor.h" 26 | 27 | namespace ZY { 28 | 29 | class Config; 30 | 31 | class PinyinEditor : public PhoneticEditor { 32 | using PhoneticEditor::InputState; 33 | 34 | public: 35 | PinyinEditor (ZhuyinProperties & props, Config & config); 36 | virtual ~PinyinEditor (void); 37 | 38 | protected: 39 | gboolean processSpace (guint keyval, guint keycode, guint modifiers); 40 | gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); 41 | 42 | virtual void updatePreeditText (); 43 | virtual void updateAuxiliaryText (); 44 | virtual void updateZhuyin (void); 45 | 46 | void commit (); 47 | void reset (); 48 | 49 | gboolean insert (guint keyval, guint keycode, guint modifiers); 50 | 51 | protected: 52 | String m_preedit_text; 53 | }; 54 | 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/ZYZZhuyinEditor.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_ZHUYIN_EDITOR_H_ 23 | #define __ZY_LIB_ZHUYIN_ZHUYIN_EDITOR_H_ 24 | 25 | #include "ZYZPhoneticEditor.h" 26 | 27 | namespace ZY { 28 | 29 | class Config; 30 | 31 | class ZhuyinEditor : public PhoneticEditor { 32 | using PhoneticEditor::InputState; 33 | 34 | public: 35 | ZhuyinEditor (ZhuyinProperties & props, Config & config); 36 | virtual ~ZhuyinEditor (void); 37 | 38 | protected: 39 | gboolean processSpace (guint keyval, guint keycode, guint modifiers); 40 | gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); 41 | 42 | virtual void updatePreeditText (); 43 | virtual void updateAuxiliaryText (); 44 | virtual void updateZhuyin (void); 45 | 46 | void commit (); 47 | void reset (); 48 | 49 | gboolean insert (guint keyval, guint keycode, guint modifiers); 50 | 51 | protected: 52 | String m_preedit_text; 53 | }; 54 | 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/ZYZUserSymbolListAllSection.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_USER_SYMBOL_LIST_ALL_SECTION_H_ 23 | #define __ZY_LIB_ZHUYIN_USER_SYMBOL_LIST_ALL_SECTION_H_ 24 | 25 | #include "ZYZSymbolSection.h" 26 | #include 27 | #include "ZYSymbolLookup.h" 28 | 29 | namespace ZY { 30 | 31 | class ZhuyinProperties; 32 | 33 | class UserSymbolListAllSection : public SymbolSection { 34 | typedef std::vector::iterator iterator_t; 35 | 36 | public: 37 | UserSymbolListAllSection (PhoneticEditor & editor, 38 | ZhuyinProperties & props); 39 | virtual ~UserSymbolListAllSection (); 40 | 41 | public: 42 | virtual bool initCandidates (zhuyin_instance_t * instance, 43 | const String & lookup); 44 | virtual bool fillLookupTableByPage (); 45 | virtual int selectCandidate (guint index); 46 | 47 | protected: 48 | gboolean loadUserSymbolFile (const gchar * filename); 49 | 50 | std::vector m_candidates; 51 | SymbolLookup m_user_symbols; 52 | }; 53 | 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/ZYZConfig.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_ZHUYIN_CONFIG_H_ 23 | #define __ZY_LIB_ZHUYIN_ZHUYIN_CONFIG_H_ 24 | 25 | #ifdef HAVE_CONFIG_H 26 | # include 27 | #endif 28 | 29 | #include 30 | #include 31 | #include "ZYConfig.h" 32 | 33 | namespace ZY { 34 | 35 | class ZhuyinConfig : public Config { 36 | public: 37 | static void init (); 38 | static ZhuyinConfig & instance (void) { return *m_instance; } 39 | 40 | protected: 41 | ZhuyinConfig (); 42 | 43 | public: 44 | virtual ~ZhuyinConfig (void); 45 | 46 | protected: 47 | void initDefaultValues (void); 48 | 49 | virtual void readDefaultValues (void); 50 | virtual gboolean valueChanged (const std::string &schema_id, 51 | const std::string &name, 52 | GVariant *value); 53 | private: 54 | static void valueChangedCallback (GSettings *settings, 55 | const gchar *name, 56 | ZhuyinConfig *self); 57 | 58 | private: 59 | static std::unique_ptr m_instance; 60 | }; 61 | 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /scripts/update-tradsimp-table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | sys.path.append(".") 4 | 5 | from ZhConversion import * 6 | from valid_hanzi import * 7 | 8 | def convert(s, d, n): 9 | out = "" 10 | end = len(s) 11 | begin = 0 12 | while begin < end: 13 | for i in range(min(n, end - begin), 0, -1): 14 | t = s[begin:begin+i] 15 | t = d.get(t, t if i == 1 else None) 16 | if t: 17 | break 18 | out = out + t 19 | begin += i 20 | return out 21 | 22 | def filter_more(records, n): 23 | han = [(k, v) for (k, v) in records if len(k) <= 0] 24 | hand = dict(han) 25 | hanm = [(k, v) for (k, v) in records if convert(k, hand, n) != v] 26 | return hanm + han 27 | 28 | def filter_func(args): 29 | k, v = args 30 | # length is not equal or length > 6 31 | if len(k) != len(v) or len(k) > 6: 32 | return False 33 | # k includes invalid hanzi 34 | if not all(c in valid_hanzi for c in k): 35 | return False 36 | # v includes invalid hanzi 37 | if not all(c in valid_hanzi for c in v): 38 | return False 39 | 40 | # # check chars in k and v 41 | # for c1, c2 in zip(k, v): 42 | # if c1 == c2: 43 | # continue 44 | # if c2 not in S_2_T.get(c1, []): 45 | # return False 46 | return True 47 | 48 | def get_records(): 49 | records = list(zh2Hans.items()) 50 | 51 | records = list(filter(filter_func, records)) 52 | 53 | maxlen = max([len(k) for (k, v) in records]) 54 | for i in range(1, maxlen - 1): 55 | records = filter_more(records, i) 56 | records = [(k.encode("utf8"), v.encode("utf8")) for (k, v) in records] 57 | records.sort() 58 | return maxlen, records 59 | 60 | def main(): 61 | print("static const gchar *trad_to_simp[][2] = {") 62 | maxlen, records = get_records() 63 | for s, ts in records: 64 | print(' { "%s", "%s" },' % (s, ts)) 65 | print("};") 66 | print('#define TRAD_TO_SIMP_MAX_LEN (%d)' % maxlen) 67 | 68 | if __name__ == "__main__": 69 | main() 70 | -------------------------------------------------------------------------------- /data/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | # 5 | # Copyright (c) 2014 Peng Wu 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2, or (at your option) 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | 21 | 22 | APPDATA_XML = libzhuyin.appdata.xml 23 | 24 | gsettings_SCHEMAS = com.github.libzhuyin.ibus-libzhuyin.gschema.xml 25 | 26 | @GSETTINGS_RULES@ 27 | 28 | SUBDIRS = \ 29 | icons \ 30 | model \ 31 | $(NULL) 32 | 33 | appdatadir = @datadir@/metainfo 34 | 35 | appdata_DATA = $(APPDATA_XML) 36 | 37 | desktop_in_files = \ 38 | ibus-setup-libzhuyin.desktop.in \ 39 | $(NULL) 40 | 41 | desktop_files = $(desktop_in_files:.desktop.in=.desktop) 42 | 43 | %.desktop: %.desktop.in 44 | $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@.tmp 45 | sed -e 's|@libexecdir[@]|$(libexecdir)|g' \ 46 | -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' $@.tmp > $@ 47 | rm $@.tmp 48 | 49 | desktopdir=$(datadir)/applications 50 | desktop_DATA = $(desktop_files) 51 | 52 | symbols_DATA = \ 53 | easysymbol.txt \ 54 | usersymbol.txt \ 55 | $(NULL) 56 | 57 | symbolsdir = $(pkgdatadir) 58 | 59 | EXTRA_DIST = \ 60 | $(desktop_in_files) \ 61 | $(symbols_DATA) \ 62 | $(APPDATA_XML) \ 63 | $(gsettings_SCHEMAS) \ 64 | $(NULL) 65 | 66 | DISTCLEANFILES = \ 67 | $(desktop_files) \ 68 | $(desktop_DATA) \ 69 | $(NULL) 70 | -------------------------------------------------------------------------------- /src/ZYZSymbolSection.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_SYMBOL_SECTION_H_ 23 | #define __ZY_LIB_ZHUYIN_SYMBOL_SECTION_H_ 24 | 25 | #include "ZYString.h" 26 | #include "ZYZPhoneticEditor.h" 27 | #include 28 | 29 | namespace ZY { 30 | 31 | class ZhuyinProperties; 32 | 33 | class SymbolSection { 34 | public: 35 | SymbolSection (PhoneticEditor & editor, ZhuyinProperties & props) : 36 | m_editor (editor), m_props(props) {} 37 | virtual ~SymbolSection () {} 38 | 39 | public: 40 | virtual bool initCandidates (zhuyin_instance_t * instance, 41 | const String & hint) = 0; 42 | virtual bool fillLookupTableByPage () = 0; 43 | virtual int selectCandidate (guint index) = 0; 44 | 45 | public: 46 | String getType () {return m_type; } 47 | String getLookup () {return m_lookup; } 48 | String getChoice () {return m_choice; } 49 | 50 | protected: 51 | LookupTable & getLookupTable () { return m_editor.m_lookup_table; } 52 | 53 | protected: 54 | PhoneticEditor & m_editor; 55 | ZhuyinProperties & m_props; 56 | 57 | /* other variables. */ 58 | String m_type; 59 | String m_lookup; 60 | String m_choice; 61 | }; 62 | 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /data/model/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Process this file with automake to produce Makefile.in 2 | ## Copyright (C) 2011 Peng Wu 3 | ## 4 | ## This program is free software; you can redistribute it and/or modify 5 | ## it under the terms of the GNU General Public License as published by 6 | ## the Free Software Foundation; either version 2, or (at your option) 7 | ## any later version. 8 | ## 9 | ## This program is distributed in the hope that it will be useful, 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ## GNU General Public License for more details. 13 | ## 14 | ## You should have received a copy of the GNU General Public License 15 | ## along with this program; if not, write to the Free Software 16 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | 19 | tablefiles = tsi.table 20 | 21 | binfiles = ${tablefiles:.table=.bin} 22 | 23 | 24 | textual_model_data = interpolation2.text \ 25 | $(tablefiles) 26 | 27 | 28 | binary_model_data = phrase_index.bin pinyin_index.bin \ 29 | addon_phrase_index.bin addon_pinyin_index.bin \ 30 | bigram.db \ 31 | $(binfiles) 32 | 33 | 34 | MAINTAINERCLEANFILES = Makefile.in 35 | 36 | EXTRA_DIST = $(textual_model_data) \ 37 | table.conf.in 38 | 39 | model_db_DATA = $(binary_model_data) \ 40 | table.conf 41 | 42 | model_dbdir = $(libdir)/ibus-libzhuyin/data 43 | 44 | CLEANFILES = $(binary_model_data) 45 | 46 | interpolation2.text: 47 | wget http://downloads.sourceforge.net/libzhuyin/models/model13.text.tar.gz 48 | tar xvf model13.text.tar.gz -C $(top_srcdir)/data/model 49 | 50 | 51 | $(tablefiles) table.conf: interpolation2.text 52 | 53 | bigram.db: $(textual_model_data) 54 | $(RM) $(binary_model_data) 55 | gen_binary_files --table-dir $(top_srcdir)/data/model 56 | import_interpolation --table-dir $(top_srcdir)/data/model < $(top_srcdir)/data/model/interpolation2.text 57 | gen_unigram --table-dir $(top_srcdir)/data/model 58 | 59 | addon_phrase_index.bin addon_pinyin_index.bin phrase_index.bin pinyin_index.bin $(binfiles): bigram.db 60 | -------------------------------------------------------------------------------- /src/ZYPointer.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_POINTER_H_ 22 | #define __ZY_POINTER_H_ 23 | 24 | #include 25 | 26 | namespace ZY { 27 | 28 | template 29 | struct Pointer { 30 | public: 31 | Pointer (T *p = NULL) : m_p (NULL) 32 | { 33 | set (p); 34 | } 35 | 36 | ~Pointer (void) 37 | { 38 | set (NULL); 39 | } 40 | 41 | void set (T * p) 42 | { 43 | if (m_p) { 44 | g_object_unref (m_p); 45 | } 46 | 47 | m_p = p; 48 | if (p) { 49 | #if 0 50 | g_debug ("%s, floating = %d",G_OBJECT_TYPE_NAME (p), g_object_is_floating (p)); 51 | #endif 52 | g_object_ref_sink (p); 53 | } 54 | } 55 | 56 | Pointer &operator = (T *p) 57 | { 58 | set (p); 59 | return *this; 60 | } 61 | 62 | Pointer &operator = (const Pointer & p) 63 | { 64 | set (p.m_p); 65 | return *this; 66 | } 67 | 68 | const T * operator-> (void) const 69 | { 70 | return m_p; 71 | } 72 | 73 | T * operator-> (void) 74 | { 75 | return m_p; 76 | } 77 | 78 | operator T * (void) const 79 | { 80 | return m_p; 81 | } 82 | 83 | operator gboolean (void) const 84 | { 85 | return m_p != NULL; 86 | } 87 | 88 | private: 89 | T *m_p; 90 | }; 91 | 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /m4/as-version.m4: -------------------------------------------------------------------------------- 1 | dnl as-version.m4 0.2.0 2 | 3 | dnl autostars m4 macro for versioning 4 | 5 | dnl Thomas Vander Stichele 6 | 7 | dnl $Id: as-version.m4,v 1.4 2004/06/01 09:40:05 thomasvs Exp $ 8 | 9 | dnl AS_VERSION 10 | 11 | dnl example 12 | dnl AS_VERSION 13 | 14 | dnl this macro 15 | dnl - AC_SUBST's PACKAGE_VERSION_MAJOR, _MINOR, _MICRO 16 | dnl - AC_SUBST's PACKAGE_VERSION_RELEASE, 17 | dnl which can be used for rpm release fields 18 | dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents 19 | dnl maintainer mode from running correctly 20 | dnl 21 | dnl don't forget to put #undef PACKAGE_VERSION_RELEASE in acconfig.h 22 | dnl if you use acconfig.h 23 | 24 | AC_DEFUN([AS_VERSION], 25 | [ 26 | PACKAGE_VERSION_MAJOR=$(echo AC_PACKAGE_VERSION | cut -d'.' -f1) 27 | PACKAGE_VERSION_MINOR=$(echo AC_PACKAGE_VERSION | cut -d'.' -f2) 28 | PACKAGE_VERSION_MICRO=$(echo AC_PACKAGE_VERSION | cut -d'.' -f3) 29 | 30 | AC_SUBST(PACKAGE_VERSION_MAJOR) 31 | AC_SUBST(PACKAGE_VERSION_MINOR) 32 | AC_SUBST(PACKAGE_VERSION_MICRO) 33 | ]) 34 | 35 | dnl AS_NANO(ACTION-IF-NO-NANO, [ACTION-IF-NANO]) 36 | 37 | dnl requires AC_INIT to be called before 38 | dnl For projects using a fourth or nano number in your versioning to indicate 39 | dnl development or prerelease snapshots, this macro allows the build to be 40 | dnl set up differently accordingly. 41 | 42 | dnl this macro: 43 | dnl - parses AC_PACKAGE_VERSION, set by AC_INIT, and extracts the nano number 44 | dnl - sets the variable PACKAGE_VERSION_NANO 45 | dnl - sets the variable PACKAGE_VERSION_RELEASE, which can be used 46 | dnl for rpm release fields 47 | dnl - executes ACTION-IF-NO-NANO or ACTION-IF-NANO 48 | 49 | dnl example: 50 | dnl AS_NANO(RELEASE="yes", RELEASE="no") 51 | 52 | AC_DEFUN([AS_NANO], 53 | [ 54 | AC_MSG_CHECKING(nano version) 55 | 56 | NANO=$(echo AC_PACKAGE_VERSION | cut -d'.' -f4) 57 | 58 | if test x"$NANO" = x || test "x$NANO" = "x0" ; then 59 | AC_MSG_RESULT([0 (release)]) 60 | NANO=0 61 | PACKAGE_VERSION_RELEASE=1 62 | ifelse([$1], , :, [$1]) 63 | else 64 | AC_MSG_RESULT($NANO) 65 | PACKAGE_VERSION_RELEASE=0.`date +%Y%m%d.%H%M%S` 66 | ifelse([$2], , :, [$2]) 67 | fi 68 | PACKAGE_VERSION_NANO=$NANO 69 | AC_SUBST(PACKAGE_VERSION_NANO) 70 | AC_SUBST(PACKAGE_VERSION_RELEASE) 71 | ]) 72 | -------------------------------------------------------------------------------- /src/ZYLibZhuyin.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_H_ 23 | #define __ZY_LIB_ZHUYIN_H_ 24 | 25 | #include 26 | #include 27 | 28 | typedef struct _zhuyin_context_t zhuyin_context_t; 29 | typedef struct _zhuyin_instance_t zhuyin_instance_t; 30 | 31 | namespace ZY { 32 | 33 | class Config; 34 | 35 | class LibZhuyinBackEnd { 36 | 37 | public: 38 | LibZhuyinBackEnd (); 39 | virtual ~LibZhuyinBackEnd (); 40 | 41 | gboolean setZhuyinOptions (Config *config); 42 | 43 | zhuyin_context_t * initZhuyinContext (Config *config); 44 | 45 | zhuyin_instance_t *allocZhuyinInstance (); 46 | void freeZhuyinInstance (zhuyin_instance_t *instance); 47 | 48 | void modified (void); 49 | 50 | gboolean importZhuyinDictionary (const char * filename); 51 | gboolean clearZhuyinUserData (const char * target); 52 | 53 | /* use static initializer in C++. */ 54 | static LibZhuyinBackEnd & instance (void) { return *m_instance; } 55 | 56 | static void init (void); 57 | static void finalize (void); 58 | 59 | private: 60 | gboolean saveUserDB (void); 61 | static gboolean timeoutCallback (gpointer data); 62 | 63 | private: 64 | /* libzhuyin context */ 65 | zhuyin_context_t *m_zhuyin_context; 66 | 67 | guint m_timeout_id; 68 | GTimer *m_timer; 69 | 70 | private: 71 | static std::unique_ptr m_instance; 72 | }; 73 | 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/ZYFallbackEditor.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_FALLBACK_EDITOR_ 22 | #define __ZY_FALLBACK_EDITOR_ 23 | 24 | #include "ZYText.h" 25 | #include "ZYEditor.h" 26 | 27 | namespace ZY { 28 | 29 | class FallbackEditor : public Editor { 30 | public: 31 | FallbackEditor (ZhuyinProperties &props, Config & config) 32 | : Editor (props, config), 33 | m_quote (TRUE), 34 | m_double_quote (TRUE), 35 | m_prev_committed_char (0) { } 36 | 37 | gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); 38 | void reset (void); 39 | 40 | void setPrevCommittedChar (gunichar ch) 41 | { 42 | m_prev_committed_char = ch; 43 | } 44 | 45 | private: 46 | void commit (gchar ch) 47 | { 48 | gchar str[2] = {ch, 0}; 49 | StaticText text (str); 50 | commitText (text); 51 | } 52 | 53 | void commit (gunichar ch) 54 | { 55 | Text text (ch); 56 | commitText (text); 57 | } 58 | 59 | void commit (const gchar *str) 60 | { 61 | StaticText text (str); 62 | commitText (text); 63 | } 64 | 65 | void commit (const String &str) 66 | { 67 | commit ((const gchar *)str); 68 | } 69 | 70 | gboolean processSymbol (guint keyval, guint keycode, guint modifiers); 71 | 72 | private: 73 | gboolean m_quote; 74 | gboolean m_double_quote; 75 | gunichar m_prev_committed_char; 76 | 77 | }; 78 | 79 | }; 80 | #endif 81 | -------------------------------------------------------------------------------- /src/ZYText.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_TEXT_H_ 22 | #define __ZY_TEXT_H_ 23 | 24 | #include 25 | #include 26 | #include "ZYObject.h" 27 | 28 | namespace ZY { 29 | 30 | class Text : Object { 31 | public: 32 | Text (IBusText *text) 33 | : Object (text) { } 34 | Text (const gchar *str) 35 | : Object (ibus_text_new_from_string (str)) { } 36 | 37 | Text (const std::string & str) 38 | : Object (ibus_text_new_from_string (str.c_str ())) { } 39 | 40 | Text (gunichar ch) 41 | : Object (ibus_text_new_from_unichar (ch)) { } 42 | 43 | void appendAttribute (guint type, guint value, guint start, guint end) 44 | { 45 | ibus_text_append_attribute (get (), type, value, start, end); 46 | } 47 | 48 | const gchar *text (void) const 49 | { 50 | return get ()->text; 51 | } 52 | 53 | operator IBusText * (void) const 54 | { 55 | return get (); 56 | } 57 | }; 58 | 59 | class StaticText : public Text { 60 | public: 61 | StaticText (const gchar *str) 62 | : Text (ibus_text_new_from_static_string (str)) { } 63 | 64 | StaticText (const std::string & str) 65 | : Text (ibus_text_new_from_static_string (str.c_str ())) { } 66 | 67 | StaticText (gunichar ch) 68 | : Text (ch) { } 69 | 70 | operator IBusText * (void) const 71 | { 72 | return Text::operator IBusText * (); 73 | } 74 | }; 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/ZYZZhuyinEngine.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * Copyright (c) 2011 Peng Wu 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | #ifndef __ZY_LIB_ZHUYIN_ZHUYIN_ENGINE_H_ 23 | #define __ZY_LIB_ZHUYIN_ZHUYIN_ENGINE_H_ 24 | 25 | #include 26 | #include "ZYEngine.h" 27 | #include "ZYZhuyinProperties.h" 28 | 29 | namespace ZY { 30 | class ZhuyinEngine : public Engine { 31 | public: 32 | ZhuyinEngine (IBusEngine *engine); 33 | ~ZhuyinEngine (void); 34 | 35 | //virtual functions 36 | gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); 37 | void focusIn (void); 38 | void focusOut (void); 39 | void reset (void); 40 | void enable (void); 41 | void disable (void); 42 | void pageUp (void); 43 | void pageDown (void); 44 | void cursorUp (void); 45 | void cursorDown (void); 46 | gboolean propertyActivate (const gchar *prop_name, guint prop_state); 47 | void candidateClicked (guint index, guint button, guint state); 48 | 49 | private: 50 | void showSetupDialog (void); 51 | void connectEditorSignals (EditorPtr editor); 52 | 53 | void commitText (Text & text); 54 | 55 | private: 56 | ZhuyinProperties m_props; 57 | 58 | guint m_prev_pressed_key; 59 | 60 | enum { 61 | MODE_INIT = 0, // init mode 62 | MODE_RAW, // raw mode 63 | MODE_LAST, 64 | } m_input_mode; 65 | 66 | gboolean m_is_zhuyin; 67 | 68 | EditorPtr m_editors[MODE_LAST]; 69 | EditorPtr m_fallback_editor; 70 | 71 | }; 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/ZYZhuyinProperties.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_ZHUYIN_PROPERTIES_H_ 22 | #define __ZY_ZHUYIN_PROPERTIES_H_ 23 | 24 | #include "ZYSignal.h" 25 | #include "ZYProperty.h" 26 | 27 | namespace ZY { 28 | 29 | class Config; 30 | 31 | class ZhuyinProperties { 32 | public: 33 | ZhuyinProperties (Config & config); 34 | 35 | void toggleModeChinese (void); 36 | void toggleModeFullWidth (void); 37 | void toggleModeTrad (void); 38 | 39 | void reset (void); 40 | 41 | gboolean modeChinese (void) const { return m_mode_chinese; } 42 | gboolean modeFullWidth (void) const { return m_mode_full_width; } 43 | gboolean modeTrad (void) const { return m_mode_trad; } 44 | 45 | PropList & properties (void) { return m_props; } 46 | 47 | gboolean propertyActivate (const gchar *prop_name, guint prop_state); 48 | 49 | signal & signalUpdateProperty (void) 50 | { 51 | return m_signal_update_property; 52 | } 53 | 54 | private: 55 | void updateProperty (Property & prop) const 56 | { 57 | m_signal_update_property (prop); 58 | } 59 | 60 | signal m_signal_update_property; 61 | 62 | private: 63 | Config & m_config; 64 | gboolean m_mode_chinese; 65 | gboolean m_mode_full_width; 66 | gboolean m_mode_trad; 67 | 68 | /* properties */ 69 | Property m_prop_chinese; 70 | Property m_prop_full_width; 71 | Property m_prop_trad; 72 | Property m_prop_setup; 73 | PropList m_props; 74 | }; 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/ZYEnhancedText.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_ENHANCED_TEXT_H_ 23 | #define __ZY_ENHANCED_TEXT_H_ 24 | 25 | #include "ZYString.h" 26 | 27 | namespace ZY{ 28 | 29 | typedef enum { 30 | PHONETIC_SECTION, 31 | SYMBOL_SECTION 32 | } section_t; 33 | 34 | /* all enhanced text should loop from the start to get the correct position. */ 35 | size_t 36 | get_enhanced_text_length (const String & enhanced_text); 37 | 38 | /* offset is for the input offset, 39 | pos is for the actual position in enhanced text. */ 40 | section_t 41 | probe_section (const String & enhanced_text, size_t offset, size_t & pos); 42 | 43 | section_t 44 | probe_section_quick (const String & enhanced_text, size_t pos); 45 | 46 | bool 47 | get_phonetic_section (const String & enhanced_text, 48 | size_t start_pos, size_t & end_pos, String & section); 49 | 50 | /* only one input character here. */ 51 | bool 52 | get_symbol_section (const String & enhanced_text, 53 | size_t start_pos, size_t & end_pos, 54 | String & type, String & lookup, String & choice); 55 | 56 | bool 57 | probe_section_start(const String & enhanced_text, 58 | guint offset, guint & inner_offset, 59 | size_t & index, size_t & start_pos); 60 | 61 | bool 62 | insert_phonetic(String & enhanced_text, size_t offset, const char key); 63 | 64 | bool 65 | insert_symbol(String & enhanced_text, size_t offset, 66 | const String & type, const String & lookup, 67 | const String & choice); 68 | 69 | bool 70 | erase_input_sequence(String & enhanced_text, size_t offset, size_t length); 71 | 72 | size_t 73 | get_number_of_phonetic_sections (String & enhanced_text); 74 | 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/ZYSymbolLookup.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifdef HAVE_CONFIG_H 24 | #include "config.h" 25 | #endif 26 | 27 | #include "ZYSymbolLookup.h" 28 | #include 29 | #include 30 | 31 | namespace ZY { 32 | 33 | gboolean 34 | SymbolLookup::loadFromFile(const char * filename) 35 | { 36 | FILE * symbolfile = fopen (filename, "r"); 37 | if (NULL == symbolfile) 38 | return FALSE; 39 | 40 | char* linebuf = NULL; size_t size = 0; ssize_t read; 41 | while ((read = getline (&linebuf, &size, symbolfile)) != -1) { 42 | if (0 == strlen (linebuf)) 43 | continue; 44 | 45 | if ( '\n' == linebuf[strlen (linebuf) - 1] ) { 46 | linebuf[strlen (linebuf) - 1] = '\0'; 47 | } 48 | 49 | gchar ** items = g_strsplit_set (linebuf, " =", 2); 50 | guint len = g_strv_length (items); 51 | 52 | if (0 == len) 53 | continue; 54 | 55 | String index = items[0]; 56 | /* for symbols.dat, copy display label from symbol. */ 57 | String symbol = index; 58 | if (2 == len) 59 | symbol = items[1]; 60 | 61 | /* just append. */ 62 | m_indexes.push_back (index); 63 | m_symbols.push_back (symbol); 64 | 65 | g_strfreev (items); 66 | } 67 | 68 | return TRUE; 69 | } 70 | 71 | String 72 | SymbolLookup::find (const String index) 73 | { 74 | gboolean found = FALSE; 75 | 76 | size_t i; 77 | for(i = 0; i < m_indexes.size (); ++i) { 78 | if (index == m_indexes[i]) { 79 | found = TRUE; 80 | break; 81 | } 82 | } 83 | 84 | if (found) 85 | return m_symbols[i]; 86 | 87 | return ""; 88 | } 89 | 90 | void 91 | SymbolLookup::dumpInfo () 92 | { 93 | size_t i; 94 | for (i = 0; i < m_indexes.size (); ++i) 95 | printf ("%s %s\n", m_indexes[i].c_str (), m_symbols[i].c_str ()); 96 | } 97 | 98 | }; 99 | -------------------------------------------------------------------------------- /src/ZYZBuiltinSymbolSection.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "ZYZBuiltinSymbolSection.h" 23 | #include 24 | #include "ZYSymbols.h" 25 | 26 | namespace ZY { 27 | 28 | BuiltinSymbolSection::BuiltinSymbolSection (PhoneticEditor & editor, 29 | ZhuyinProperties & props) : 30 | SymbolSection (editor, props) 31 | { 32 | m_type = BUILTIN_SYMBOL_TYPE; 33 | } 34 | 35 | BuiltinSymbolSection::~BuiltinSymbolSection () 36 | { 37 | } 38 | 39 | bool 40 | BuiltinSymbolSection::initCandidates (zhuyin_instance_t * instance, 41 | const String & lookup) 42 | { 43 | if (!lookup) 44 | return false; 45 | 46 | m_candidates.clear (); 47 | 48 | assert (1 == lookup.length ()); 49 | m_lookup = lookup; 50 | 51 | /* cache the choices. */ 52 | gchar ** choices = NULL; 53 | size_t num = get_choice_list (m_lookup[0], choices); 54 | assert (num > 0); 55 | for (size_t i = 0; i < num; ++i) { 56 | m_candidates.push_back (choices[i]); 57 | } 58 | 59 | return true; 60 | } 61 | 62 | bool 63 | BuiltinSymbolSection::fillLookupTableByPage () 64 | { 65 | LookupTable & lookup_table = getLookupTable (); 66 | 67 | guint len = m_candidates.size (); 68 | 69 | guint filled_nr = lookup_table.size (); 70 | guint page_size = lookup_table.pageSize (); 71 | 72 | /* fill lookup table by libzhuyin get candidates. */ 73 | guint need_nr = MIN (page_size, len - filled_nr); 74 | g_assert (need_nr >=0); 75 | if (need_nr == 0) 76 | return FALSE; 77 | 78 | for (guint i = filled_nr; i < filled_nr + need_nr; i++) { 79 | if (i >= len) /* no more candidates */ 80 | break; 81 | 82 | Text text (m_candidates[i]); 83 | lookup_table.appendCandidate (text); 84 | } 85 | 86 | return TRUE; 87 | } 88 | 89 | int 90 | BuiltinSymbolSection::selectCandidate (guint index) 91 | { 92 | if (index >= m_candidates.size ()) 93 | return 0; 94 | 95 | m_choice = m_candidates[index]; 96 | return 1; 97 | } 98 | 99 | }; 100 | -------------------------------------------------------------------------------- /src/ZYZBopomofoSymbolSection.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "ZYZBopomofoSymbolSection.h" 23 | #include 24 | #include 25 | #include "ZYSymbols.h" 26 | 27 | namespace ZY { 28 | 29 | BopomofoSymbolSection::BopomofoSymbolSection (PhoneticEditor & editor, 30 | ZhuyinProperties & props) : 31 | SymbolSection (editor, props) 32 | { 33 | m_type = BOPOMOFO_SYMBOL_TYPE; 34 | } 35 | 36 | BopomofoSymbolSection::~BopomofoSymbolSection () 37 | { 38 | } 39 | 40 | bool 41 | BopomofoSymbolSection::initCandidates (zhuyin_instance_t * instance, 42 | const String & lookup) 43 | { 44 | m_candidates.clear (); 45 | 46 | assert (1 == lookup.length ()); 47 | m_lookup = lookup; 48 | const char key = lookup[0]; 49 | 50 | /* cache the choices. */ 51 | gchar ** symbols = NULL; 52 | check_result (zhuyin_in_chewing_keyboard (instance, key, &symbols)); 53 | size_t num = g_strv_length (symbols); 54 | assert (num > 0); 55 | for (size_t i = 0; i < num; ++i) { 56 | m_candidates.push_back (symbols[i]); 57 | } 58 | g_strfreev (symbols); 59 | 60 | return true; 61 | } 62 | 63 | bool 64 | BopomofoSymbolSection::fillLookupTableByPage () 65 | { 66 | LookupTable & lookup_table = getLookupTable (); 67 | 68 | guint len = m_candidates.size (); 69 | 70 | guint filled_nr = lookup_table.size (); 71 | guint page_size = lookup_table.pageSize (); 72 | 73 | /* fill lookup table by libzhuyin get candidates. */ 74 | guint need_nr = MIN (page_size, len - filled_nr); 75 | g_assert (need_nr >=0); 76 | if (need_nr == 0) 77 | return FALSE; 78 | 79 | for (guint i = filled_nr; i < filled_nr + need_nr; i++) { 80 | if (i >= len) /* no more candidates */ 81 | break; 82 | 83 | Text text (m_candidates[i]); 84 | lookup_table.appendCandidate (text); 85 | } 86 | 87 | return TRUE; 88 | } 89 | 90 | int 91 | BopomofoSymbolSection::selectCandidate (guint index) 92 | { 93 | if (index >= m_candidates.size ()) 94 | return 0; 95 | 96 | m_choice = m_candidates[index]; 97 | return 1; 98 | } 99 | 100 | }; 101 | -------------------------------------------------------------------------------- /src/ZYLookupTable.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_LOOKUP_TABLE_H_ 22 | #define __ZY_LOOKUP_TABLE_H_ 23 | 24 | #include 25 | #include "ZYObject.h" 26 | #include "ZYText.h" 27 | 28 | namespace ZY { 29 | 30 | class LookupTable : Object { 31 | public: 32 | LookupTable (guint page_size = 10, 33 | guint cursor_pos = 0, 34 | gboolean cursor_visible = TRUE, 35 | gboolean round = FALSE) 36 | : Object (ibus_lookup_table_new (page_size, cursor_pos, cursor_visible, round)) { } 37 | 38 | guint pageSize (void) { return ibus_lookup_table_get_page_size (*this); } 39 | guint orientation (void) { return ibus_lookup_table_get_orientation (*this); } 40 | guint cursorPos (void) { return ibus_lookup_table_get_cursor_pos (*this); } 41 | guint size (void) { return ibus_lookup_table_get_number_of_candidates (*this); } 42 | 43 | gboolean pageUp (void) { return ibus_lookup_table_page_up (*this); } 44 | gboolean pageDown (void) { return ibus_lookup_table_page_down (*this); } 45 | gboolean cursorUp (void) { return ibus_lookup_table_cursor_up (*this); } 46 | gboolean cursorDown (void) { return ibus_lookup_table_cursor_down (*this); } 47 | 48 | void setPageSize (guint size) { ibus_lookup_table_set_page_size (*this, size); } 49 | void setCursorPos (guint pos) { ibus_lookup_table_set_cursor_pos (*this, pos); } 50 | void setOrientation (gint orientation) { ibus_lookup_table_set_orientation (*this, orientation); } 51 | void clear (void) { ibus_lookup_table_clear (*this); } 52 | void setCursorVisable (gboolean visable){ ibus_lookup_table_set_cursor_visible (*this, visable); } 53 | void setLabel (guint index, IBusText *text) { ibus_lookup_table_set_label (*this, index, text); } 54 | void appendCandidate (IBusText *text) { ibus_lookup_table_append_candidate (*this, text); } 55 | void appendLabel (IBusText *text) { ibus_lookup_table_append_label (*this, text); } 56 | IBusText * getCandidate(guint index) { return ibus_lookup_table_get_candidate(*this, index); } 57 | 58 | operator IBusLookupTable * (void) const 59 | { 60 | return get (); 61 | } 62 | 63 | }; 64 | 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/ZYZUserSymbolShownSection.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "ZYZUserSymbolShownSection.h" 23 | #include 24 | #include "ZYSymbols.h" 25 | 26 | namespace ZY { 27 | 28 | UserSymbolShownSection::UserSymbolShownSection (PhoneticEditor & editor, 29 | ZhuyinProperties & props) : 30 | SymbolSection (editor, props) 31 | { 32 | m_type = BUILTIN_SYMBOL_TYPE; 33 | } 34 | 35 | UserSymbolShownSection::~UserSymbolShownSection () 36 | { 37 | } 38 | 39 | bool 40 | UserSymbolShownSection::initCandidates (zhuyin_instance_t * instance, 41 | const String & lookup) 42 | { 43 | if (!lookup) 44 | return false; 45 | 46 | m_candidates.clear (); 47 | 48 | m_lookup = lookup; 49 | 50 | /* get the symbols from lookup string. */ 51 | const gchar * str = m_lookup.c_str (); 52 | gboolean valid = g_utf8_validate (str, -1, NULL); 53 | g_return_val_if_fail (valid, false); 54 | 55 | while (*str) { 56 | gunichar unichar = g_utf8_get_char (str); 57 | String utf8ch; 58 | utf8ch.appendUnichar (unichar); 59 | m_candidates.push_back (utf8ch); 60 | str = g_utf8_next_char (str); 61 | } 62 | 63 | return true; 64 | } 65 | 66 | bool 67 | UserSymbolShownSection::fillLookupTableByPage () 68 | { 69 | LookupTable & lookup_table = getLookupTable (); 70 | 71 | guint len = m_candidates.size (); 72 | 73 | guint filled_nr = lookup_table.size (); 74 | guint page_size = lookup_table.pageSize (); 75 | 76 | /* fill lookup table by libzhuyin get candidates. */ 77 | guint need_nr = MIN (page_size, len - filled_nr); 78 | g_assert (need_nr >=0); 79 | if (need_nr == 0) 80 | return FALSE; 81 | 82 | for (guint i = filled_nr; i < filled_nr + need_nr; i++) { 83 | if (i >= len) /* no more candidates */ 84 | break; 85 | 86 | Text text (m_candidates[i]); 87 | lookup_table.appendCandidate (text); 88 | } 89 | 90 | return TRUE; 91 | } 92 | 93 | int 94 | UserSymbolShownSection::selectCandidate (guint index) 95 | { 96 | if (index >= m_candidates.size ()) 97 | return 0; 98 | 99 | m_choice = m_candidates[index]; 100 | assert (1 == m_choice.utf8Length ()); 101 | return 1; 102 | } 103 | 104 | }; 105 | -------------------------------------------------------------------------------- /src/ZYProperty.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_PROPERTY_H_ 22 | #define __ZY_PROPERTY_H_ 23 | 24 | #include 25 | #include "ZYObject.h" 26 | #include "ZYText.h" 27 | 28 | namespace ZY { 29 | 30 | class Property : public Object { 31 | public: 32 | Property (const gchar *key, 33 | IBusPropType type = PROP_TYPE_NORMAL, 34 | IBusText *label = NULL, 35 | const gchar *icon = NULL, 36 | IBusText *tooltip = NULL, 37 | gboolean sensitive = TRUE, 38 | gboolean visible = TRUE, 39 | IBusPropState state = PROP_STATE_UNCHECKED, 40 | IBusPropList *props = NULL) 41 | : Object (ibus_property_new (key, type, label, icon, tooltip, sensitive, visible, state, props)) { } 42 | 43 | void setLabel (IBusText *text) 44 | { 45 | ibus_property_set_label (get (), text); 46 | } 47 | 48 | void setLabel (const gchar *text) 49 | { 50 | setLabel (Text (text)); 51 | } 52 | 53 | void setIcon (const gchar *icon) 54 | { 55 | ibus_property_set_icon (get (), icon); 56 | } 57 | 58 | void setSymbol (IBusText *text) 59 | { 60 | ibus_property_set_symbol (get (), text); 61 | } 62 | 63 | void setSymbol (const gchar *text) 64 | { 65 | setSymbol (Text (text)); 66 | } 67 | 68 | void setSensitive (gboolean sensitive) 69 | { 70 | ibus_property_set_sensitive (get (), sensitive); 71 | } 72 | 73 | void setTooltip (IBusText *text) 74 | { 75 | ibus_property_set_tooltip (get (), text); 76 | } 77 | 78 | void setTooltip (const gchar *text) 79 | { 80 | setTooltip (Text (text)); 81 | } 82 | 83 | operator IBusProperty * (void) const 84 | { 85 | return get (); 86 | } 87 | }; 88 | 89 | 90 | class PropList : Object { 91 | public: 92 | PropList (void) : Object (ibus_prop_list_new ()) { } 93 | 94 | void append (Property &prop) 95 | { 96 | ibus_prop_list_append (get (), prop); 97 | } 98 | 99 | operator IBusPropList * (void) const 100 | { 101 | return get (); 102 | } 103 | }; 104 | 105 | }; 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /src/ZYZEnhancedEditor.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #include "ZYZEnhancedEditor.h" 24 | #include 25 | #include "ZYEnhancedText.h" 26 | 27 | namespace ZY { 28 | 29 | EnhancedEditor::EnhancedEditor (ZhuyinProperties & props, Config & config) 30 | : Editor (props, config) 31 | { 32 | } 33 | 34 | EnhancedEditor::~EnhancedEditor (void) 35 | { 36 | } 37 | 38 | gboolean 39 | EnhancedEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) 40 | { 41 | modifiers &= (IBUS_CONTROL_MASK | 42 | IBUS_MOD1_MASK | 43 | IBUS_SUPER_MASK | 44 | IBUS_HYPER_MASK | 45 | IBUS_META_MASK); 46 | /* ignore key events with some masks */ 47 | if (modifiers != 0) 48 | return TRUE; 49 | 50 | #if 0 51 | if (isPhonetic (keyval)) { 52 | /* zhuyin or pinyin key */ 53 | check_result (insert_phonetic (m_text, m_cursor++, keyval)); 54 | update (); 55 | return TRUE; 56 | } else { 57 | /* control key */ 58 | if (!m_text) 59 | return FALSE; 60 | } 61 | #endif 62 | 63 | switch (keyval) { 64 | case IBUS_BackSpace: 65 | if (m_cursor > 0) { 66 | erase_input_sequence (m_text, --m_cursor, 1); 67 | update (); 68 | } 69 | return TRUE; 70 | case IBUS_Delete: 71 | case IBUS_KP_Delete: 72 | if (m_cursor < get_enhanced_text_length (m_text)) { 73 | erase_input_sequence (m_text, m_cursor, 1); 74 | update (); 75 | } 76 | return TRUE; 77 | case IBUS_Left: 78 | case IBUS_KP_Left: 79 | if (!m_text) 80 | return FALSE; 81 | if (m_cursor > 0) { 82 | m_cursor --; 83 | update (); 84 | } 85 | return TRUE; 86 | case IBUS_Right: 87 | case IBUS_KP_Right: 88 | if (m_cursor < m_text.length ()) { 89 | m_cursor ++; 90 | update (); 91 | } 92 | return TRUE; 93 | case IBUS_Escape: 94 | reset (); 95 | return TRUE; 96 | default: 97 | return TRUE; 98 | } 99 | } 100 | 101 | void 102 | EnhancedEditor::update (void) 103 | { 104 | Editor::update (); 105 | } 106 | 107 | void 108 | EnhancedEditor::reset (void) 109 | { 110 | Editor::reset (); 111 | } 112 | 113 | }; 114 | -------------------------------------------------------------------------------- /src/ZYSignal.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_SIGNAL_H_ 22 | #define __ZY_SIGNAL_H_ 23 | 24 | 25 | #ifdef HAVE_CONFIG_H 26 | # include 27 | #endif 28 | 29 | #ifdef __GXX_EXPERIMENTAL_CXX0X__ 30 | 31 | # include 32 | 33 | namespace ZY { 34 | 35 | using namespace std::placeholders; 36 | 37 | // implement signal templates 38 | template 42 | struct signal 43 | { 44 | }; 45 | 46 | template 47 | struct signal< R(), T1, T2, T3> 48 | { 49 | typedef std::function func_type; 50 | void connect (func_type f) { m_func = f; } 51 | R operator ()() const { m_func (); } 52 | private: 53 | func_type m_func; 54 | }; 55 | 56 | template 57 | struct signal< R(T1), T2, T3> 58 | { 59 | typedef std::function func_type; 60 | void connect (func_type f) { m_func = f; } 61 | R operator ()(T1 a1) const { return m_func (a1); } 62 | private: 63 | func_type m_func; 64 | }; 65 | 66 | template 67 | struct signal< R(T1, T2), T3> 68 | { 69 | typedef std::function func_type; 70 | void connect (func_type f) { m_func = f; } 71 | R operator ()(T1 a1, T2 a2) const { return m_func (a1, a2); } 72 | private: 73 | func_type m_func; 74 | }; 75 | 76 | template 77 | struct signal< R(T1, T2, T3)> 78 | { 79 | typedef std::function func_type; 80 | void connect (func_type f) {m_func = f; } 81 | R operator ()(T1 a1, T2 a2, T3 a3) const { return m_func (a1, a2, a3); } 82 | private: 83 | func_type m_func; 84 | }; 85 | 86 | }; 87 | 88 | #else // __GXX_EXPERIMENTAL_CXX0X__ 89 | 90 | # include 91 | # include 92 | 93 | namespace std { 94 | // import boost::bind into std namespace 95 | using boost::bind; 96 | }; 97 | 98 | namespace ZY { 99 | // use boost::signal2 100 | namespace bs2 = boost::signals2; 101 | template 102 | struct signal : public bs2::signal_type 103 | >::type { }; 104 | 105 | }; 106 | 107 | #endif // __GXX_EXPERIMENTAL_CXX0X__ 108 | #endif // __ZY_SIGNAL_H_ 109 | 110 | -------------------------------------------------------------------------------- /src/ZYUtil.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_UTIL_H_ 22 | #define __ZY_UTIL_H_ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | # include 26 | #endif 27 | 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef __GXX_EXPERIMENTAL_CXX0X__ 34 | # include 35 | #else 36 | # include 37 | # include 38 | 39 | namespace std { 40 | // import boost::shared_ptr to std namespace 41 | using boost::shared_ptr; 42 | // import boost::scoped_ptr to std namespace, and rename to unique_ptr 43 | // XXX: the unique_ptr can transfer the pointer ownership, 44 | // but scoped_ptr cannot. 45 | template class unique_ptr : public boost::scoped_ptr {}; 46 | }; 47 | 48 | #endif 49 | 50 | #if defined(NDEBUG) || defined(G_DISABLE_ASSERT) 51 | #define check_result(expr) expr 52 | #else 53 | #define check_result(expr) assert(expr) 54 | #endif 55 | 56 | #include 57 | 58 | namespace ZY { 59 | 60 | // mask for Ctrl, Alt, Super, Hyper, Meta 61 | const guint CMSHM_MASK = IBUS_CONTROL_MASK | 62 | IBUS_MOD1_MASK | 63 | IBUS_SUPER_MASK | 64 | IBUS_HYPER_MASK | 65 | IBUS_META_MASK; 66 | // mask for Shift, Ctrl, Alt, Super, Hyper, Meta 67 | const guint SCMSHM_MASK = CMSHM_MASK | IBUS_SHIFT_MASK; 68 | 69 | inline guint 70 | cmshm_filter (guint modifiers) 71 | { 72 | return modifiers & CMSHM_MASK; 73 | } 74 | 75 | inline guint 76 | scmshm_filter (guint modifiers) 77 | { 78 | return modifiers & SCMSHM_MASK; 79 | } 80 | 81 | inline gboolean 82 | cmshm_test (guint modifiers, guint mask) 83 | { 84 | return cmshm_filter (modifiers) == mask; 85 | } 86 | 87 | inline gboolean 88 | scmshm_test (guint modifiers, guint mask) 89 | { 90 | return scmshm_filter (modifiers) == mask; 91 | } 92 | 93 | #if 0 94 | class Uname { 95 | public: 96 | Uname (void) 97 | { 98 | uname (&m_buf); 99 | } 100 | 101 | const gchar *hostname (void) const { return m_buf.nodename; } 102 | private: 103 | struct utsname m_buf; 104 | }; 105 | 106 | class Hostname : public Uname { 107 | public: 108 | operator const gchar * (void) const 109 | { 110 | return hostname (); 111 | } 112 | }; 113 | 114 | class Env : public std::string { 115 | public: 116 | Env (const gchar *name) 117 | { 118 | gchar *str; 119 | str = std::getenv (name); 120 | assign (str != NULL ? str : ""); 121 | } 122 | 123 | operator const gchar *(void) const 124 | { 125 | return c_str(); 126 | } 127 | }; 128 | #endif 129 | 130 | }; 131 | #endif 132 | -------------------------------------------------------------------------------- /po/Makevars: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = $(PACKAGE) 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments 12 | 13 | # This is the copyright holder that gets inserted into the header of the 14 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 15 | # package. (Note that the msgstr strings, extracted from the package's 16 | # sources, belong to the copyright holder of the package.) Translators are 17 | # expected to transfer the copyright for their translations to this person 18 | # or entity, or to disclaim their copyright. The empty string stands for 19 | # the public domain; in this case the translators are expected to disclaim 20 | # their copyright. 21 | COPYRIGHT_HOLDER = Free Software Foundation, Inc. 22 | 23 | # This tells whether or not to prepend "GNU " prefix to the package 24 | # name that gets inserted into the header of the $(DOMAIN).pot file. 25 | # Possible values are "yes", "no", or empty. If it is empty, try to 26 | # detect it automatically by scanning the files in $(top_srcdir) for 27 | # "GNU packagename" string. 28 | PACKAGE_GNU = 29 | 30 | # This is the email address or URL to which the translators shall report 31 | # bugs in the untranslated strings: 32 | # - Strings which are not entire sentences, see the maintainer guidelines 33 | # in the GNU gettext documentation, section 'Preparing Strings'. 34 | # - Strings which use unclear terms or require additional context to be 35 | # understood. 36 | # - Strings which make invalid assumptions about notation of date, time or 37 | # money. 38 | # - Pluralisation problems. 39 | # - Incorrect English spelling. 40 | # - Incorrect formatting. 41 | # It can be your email address, or a mailing list address where translators 42 | # can write to without being subscribed, or the URL of a web page through 43 | # which the translators can contact you. 44 | MSGID_BUGS_ADDRESS = 45 | 46 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 47 | # message catalogs shall be used. It is usually empty. 48 | EXTRA_LOCALE_CATEGORIES = 49 | 50 | # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' 51 | # context. Possible values are "yes" and "no". Set this to yes if the 52 | # package uses functions taking also a message context, like pgettext(), or 53 | # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. 54 | USE_MSGCTXT = no 55 | 56 | # These options get passed to msgmerge. 57 | # Useful options are in particular: 58 | # --previous to keep previous msgids of translated messages, 59 | # --quiet to reduce the verbosity. 60 | MSGMERGE_OPTIONS = 61 | 62 | # These options get passed to msginit. 63 | # If you want to disable line wrapping when writing PO files, add 64 | # --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and 65 | # MSGINIT_OPTIONS. 66 | MSGINIT_OPTIONS = 67 | 68 | # This tells whether or not to regenerate a PO file when $(DOMAIN).pot 69 | # has changed. Possible values are "yes" and "no". Set this to no if 70 | # the POT file is checked in the repository and the version control 71 | # program ignores timestamps. 72 | PO_DEPENDS_ON_POT = yes 73 | 74 | # This tells whether or not to forcibly update $(DOMAIN).pot and 75 | # regenerate PO files on "make dist". Possible values are "yes" and 76 | # "no". Set this to no if the POT file and PO files are maintained 77 | # externally. 78 | DIST_DEPENDS_ON_UPDATE_PO = yes 79 | -------------------------------------------------------------------------------- /src/ZYZUserSymbolListAllSection.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "ZYZUserSymbolListAllSection.h" 23 | #include 24 | #include "ZYSymbols.h" 25 | 26 | namespace ZY { 27 | 28 | UserSymbolListAllSection::UserSymbolListAllSection (PhoneticEditor & editor, 29 | ZhuyinProperties & props) : 30 | SymbolSection (editor, props) 31 | { 32 | m_type = BUILTIN_SYMBOL_TYPE; 33 | 34 | /* load user symbol. */ 35 | gchar * path = g_build_filename (g_get_user_config_dir (), 36 | "ibus", "libzhuyin", 37 | "usersymbol.txt", NULL); 38 | loadUserSymbolFile (".." G_DIR_SEPARATOR_S "data" G_DIR_SEPARATOR_S 39 | "usersymbol.txt") || 40 | loadUserSymbolFile (path) || 41 | loadUserSymbolFile (PKGDATADIR G_DIR_SEPARATOR_S "usersymbol.txt"); 42 | g_free(path); 43 | } 44 | 45 | UserSymbolListAllSection::~UserSymbolListAllSection () 46 | { 47 | } 48 | 49 | gboolean 50 | UserSymbolListAllSection::loadUserSymbolFile (const gchar * filename) 51 | { 52 | gboolean retval = m_user_symbols.loadFromFile (filename); 53 | return retval; 54 | } 55 | 56 | bool 57 | UserSymbolListAllSection::initCandidates (zhuyin_instance_t * instance, 58 | const String & lookup) 59 | { 60 | if (!lookup) 61 | return false; 62 | 63 | m_candidates.clear (); 64 | 65 | assert ("`" == lookup); 66 | m_lookup = lookup; 67 | 68 | /* cache the symbols. */ 69 | const std::vector & indexes = m_user_symbols.getIndexes (); 70 | for (size_t i = 0; i < indexes.size (); ++i) { 71 | m_candidates.push_back (indexes[i]); 72 | } 73 | 74 | return true; 75 | } 76 | 77 | bool 78 | UserSymbolListAllSection::fillLookupTableByPage () 79 | { 80 | LookupTable & lookup_table = getLookupTable (); 81 | 82 | guint len = m_candidates.size (); 83 | 84 | guint filled_nr = lookup_table.size (); 85 | guint page_size = lookup_table.pageSize (); 86 | 87 | /* fill lookup table by libzhuyin get candidates. */ 88 | guint need_nr = MIN (page_size, len - filled_nr); 89 | g_assert (need_nr >=0); 90 | if (need_nr == 0) 91 | return FALSE; 92 | 93 | for (guint i = filled_nr; i < filled_nr + need_nr; i++) { 94 | if (i >= len) /* no more candidates */ 95 | break; 96 | 97 | Text text (m_candidates[i]); 98 | lookup_table.appendCandidate (text); 99 | } 100 | 101 | return TRUE; 102 | } 103 | 104 | int 105 | UserSymbolListAllSection::selectCandidate (guint index) 106 | { 107 | if (index >= m_candidates.size ()) 108 | return 0; 109 | 110 | m_choice = m_user_symbols.find (m_candidates[index]); 111 | return m_choice.utf8Length (); 112 | } 113 | 114 | }; 115 | -------------------------------------------------------------------------------- /src/ZYConfig.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #include "ZYConfig.h" 22 | 23 | #include "ZYTypes.h" 24 | #include "ZYBus.h" 25 | 26 | namespace ZY { 27 | 28 | 29 | Config::Config (const std::string & name) 30 | : m_schema_id (name) 31 | { 32 | m_settings = NULL; 33 | initDefaultValues (); 34 | } 35 | 36 | Config::~Config (void) 37 | { 38 | } 39 | 40 | void 41 | Config::initDefaultValues (void) 42 | { 43 | m_page_size = 5; 44 | 45 | m_is_zhuyin = TRUE; 46 | m_zhuyin_scheme = ZHUYIN_DEFAULT; 47 | m_pinyin_scheme = FULL_PINYIN_DEFAULT; 48 | m_need_tone = TRUE; 49 | 50 | m_init_chinese = TRUE; 51 | m_init_full_width = FALSE; 52 | m_init_trad_chinese = TRUE; 53 | 54 | m_always_input_numbers = FALSE; 55 | m_space_show_candidates = FALSE; 56 | m_candidates_after_cursor = TRUE; 57 | 58 | m_easy_symbol = TRUE; 59 | m_user_symbol = TRUE; 60 | } 61 | 62 | 63 | void 64 | Config::readDefaultValues (void) 65 | { 66 | } 67 | 68 | bool 69 | Config::read (const gchar * name, 70 | bool defval) 71 | { 72 | GVariant *value = NULL; 73 | if ((value = g_settings_get_value (m_settings, name)) != NULL) { 74 | if (g_variant_classify (value) == G_VARIANT_CLASS_BOOLEAN) 75 | return g_variant_get_boolean (value); 76 | } 77 | 78 | g_warn_if_reached (); 79 | return defval; 80 | } 81 | 82 | gint 83 | Config::read (const gchar * name, 84 | gint defval) 85 | { 86 | GVariant *value = NULL; 87 | if ((value = g_settings_get_value (m_settings, name)) != NULL) { 88 | if (g_variant_classify (value) == G_VARIANT_CLASS_INT32) 89 | return g_variant_get_int32 (value); 90 | } 91 | 92 | g_warn_if_reached (); 93 | return defval; 94 | } 95 | 96 | std::string 97 | Config::read (const gchar * name, 98 | const gchar * defval) 99 | { 100 | GVariant *value = NULL; 101 | if ((value = g_settings_get_value (m_settings, name)) != NULL) { 102 | if (g_variant_classify (value) == G_VARIANT_CLASS_STRING) 103 | return g_variant_get_string (value, NULL); 104 | } 105 | 106 | g_warn_if_reached (); 107 | return defval; 108 | } 109 | 110 | gboolean 111 | Config::valueChanged (const std::string &schema_id, 112 | const std::string &name, 113 | GVariant *value) 114 | { 115 | return FALSE; 116 | } 117 | 118 | void 119 | Config::valueChangedCallback (GSettings *settings, 120 | const gchar *name, 121 | Config *self) 122 | { 123 | gchar * property = NULL; 124 | g_object_get (settings, "schema-id", &property, NULL); 125 | std::string schema_id (property); 126 | g_free (property); 127 | 128 | GVariant * value = g_settings_get_value (settings, name); 129 | self->valueChanged (schema_id, name, value); 130 | g_variant_unref (value); 131 | } 132 | 133 | }; 134 | -------------------------------------------------------------------------------- /src/ZYZPhoneticSection.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "ZYZPhoneticSection.h" 23 | #include 24 | #include "ZYConfig.h" 25 | #include "ZYZhuyinProperties.h" 26 | #include "ZYTradSimpConverter.h" 27 | 28 | namespace ZY { 29 | 30 | PhoneticSection::PhoneticSection (PhoneticEditor & editor, 31 | ZhuyinProperties & props) : 32 | m_editor (editor), m_props (props) 33 | { 34 | } 35 | 36 | PhoneticSection::~PhoneticSection () 37 | { 38 | } 39 | 40 | bool 41 | PhoneticSection::initCandidates (zhuyin_instance_t * instance, 42 | int cursor) 43 | { 44 | m_instance = instance; 45 | m_cursor = cursor; 46 | 47 | size_t offset = 0; 48 | zhuyin_get_zhuyin_offset (instance, cursor, &offset); 49 | 50 | if (m_editor.m_config.candidatesAfterCursor ()) 51 | zhuyin_guess_candidates_after_cursor (m_instance, offset); 52 | else 53 | zhuyin_guess_candidates_before_cursor (m_instance, offset); 54 | 55 | return true; 56 | } 57 | 58 | bool 59 | PhoneticSection::fillLookupTableByPage () 60 | { 61 | LookupTable & lookup_table = getLookupTable (); 62 | 63 | guint len = 0; 64 | zhuyin_get_n_candidate (m_instance, &len); 65 | 66 | guint filled_nr = lookup_table.size (); 67 | guint page_size = lookup_table.pageSize (); 68 | 69 | /* fill lookup table by libzhuyin get candidates. */ 70 | guint need_nr = MIN (page_size, len - filled_nr); 71 | g_assert (need_nr >=0); 72 | if (need_nr == 0) 73 | return FALSE; 74 | 75 | String word; 76 | for (guint i = filled_nr; i < filled_nr + need_nr; i++) { 77 | if (i >= len) /* no more candidates */ 78 | break; 79 | 80 | lookup_candidate_t * candidate = NULL; 81 | zhuyin_get_candidate (m_instance, i, &candidate); 82 | 83 | const gchar * phrase_string = NULL; 84 | zhuyin_get_candidate_string (m_instance, candidate, &phrase_string); 85 | 86 | /* show get candidates. */ 87 | if (G_LIKELY (m_props.modeTrad ())) { 88 | word = phrase_string; 89 | } else { /* Simplified Chinese */ 90 | word.truncate (0); 91 | TradSimpConverter::tradToSimp (phrase_string, word); 92 | } 93 | 94 | Text text (word); 95 | lookup_table.appendCandidate (text); 96 | } 97 | 98 | return TRUE; 99 | } 100 | 101 | int 102 | PhoneticSection::selectCandidate (guint index) 103 | { 104 | guint len = 0; 105 | zhuyin_get_n_candidate (m_instance, &len); 106 | 107 | if (index >= len) 108 | return 0; 109 | 110 | lookup_candidate_t * candidate = NULL; 111 | zhuyin_get_candidate (m_instance, index, &candidate); 112 | 113 | size_t offset = 0; 114 | zhuyin_get_zhuyin_offset (m_instance, m_cursor, &offset); 115 | 116 | offset = zhuyin_choose_candidate 117 | (m_instance, offset, candidate); 118 | 119 | return offset - m_cursor; 120 | } 121 | 122 | }; 123 | -------------------------------------------------------------------------------- /data/com.github.libzhuyin.ibus-libzhuyin.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | Always Input Numbers by Input Pad 7 | 8 | 9 | '1234567890' 10 | Candidate Choose Keys 11 | 12 | 13 | 10 14 | Candidates per Page 15 | 16 | 17 | true 18 | Show Candidates After the Cursor 19 | 20 | 21 | true 22 | Use Chinese Mode When Start-up 23 | 24 | 25 | true 26 | Easy Symbols 27 | 28 | 29 | false 30 | Use Full Width When Start-up 31 | 32 | 33 | false 34 | Fuzzy Zhuyin 35 | 36 | 37 | true 38 | Fuzzy Zhuyin for an and ang 39 | 40 | 41 | true 42 | Fuzzy Zhuyin for en and eng 43 | 44 | 45 | true 46 | Fuzzy Zhuyin for in and ing 47 | 48 | 49 | true 50 | Fuzzy Zhuyin for f and h 51 | 52 | 53 | false 54 | Fuzzy Zhuyin for g and k 55 | 56 | 57 | true 58 | Fuzzy Zhuyin for l and n 59 | 60 | 61 | false 62 | Fuzzy Zhuyin for l and r 63 | 64 | 65 | true 66 | Fuzzy Zhuyin for c and ch 67 | 68 | 69 | true 70 | Fuzzy Zhuyin for s and sh 71 | 72 | 73 | true 74 | Fuzzy Zhuyin for z and zh 75 | 76 | 77 | 0 78 | Keyboard Layout 79 | 80 | 81 | true 82 | Need tone information 83 | 84 | 85 | false 86 | Use Space Key to Show Candidates 87 | 88 | 89 | true 90 | Use Traditional Chinese When Start-up 91 | 92 | 93 | true 94 | Use Symbols 95 | 96 | 97 | '' 98 | Import Dictionary 99 | 100 | 101 | '' 102 | Clean User Data 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/ZYEditor.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #include "ZYText.h" 22 | #include "ZYEditor.h" 23 | 24 | namespace ZY { 25 | 26 | Editor::Editor (ZhuyinProperties & props, Config & config) 27 | : m_cursor (0), 28 | m_props (props), 29 | m_config (config) 30 | { 31 | } 32 | 33 | Editor::~Editor (void) 34 | { 35 | } 36 | 37 | gboolean 38 | Editor::processKeyEvent (guint keyval, guint keycode, guint modifiers) 39 | { 40 | if (modifiers & IBUS_MOD4_MASK) 41 | return FALSE; 42 | 43 | modifiers &= (IBUS_CONTROL_MASK | 44 | IBUS_MOD1_MASK | 45 | IBUS_SUPER_MASK | 46 | IBUS_HYPER_MASK | 47 | IBUS_META_MASK); 48 | /* ignore key events with some masks */ 49 | if (modifiers != 0) 50 | return FALSE; 51 | 52 | if (keyval >= IBUS_exclam && keyval <= IBUS_asciitilde) { 53 | /* char key */ 54 | m_text.insert (m_cursor++, keyval); 55 | update (); 56 | return TRUE; 57 | } 58 | else { 59 | /* control key */ 60 | if (!m_text) 61 | return FALSE; 62 | } 63 | 64 | switch (keyval) { 65 | case IBUS_BackSpace: 66 | if (m_cursor > 0) { 67 | m_text.erase (--m_cursor, 1); 68 | update (); 69 | } 70 | return TRUE; 71 | case IBUS_Delete: 72 | case IBUS_KP_Delete: 73 | if (m_cursor < m_text.length ()) { 74 | m_text.erase (m_cursor, 1); 75 | update (); 76 | } 77 | return TRUE; 78 | case IBUS_Left: 79 | case IBUS_KP_Left: 80 | if (!m_text) 81 | return FALSE; 82 | if (m_cursor > 0) { 83 | m_cursor --; 84 | update (); 85 | } 86 | return TRUE; 87 | case IBUS_Right: 88 | case IBUS_KP_Right: 89 | if (m_cursor < m_text.length ()) { 90 | m_cursor ++; 91 | update (); 92 | } 93 | return TRUE; 94 | case IBUS_space: 95 | case IBUS_Return: 96 | case IBUS_KP_Enter: 97 | { 98 | StaticText text (m_text); 99 | commitText (text); 100 | reset (); 101 | } 102 | return TRUE; 103 | case IBUS_Escape: 104 | if (m_text.empty ()) 105 | return FALSE; 106 | 107 | reset (); 108 | return TRUE; 109 | default: 110 | return TRUE; 111 | } 112 | } 113 | 114 | void 115 | Editor::reset (void) 116 | { 117 | gboolean need_update = (m_cursor != 0 || !m_text.empty ()); 118 | m_cursor = 0; 119 | m_text = ""; 120 | if (need_update) 121 | update (); 122 | } 123 | 124 | void 125 | Editor::pageUp (void) 126 | { 127 | } 128 | 129 | void 130 | Editor::pageDown (void) 131 | { 132 | } 133 | 134 | void 135 | Editor::cursorUp (void) 136 | { 137 | } 138 | 139 | void 140 | Editor::cursorDown (void) 141 | { 142 | } 143 | 144 | void 145 | Editor::candidateClicked (guint index, guint button, guint state) 146 | { 147 | } 148 | 149 | void 150 | Editor::update (void) 151 | { 152 | if (m_text) { 153 | StaticText text (m_text); 154 | text.appendAttribute (IBUS_ATTR_TYPE_UNDERLINE, IBUS_ATTR_UNDERLINE_SINGLE, 0, -1); 155 | updatePreeditText (text, m_cursor, TRUE); 156 | } 157 | else { 158 | hidePreeditText (); 159 | } 160 | } 161 | 162 | }; 163 | 164 | -------------------------------------------------------------------------------- /src/ZYEngine.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_ENGINE_H_ 22 | #define __ZY_ENGINE_H_ 23 | 24 | #include 25 | 26 | #include "ZYPointer.h" 27 | #include "ZYLookupTable.h" 28 | #include "ZYProperty.h" 29 | #include "ZYEditor.h" 30 | 31 | namespace ZY { 32 | 33 | #define IBUS_TYPE_ZHUYIN_ENGINE \ 34 | (ZY::ibus_zhuyin_engine_get_type ()) 35 | 36 | GType ibus_zhuyin_engine_get_type (void); 37 | 38 | class Engine { 39 | public: 40 | Engine (IBusEngine *engine); 41 | virtual ~Engine (void); 42 | 43 | gboolean contentIsPassword(); 44 | 45 | // virtual functions 46 | virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers) = 0; 47 | virtual void focusIn (void) = 0; 48 | virtual void focusOut (void); 49 | #if IBUS_CHECK_VERSION (1, 5, 4) 50 | virtual void setContentType (guint purpose, guint hints); 51 | #endif 52 | virtual void reset (void) = 0; 53 | virtual void enable (void) = 0; 54 | virtual void disable (void) = 0; 55 | virtual void pageUp (void) = 0; 56 | virtual void pageDown (void) = 0; 57 | virtual void cursorUp (void) = 0; 58 | virtual void cursorDown (void) = 0; 59 | virtual gboolean propertyActivate (const gchar *prop_name, guint prop_state) = 0; 60 | virtual void candidateClicked (guint index, guint button, guint state) = 0; 61 | 62 | protected: 63 | void commitText (Text & text) const 64 | { 65 | ibus_engine_commit_text (m_engine, text); 66 | } 67 | 68 | void updatePreeditText (Text & text, guint cursor, gboolean visible) const 69 | { 70 | ibus_engine_update_preedit_text (m_engine, text, cursor, visible); 71 | } 72 | 73 | void showPreeditText (void) const 74 | { 75 | ibus_engine_show_preedit_text (m_engine); 76 | } 77 | 78 | void hidePreeditText (void) const 79 | { 80 | ibus_engine_hide_preedit_text (m_engine); 81 | } 82 | 83 | void updateAuxiliaryText (Text & text, gboolean visible) const 84 | { 85 | ibus_engine_update_auxiliary_text (m_engine, text, visible); 86 | } 87 | 88 | void showAuxiliaryText (void) const 89 | { 90 | ibus_engine_show_auxiliary_text (m_engine); 91 | } 92 | 93 | void hideAuxiliaryText (void) const 94 | { 95 | ibus_engine_hide_auxiliary_text (m_engine); 96 | } 97 | 98 | void updateLookupTable (LookupTable &table, gboolean visible) const 99 | { 100 | ibus_engine_update_lookup_table (m_engine, table, visible); 101 | } 102 | 103 | void updateLookupTableFast (LookupTable &table, gboolean visible) const 104 | { 105 | ibus_engine_update_lookup_table_fast (m_engine, table, visible); 106 | } 107 | 108 | void showLookupTable (void) const 109 | { 110 | ibus_engine_show_lookup_table (m_engine); 111 | } 112 | 113 | void hideLookupTable (void) const 114 | { 115 | ibus_engine_hide_lookup_table (m_engine); 116 | } 117 | 118 | void registerProperties (PropList & props) const 119 | { 120 | ibus_engine_register_properties (m_engine, props); 121 | } 122 | 123 | void updateProperty (Property & prop) const 124 | { 125 | ibus_engine_update_property (m_engine, prop); 126 | } 127 | 128 | protected: 129 | Pointer m_engine; // engine pointer 130 | 131 | #if IBUS_CHECK_VERSION (1, 5, 4) 132 | IBusInputPurpose m_input_purpose; 133 | #endif 134 | 135 | }; 136 | 137 | }; 138 | #endif 139 | -------------------------------------------------------------------------------- /src/ZYString.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_STRING_H_ 22 | #define __ZY_STRING_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace ZY { 30 | 31 | class String : public std::string { 32 | public: 33 | String () : std::string () { } 34 | String (const gchar *str) : std::string (str) { } 35 | String (const std::string &str) : std::string (str) { } 36 | String (const gchar ch) : std::string (1, ch) { } 37 | 38 | String & printf (const gchar *fmt, ...) 39 | { 40 | gchar *str; 41 | va_list args; 42 | 43 | va_start (args, fmt); 44 | str = g_strdup_vprintf (fmt, args); 45 | va_end (args); 46 | 47 | assign (str); 48 | g_free (str); 49 | return *this; 50 | } 51 | 52 | String & appendPrintf (const gchar *fmt, ...) 53 | { 54 | gchar *str; 55 | va_list args; 56 | 57 | va_start (args, fmt); 58 | str = g_strdup_vprintf (fmt, args); 59 | va_end (args); 60 | 61 | append (str); 62 | g_free (str); 63 | 64 | return *this; 65 | } 66 | 67 | String & appendUnichar (gunichar ch) 68 | { 69 | gchar str[12]; 70 | gint len; 71 | len = g_unichar_to_utf8 (ch, str); 72 | str[len] = 0; 73 | append (str); 74 | return *this; 75 | } 76 | 77 | String & insert (gint i, gchar ch) 78 | { 79 | std::string::insert (i, 1, ch); 80 | return *this; 81 | } 82 | 83 | String & truncate (guint len) 84 | { 85 | erase(len); 86 | return *this; 87 | } 88 | 89 | gsize utf8Length (void) const 90 | { 91 | return g_utf8_strlen (c_str(), -1); 92 | } 93 | 94 | String & operator<< (gint i) 95 | { 96 | return appendPrintf ("%d", i); 97 | } 98 | 99 | String & operator<< (guint i) 100 | { 101 | return appendPrintf ("%u", i); 102 | } 103 | 104 | String & operator<< (const gchar ch) 105 | { 106 | append (1, ch); 107 | return *this; 108 | } 109 | 110 | String & operator<< (const gchar *str) 111 | { 112 | append (str); 113 | return *this; 114 | } 115 | 116 | String & operator<< (const gunichar *wstr) 117 | { 118 | gchar *str; 119 | GError *error; 120 | str = g_ucs4_to_utf8 (wstr, -1, NULL, NULL, &error); 121 | if (str == NULL) { 122 | g_warning ("convert ucs4 to utf8 failed: %s", error->message); 123 | g_error_free (error); 124 | } 125 | else { 126 | append (str); 127 | g_free (str); 128 | } 129 | return *this; 130 | } 131 | 132 | gchar operator[] (gint i) 133 | { 134 | return std::string::operator[] (i); 135 | } 136 | 137 | String & operator<< (const std::string &str) 138 | { 139 | return operator<< (str.c_str ()); 140 | } 141 | 142 | String & operator<< (const String &str) 143 | { 144 | return operator<< ((const gchar *)str); 145 | } 146 | 147 | String & operator= (const gchar * str) 148 | { 149 | assign (str); 150 | return *this; 151 | } 152 | 153 | String & operator= (const gchar ch) 154 | { 155 | assign (1, ch); 156 | return *this; 157 | } 158 | 159 | operator const gchar *(void) const 160 | { 161 | return this->c_str (); 162 | } 163 | 164 | operator gboolean (void) const 165 | { 166 | return ! empty (); 167 | } 168 | }; 169 | 170 | }; 171 | #endif 172 | -------------------------------------------------------------------------------- /src/ZYFallbackEditor.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "ZYFallbackEditor.h" 23 | #include 24 | #include "ZYSymbols.h" 25 | #include "ZYZhuyinProperties.h" 26 | 27 | namespace ZY { 28 | 29 | inline gboolean 30 | FallbackEditor::processSymbol (guint keyval, guint keycode, guint modifiers) 31 | { 32 | guint cmshm_modifiers = cmshm_filter (modifiers); 33 | 34 | /* check ctrl, alt, hyper, supper masks */ 35 | if (cmshm_modifiers != 0) 36 | return FALSE; 37 | 38 | /* English mode */ 39 | if (!m_props.modeChinese ()) { 40 | 41 | /* Punctuation character */ 42 | if (is_full_width_symbol (keyval)) { 43 | if(G_UNLIKELY (m_props.modeFullWidth ())) { 44 | String symbol; 45 | convert_full_width_symbol (keyval, symbol); 46 | commit (symbol); 47 | } else { 48 | commit (keyval); 49 | } 50 | return TRUE; 51 | } 52 | 53 | } else { 54 | /* Chinese mode, handled by ZhuyinEditor or PinyinEditor. */ 55 | return TRUE; 56 | } 57 | 58 | return FALSE; 59 | } 60 | 61 | gboolean 62 | FallbackEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) 63 | { 64 | gboolean retval = FALSE; 65 | 66 | if (modifiers & IBUS_MOD4_MASK) 67 | return FALSE; 68 | 69 | modifiers &= (IBUS_CONTROL_MASK | 70 | IBUS_MOD1_MASK | 71 | IBUS_SUPER_MASK | 72 | IBUS_HYPER_MASK | 73 | IBUS_META_MASK); 74 | 75 | switch (keyval) { 76 | /* numbers */ 77 | case IBUS_KP_0 ... IBUS_KP_9: 78 | keyval = keyval - IBUS_KP_0 + IBUS_0; 79 | case IBUS_0 ... IBUS_9: 80 | /* letters */ 81 | case IBUS_a ... IBUS_z: 82 | case IBUS_A ... IBUS_Z: 83 | if (modifiers == 0) { 84 | retval = processSymbol (keyval, keycode, modifiers); 85 | } 86 | break; 87 | /* punct */ 88 | case IBUS_exclam ... IBUS_slash: 89 | case IBUS_colon ... IBUS_at: 90 | case IBUS_bracketleft ... IBUS_quoteleft: 91 | case IBUS_braceleft ... IBUS_asciitilde: 92 | retval = processSymbol (keyval, keycode, modifiers); 93 | break; 94 | case IBUS_KP_Equal: 95 | retval = processSymbol ('=', keycode, modifiers); 96 | break; 97 | case IBUS_KP_Multiply: 98 | retval = processSymbol ('*', keycode, modifiers); 99 | break; 100 | case IBUS_KP_Add: 101 | retval = processSymbol ('+', keycode, modifiers); 102 | break; 103 | #if 0 104 | case IBUS_KP_Separator: 105 | retval = processSymbol (IBUS_separator, keycode, modifiers); 106 | break; 107 | #endif 108 | case IBUS_KP_Subtract: 109 | retval = processSymbol ('-', keycode, modifiers); 110 | break; 111 | case IBUS_KP_Decimal: 112 | retval = processSymbol ('.', keycode, modifiers); 113 | break; 114 | case IBUS_KP_Divide: 115 | retval = processSymbol ('/', keycode, modifiers); 116 | break; 117 | /* space */ 118 | case IBUS_KP_Space: 119 | keyval = IBUS_space; 120 | case IBUS_space: 121 | retval = processSymbol (keyval, keycode, modifiers); 122 | break; 123 | /* others */ 124 | default: 125 | break; 126 | } 127 | 128 | return retval; 129 | } 130 | 131 | void 132 | FallbackEditor::reset (void) { 133 | m_quote = TRUE; 134 | m_double_quote = TRUE; 135 | m_prev_committed_char = 0; 136 | } 137 | 138 | }; 139 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | # 5 | # Copyright (c) 2014 Peng Wu 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2, or (at your option) 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | 21 | libexec_PROGRAMS = ibus-engine-libzhuyin 22 | 23 | #ibus_engine_libzhuyin_built_c_sources = \ 24 | # $(NULL) 25 | #ibus_engine_libzhuyin_built_h_sources = \ 26 | # ZYPunctTable.h \ 27 | # ZYSimpTradConverterTable.h \ 28 | # $(NULL) 29 | 30 | ibus_engine_libzhuyin_c_sources = \ 31 | ZYConfig.cc \ 32 | ZYEditor.cc \ 33 | ZYLibZhuyin.cc \ 34 | ZYZConfig.cc \ 35 | ZYZhuyinProperties.cc \ 36 | ZYTradSimpConverter.cc \ 37 | ZYEnhancedText.cc \ 38 | ZYZEnhancedEditor.cc \ 39 | ZYZPhoneticEditor.cc \ 40 | ZYZZhuyinEditor.cc \ 41 | ZYZPinyinEditor.cc \ 42 | ZYSymbols.cc \ 43 | ZYSymbolLookup.cc \ 44 | ZYZBuiltinSymbolSection.cc \ 45 | ZYZPhoneticSection.cc \ 46 | ZYZBopomofoSymbolSection.cc \ 47 | ZYZUserSymbolListAllSection.cc \ 48 | ZYZUserSymbolShownSection.cc \ 49 | ZYFallbackEditor.cc \ 50 | ZYEngine.cc \ 51 | ZYZZhuyinEngine.cc \ 52 | ZYMain.cc \ 53 | $(NULL) 54 | 55 | ibus_engine_libzhuyin_h_sources = \ 56 | ZYBus.h \ 57 | ZYConfig.h \ 58 | ZYEditor.h \ 59 | ZYLookupTable.h \ 60 | ZYObject.h \ 61 | ZYLibZhuyin.h \ 62 | ZYZConfig.h \ 63 | ZYZhuyinProperties.h \ 64 | ZYTradSimpConverter.h \ 65 | ZYEnhancedText.h \ 66 | ZYZEnhancedEditor.h \ 67 | ZYZPhoneticEditor.h \ 68 | ZYZZhuyinEditor.h \ 69 | ZYZPinyinEditor.h \ 70 | ZYSymbols.h \ 71 | ZYSymbolLookup.h \ 72 | ZYZSymbolSection.h \ 73 | ZYZBuiltinSymbolSection.h \ 74 | ZYZPhoneticSection.h \ 75 | ZYZBopomofoSymbolSection.h \ 76 | ZYZUserSymbolListAllSection.h \ 77 | ZYZUserSymbolShownSection.h \ 78 | ZYPointer.h \ 79 | ZYProperty.h \ 80 | ZYRawEditor.h \ 81 | ZYFallbackEditor.h \ 82 | ZYSignal.h \ 83 | ZYString.h \ 84 | ZYText.h \ 85 | ZYTypes.h \ 86 | ZYUtil.h \ 87 | ZYEngine.h \ 88 | ZYZZhuyinEngine.h \ 89 | ZYTradSimpConverterTable.h \ 90 | $(NULL) 91 | 92 | 93 | ibus_engine_libzhuyin_SOURCES = \ 94 | $(ibus_engine_libzhuyin_c_sources) \ 95 | $(ibus_engine_libzhuyin_h_sources) \ 96 | $(NULL) 97 | 98 | ibus_engine_libzhuyin_CXXFLAGS = \ 99 | @IBUS_CFLAGS@ \ 100 | @LIBZHUYIN_CFLAGS@ \ 101 | @OPENCC_CFLAGS@ \ 102 | -DGETTEXT_PACKAGE=\"@GETTEXT_PACKAGE@\" \ 103 | -DPKGDATADIR=\"$(pkgdatadir)\" \ 104 | -DLIBEXECDIR=\"$(libexecdir)\" \ 105 | -DMODEL_DATADIR=\"$(libdir)\/ibus-libzhuyin\/data\" \ 106 | $(NULL) 107 | 108 | if HAVE_BOOST 109 | ibus_engine_libzhuyin_CXXFLAGS += \ 110 | @BOOST_CPPFLAGS@ \ 111 | $(NULL) 112 | else 113 | ibus_engine_libzhuyin_CXXFLAGS += \ 114 | -std=c++0x \ 115 | $(NULL) 116 | endif 117 | 118 | ibus_engine_libzhuyin_LDADD = \ 119 | @IBUS_LIBS@ \ 120 | @LIBZHUYIN_LIBS@ \ 121 | @OPENCC_LIBS@ \ 122 | $(NULL) 123 | 124 | 125 | component_DATA = \ 126 | libzhuyin.xml \ 127 | $(NULL) 128 | componentdir = @datadir@/ibus/component 129 | 130 | EXTRA_DIST = \ 131 | libzhuyin.xml.in \ 132 | $(NULL) 133 | 134 | CLEANFILES = \ 135 | libzhuyin.xml \ 136 | $(NULL) 137 | 138 | ZYTradSimpConverterTable.h: 139 | $(AM_V_GEN) \ 140 | $(PYTHON) $(top_srcdir)/scripts/update-tradsimp-table.py > $@ || \ 141 | ( $(RM) $@; exit 1 ) 142 | 143 | update-tradsimp-table: 144 | $(RM) ZhConversion.php ZhConversion.py ZYTradSimpConverterTable.h 145 | $(MAKE) ZhConversion.php 146 | $(MAKE) ZhConversion.py 147 | $(MAKE) ZYTradSimpConverterTable.h 148 | 149 | libzhuyin.xml: libzhuyin.xml.in 150 | $(AM_V_GEN) \ 151 | ( \ 152 | libexecdir=${libexecdir}; \ 153 | pkgdatadir=${pkgdatadir}; \ 154 | s=`cat $<`; \ 155 | eval "echo \"$${s}\""; \ 156 | ) > $@ 157 | 158 | 159 | ZhConversion.php: 160 | $(AM_V_GEN) \ 161 | curl https://raw.githubusercontent.com/wikimedia/mediawiki/master/languages/data/ZhConversion.php > $@ || \ 162 | ( $(RM) $@; exit 1 ) 163 | 164 | ZhConversion.py: ZhConversion.php 165 | $(AM_V_GEN) \ 166 | php $(top_srcdir)/scripts/php_2_py.php > $@ || \ 167 | ( $(RM) $@; exit 1 ) 168 | -------------------------------------------------------------------------------- /data/icons/half.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 21 | 23 | 27 | 31 | 32 | 39 | 48 | 49 | 67 | 69 | 70 | 72 | image/svg+xml 73 | 75 | 76 | 77 | 78 | 82 | 92 | 104 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /src/ZYTradSimpConverter.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | # include "config.h" 24 | #endif 25 | 26 | #include "ZYTradSimpConverter.h" 27 | 28 | #ifdef HAVE_OPENCC 29 | # include 30 | #else 31 | # include 32 | # include 33 | #endif 34 | 35 | #include "ZYTypes.h" 36 | #include "ZYString.h" 37 | 38 | namespace ZY { 39 | 40 | #ifdef HAVE_OPENCC 41 | 42 | class opencc { 43 | public: 44 | opencc (void) 45 | { 46 | m_cc = opencc_open (OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP); 47 | g_assert (m_cc != NULL); 48 | } 49 | 50 | ~opencc (void) 51 | { 52 | opencc_close (m_cc); 53 | } 54 | 55 | void convert (const gchar *in, String &out) 56 | { 57 | char * converted = opencc_convert_utf8 (m_cc, in, -1); 58 | g_assert (converted != NULL); 59 | out = converted; 60 | opencc_convert_utf8_free (converted); 61 | } 62 | 63 | private: 64 | opencc_t m_cc; 65 | }; 66 | 67 | void 68 | TradSimpConverter::tradToSimp (const gchar *in, String &out) 69 | { 70 | static opencc cc; 71 | cc.convert (in, out); 72 | } 73 | 74 | #else 75 | 76 | static gint _xcmp (const gchar *p1, const gchar *p2, const gchar *str) 77 | { 78 | for (;;) { 79 | // both reach end 80 | if (p1 == p2 && *str == '\0') 81 | return 0; 82 | // p1 reaches end 83 | if (p1 == p2) 84 | return -1; 85 | // str reaches end 86 | if (*str == '\0') 87 | return 1; 88 | 89 | if (*p1 < *str) 90 | return -1; 91 | if (*p1 > *str) 92 | return 1; 93 | 94 | p1 ++; str ++; 95 | }; 96 | } 97 | 98 | static gint _cmp (gconstpointer p1, gconstpointer p2) 99 | { 100 | const gchar **pp = (const gchar **) p1; 101 | const gchar **s2 = (const gchar **) p2; 102 | 103 | return _xcmp (pp[0], pp[1], s2[0]); 104 | } 105 | 106 | #include "ZYTradSimpConverterTable.h" 107 | 108 | void 109 | TradSimpConverter::tradToSimp (const gchar *in, String &out) 110 | { 111 | const gchar *pend; 112 | const gchar *pp[2]; 113 | glong len; 114 | glong begin; 115 | 116 | if (!g_utf8_validate (in, -1 , NULL)) { 117 | g_warning ("\%s\" is not an utf8 string!", in); 118 | g_assert_not_reached (); 119 | } 120 | 121 | begin = 0; 122 | pend = in + std::strlen (in); 123 | len = g_utf8_strlen (in, -1); // length in charactoers 124 | pp[0] = in; 125 | 126 | while (pp[0] != pend) { 127 | glong slen = std::min (len - begin, (glong) TRAD_TO_SIMP_MAX_LEN); // the length of sub string in character 128 | pp[1] = g_utf8_offset_to_pointer (pp[0], slen); // the end of sub string 129 | 130 | for (;;) { 131 | const gchar **result; 132 | result = (const gchar **) std::bsearch (pp, trad_to_simp, 133 | G_N_ELEMENTS (trad_to_simp), sizeof (trad_to_simp[0]), 134 | _cmp); 135 | 136 | if (result != NULL) { 137 | // found item in table, 138 | // append the trad to out and adjust pointers 139 | out << result[1]; 140 | pp[0] = pp[1]; 141 | begin += slen; 142 | break; 143 | } 144 | 145 | if (slen == 1) { 146 | // if only one character left, 147 | // append origin character to out and adjust pointers 148 | out.append (pp[0], pp[1] - pp[0]); 149 | pp[0] = pp[1]; 150 | begin += 1; 151 | break; 152 | } 153 | 154 | // if more than on characters left, 155 | // adjust pp[1] to previous character 156 | pp[1] = g_utf8_prev_char (pp[1]); 157 | slen--; 158 | } 159 | } 160 | } 161 | 162 | #endif 163 | 164 | }; 165 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # vim:set et ts=4: 2 | # 3 | # ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | # 5 | # Copyright (c) 2014 Peng Wu 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2, or (at your option) 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | 21 | # if not 1, append datestamp to the version number. 22 | m4_define([ibus_released], [1]) 23 | m4_define([ibus_major_version], [1]) 24 | m4_define([ibus_minor_version], [10]) 25 | m4_define([ibus_micro_version], [4]) 26 | m4_define(ibus_maybe_datestamp, 27 | m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi])) 28 | 29 | m4_define([ibus_version], 30 | ibus_major_version.ibus_minor_version.ibus_micro_version[]ibus_maybe_datestamp) 31 | 32 | AC_INIT([ibus-libzhuyin], [ibus_version], [https://github.com/libzhuyin/ibus-libzhuyin/issues/new],[ibus-libzhuyin]) 33 | AM_INIT_AUTOMAKE([1.10]) 34 | AC_GNU_SOURCE 35 | 36 | AC_CONFIG_HEADERS([config.h]) 37 | AC_CONFIG_MACRO_DIR([m4]) 38 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) 39 | 40 | # define PACKAGE_VERSION_* variables 41 | AS_VERSION 42 | AS_NANO 43 | AM_SANITY_CHECK 44 | AM_MAINTAINER_MODE 45 | AM_DISABLE_STATIC 46 | AC_PROG_CC 47 | AC_PROG_CXX 48 | AM_PROG_CC_C_O 49 | AC_ISC_POSIX 50 | AC_HEADER_STDC 51 | LT_INIT 52 | AC_PROG_SED 53 | 54 | # check ibus 55 | PKG_CHECK_MODULES(IBUS, [ 56 | ibus-1.0 >= 1.4.0 57 | ]) 58 | 59 | # check libzhuyin and database format 60 | PKG_CHECK_MODULES(LIBZHUYIN, [ 61 | libzhuyin >= 2.6.0 62 | ], [enable_libzhuyin=yes]) 63 | DATABASE_FORMAT=`$PKG_CONFIG --variable=database_format libzhuyin` 64 | AC_SUBST(DATABASE_FORMAT) 65 | 66 | # check if ibus_config_get_values, which is available in ibus-1.3.99+ (git master) 67 | save_CFLAGS="$CFLAGS" 68 | save_LIBS="$LIBS" 69 | CFLAGS="$CFLAGS $IBUS_CFLAGS" 70 | LIBS="$LIBS $IBUS_LIBS" 71 | AC_CHECK_FUNCS([ibus_config_get_values]) 72 | CFLAGS="$save_CFLAGS" 73 | LIBS="$save_LIBS" 74 | 75 | # check env 76 | AC_PATH_PROG(ENV, env) 77 | AC_SUBST(ENV) 78 | 79 | # check python 80 | AC_ARG_WITH(python, 81 | AS_HELP_STRING([--with-python[=PATH]], 82 | [Select python2 or python3]), 83 | [PYTHON=$with_python], [] 84 | ) 85 | AM_PATH_PYTHON([2.5]) 86 | 87 | # --enable-boost 88 | AC_ARG_ENABLE(boost, 89 | AC_HELP_STRING([--enable-boost], 90 | [Use boost to replace stdc++0x.]), 91 | [enable_boost=$enableval], 92 | [enable_boost=no] 93 | ) 94 | if test x"$enable_boost" = x"yes"; then 95 | # check boost 96 | BOOST_REQUIRE([1.39]) 97 | BOOST_FIND_HEADER([boost/bind.hpp]) 98 | BOOST_FIND_HEADER([boost/signals2.hpp]) 99 | fi 100 | AM_CONDITIONAL(HAVE_BOOST, test x"$enable_boost" = x"yes") 101 | 102 | # --enable-opencc 103 | AC_ARG_ENABLE(opencc, 104 | AC_HELP_STRING([--enable-opencc], 105 | [Use opencc for simplified and traditional Chinese conversion]), 106 | [enable_opencc=$enableval], 107 | [enable_opencc=no] 108 | ) 109 | if test x"$enable_opencc" = x"yes"; then 110 | # check opencc 111 | PKG_CHECK_MODULES(OPENCC, [opencc >= 1.0.0], [ 112 | AC_DEFINE(HAVE_OPENCC, 1, [Define if found opencc]) 113 | ]) 114 | fi 115 | 116 | # define GETTEXT_* variables 117 | GETTEXT_PACKAGE=ibus-libzhuyin 118 | AC_SUBST(GETTEXT_PACKAGE) 119 | AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) 120 | 121 | AM_GNU_GETTEXT_VERSION([0.21]) 122 | AM_GNU_GETTEXT([external]) 123 | 124 | # Checks for GSettings. 125 | PKG_CHECK_MODULES(GIO2, [gio-2.0 >= 2.26.0]) 126 | 127 | GLIB_GSETTINGS 128 | 129 | # OUTPUT files 130 | AC_CONFIG_FILES([ po/Makefile.in 131 | Makefile 132 | src/Makefile 133 | src/libzhuyin.xml.in 134 | setup/Makefile 135 | setup/config.py 136 | setup/ibus-setup-libzhuyin 137 | ibus-libzhuyin.spec 138 | data/Makefile 139 | data/icons/Makefile 140 | data/model/Makefile 141 | data/model/table.conf 142 | ]) 143 | 144 | AC_OUTPUT 145 | 146 | AC_MSG_RESULT([ 147 | Build options: 148 | Version $VERSION 149 | Install prefix $prefix 150 | DBM $DATABASE_FORMAT 151 | Use boost $enable_boost 152 | Use opencc $enable_opencc 153 | Use libzhuyin $enable_libzhuyin 154 | ]) 155 | -------------------------------------------------------------------------------- /src/ZYConfig.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_CONFIG_H_ 22 | #define __ZY_CONFIG_H_ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | # include 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "ZYUtil.h" 33 | #include "ZYObject.h" 34 | 35 | namespace ZY { 36 | 37 | class Config { 38 | protected: 39 | Config (const std::string & name); 40 | virtual ~Config (void); 41 | 42 | public: 43 | zhuyin_option_t option (void) const { return m_option & m_option_mask; } 44 | guint orientation (void) const { return m_orientation; } 45 | guint pageSize (void) const { return m_page_size; } 46 | gboolean isZhuyin(void) const { return m_is_zhuyin; } 47 | ZhuyinScheme zhuyinScheme (void) const { return m_zhuyin_scheme; } 48 | FullPinyinScheme pinyinScheme (void) const { return m_pinyin_scheme; } 49 | gboolean needTone (void) const { return m_need_tone; } 50 | gboolean initChinese (void) const { return m_init_chinese; } 51 | gboolean initFullWidth (void) const { return m_init_full_width; } 52 | gboolean initTradChinese (void) const { return m_init_trad_chinese; } 53 | gboolean alwaysInputNumbers (void) const { return m_always_input_numbers; } 54 | gboolean spaceShowCandidates (void) const { return m_space_show_candidates; } 55 | gboolean candidatesAfterCursor (void) const { return m_candidates_after_cursor; } 56 | std::string candidateKeys (void) const { return m_candidate_keys; } 57 | 58 | gboolean easySymbol (void) const { return m_easy_symbol; } 59 | gboolean userSymbol (void) const { return m_user_symbol; } 60 | 61 | protected: 62 | bool read (const gchar * name, bool defval); 63 | gint read (const gchar * name, gint defval); 64 | std::string read (const gchar * name, const gchar * defval); 65 | void initDefaultValues (void); 66 | 67 | virtual void readDefaultValues (void); 68 | virtual gboolean valueChanged (const std::string &schema_id, 69 | const std::string &name, 70 | GVariant *value); 71 | private: 72 | static void valueChangedCallback (GSettings *settings, 73 | const gchar *name, 74 | Config *self); 75 | 76 | protected: 77 | GSettings *m_settings; 78 | std::string m_schema_id; 79 | 80 | zhuyin_option_t m_option; 81 | zhuyin_option_t m_option_mask; 82 | 83 | gint m_orientation; 84 | guint m_page_size; 85 | 86 | gboolean m_is_zhuyin; 87 | ZhuyinScheme m_zhuyin_scheme; 88 | FullPinyinScheme m_pinyin_scheme; 89 | gboolean m_need_tone; 90 | 91 | gboolean m_init_chinese; 92 | gboolean m_init_full_width; 93 | gboolean m_init_trad_chinese; 94 | 95 | gboolean m_always_input_numbers; 96 | gboolean m_space_show_candidates; 97 | gboolean m_candidates_after_cursor; 98 | 99 | std::string m_candidate_keys; 100 | 101 | gboolean m_easy_symbol; 102 | gboolean m_user_symbol; 103 | }; 104 | 105 | static inline bool 106 | normalizeGVariant (GVariant *value, bool defval) 107 | { 108 | if (value == NULL || 109 | g_variant_classify (value) != G_VARIANT_CLASS_BOOLEAN) { 110 | g_warn_if_reached (); 111 | return defval; 112 | } 113 | return g_variant_get_boolean (value); 114 | } 115 | 116 | static inline gint 117 | normalizeGVariant (GVariant *value, gint defval) 118 | { 119 | if (value == NULL || 120 | g_variant_classify (value) != G_VARIANT_CLASS_INT32) { 121 | g_warn_if_reached (); 122 | return defval; 123 | } 124 | return g_variant_get_int32 (value); 125 | } 126 | 127 | static inline std::string 128 | normalizeGVariant (GVariant *value, const std::string &defval) 129 | { 130 | if (value == NULL || 131 | g_variant_classify (value) != G_VARIANT_CLASS_STRING) { 132 | g_warn_if_reached (); 133 | return defval; 134 | } 135 | return g_variant_get_string (value, NULL); 136 | } 137 | 138 | }; 139 | #endif 140 | -------------------------------------------------------------------------------- /src/ZYZPhoneticEditor.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef __ZY_LIB_ZHUYIN_BASE_EDITOR_H_ 23 | #define __ZY_LIB_ZHUYIN_BASE_EDITOR_H_ 24 | 25 | #include 26 | #include "ZYLookupTable.h" 27 | #include "ZYZEnhancedEditor.h" 28 | #include "ZYSymbolLookup.h" 29 | #include 30 | 31 | namespace ZY { 32 | 33 | class ZhuyinEngine; 34 | 35 | class PhoneticSection; 36 | typedef std::shared_ptr PhoneticSectionPtr; 37 | 38 | class SymbolSection; 39 | typedef std::shared_ptr SymbolSectionPtr; 40 | 41 | class PhoneticEditor : public EnhancedEditor { 42 | friend class ZhuyinEngine; 43 | friend class SymbolSection; 44 | friend class PhoneticSection; 45 | 46 | protected: 47 | typedef std::vector zhuyin_instance_vec; 48 | 49 | public: 50 | PhoneticEditor (ZhuyinProperties & props, Config & config); 51 | virtual ~PhoneticEditor (void); 52 | 53 | public: 54 | /* virtual functions */ 55 | virtual void pageUp (void); 56 | virtual void pageDown (void); 57 | virtual void cursorUp (void); 58 | virtual void cursorDown (void); 59 | virtual void update (void); 60 | virtual void reset (void); 61 | virtual void candidateClicked (guint index, guint button, guint state); 62 | virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); 63 | virtual gboolean processEscape (guint keyval, guint keycode, guint modifiers); 64 | virtual gboolean processSpace (guint keyval, guint keycode, guint modifiers); 65 | virtual gboolean processCommit (guint keyval, guint keycode, guint modifiers); 66 | virtual gboolean processSelectCandidate (guint keyval, guint keycode, guint modifiers); 67 | virtual gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers); 68 | virtual gboolean processShowCandidateKey (guint keyval, guint keycode, guint modifiers); 69 | virtual gboolean processCandidateKey (guint keyval, guint keycode, guint modifiers); 70 | virtual gboolean processEasySymbolKey (guint keyval, guint keycode, guint modifiers); 71 | virtual gboolean processUserSymbolKey (guint keyval, guint keycode, guint modifiers); 72 | virtual void updateLookupTable (); 73 | virtual void updateLookupTableFast (); 74 | virtual void updateLookupTableLabel (); 75 | virtual gboolean fillLookupTableByPage (); 76 | 77 | virtual gboolean insertSymbol (guint keyval, guint keycode, guint modifiers); 78 | virtual gboolean insertNumbers (guint keyval); 79 | 80 | protected: 81 | gboolean prepareCandidates (void); 82 | gboolean selectCandidate (guint i); 83 | gboolean selectCandidateInPage (guint i); 84 | guint getCursorLeft (void); 85 | guint getCursorRight (void); 86 | 87 | void commit (const gchar *str); 88 | 89 | /* pure virtual functions */ 90 | virtual gboolean insert (guint keyval, guint keycode, guint modifiers) = 0; 91 | virtual gboolean removeCharBefore (void); 92 | virtual gboolean removeCharAfter (void); 93 | virtual gboolean moveCursorLeft (void); 94 | virtual gboolean moveCursorRight (void); 95 | virtual gboolean moveCursorToBegin (void); 96 | virtual gboolean moveCursorToEnd (void); 97 | virtual void commit (void) = 0; 98 | virtual void updateAuxiliaryText (void) = 0; 99 | virtual void updatePreeditText (void) = 0; 100 | virtual void updateZhuyin (void) = 0; 101 | 102 | /* for class DaChen26Editor to override this. */ 103 | virtual guint getZhuyinCursor (void); 104 | 105 | void resizeInstances (void); 106 | 107 | gboolean loadEasySymbolFile (const gchar * filename); 108 | 109 | /* varibles */ 110 | LookupTable m_lookup_table; 111 | String m_buffer; 112 | 113 | /* use libzhuyin here. */ 114 | zhuyin_instance_t *m_instance; 115 | 116 | enum InputState { 117 | STATE_INPUT = 0, // input state 118 | STATE_CANDIDATE_SHOWN, // candidates shown state 119 | STATE_BUILTIN_SYMBOL_SHOWN, // built-in symbol shown state 120 | STATE_BOPOMOFO_SYMBOL_SHOWN, // bopomofo symbol shown state 121 | STATE_USER_SYMBOL_LIST_ALL, // user symbol input state 122 | STATE_USER_SYMBOL_SHOWN, // user symbol shown state 123 | STATE_LAST, 124 | } m_input_state; 125 | 126 | SymbolSectionPtr m_symbol_sections[STATE_LAST]; 127 | PhoneticSectionPtr m_phonetic_section; 128 | 129 | zhuyin_instance_vec m_instances; 130 | 131 | SymbolLookup m_easy_symbols; 132 | 133 | /* move left one character when cursor is at the end, 134 | * only in candidates after cursor option. 135 | */ 136 | gboolean m_moved_left; 137 | }; 138 | 139 | }; 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /src/ZYMain.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * Copyright (c) 2014 Peng Wu 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifdef HAVE_CONFIG_H 24 | # include "config.h" 25 | #endif 26 | #include 27 | #include 28 | #include 29 | #include "ZYEngine.h" 30 | #include "ZYPointer.h" 31 | #include "ZYBus.h" 32 | #include "ZYConfig.h" 33 | #include "ZYZConfig.h" 34 | #include "ZYLibZhuyin.h" 35 | 36 | 37 | using namespace ZY; 38 | 39 | #define N_(text) text 40 | 41 | static Pointer factory; 42 | 43 | /* options */ 44 | static gboolean ibus = FALSE; 45 | static gboolean verbose = FALSE; 46 | 47 | static void 48 | show_version_and_quit (void) 49 | { 50 | g_print ("%s - Version %s\n", g_get_application_name (), VERSION); 51 | exit (EXIT_SUCCESS); 52 | } 53 | 54 | static const GOptionEntry entries[] = 55 | { 56 | { "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, 57 | (gpointer) show_version_and_quit, "Show the application's version.", NULL }, 58 | { "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus", NULL }, 59 | { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "verbose", NULL }, 60 | { NULL }, 61 | }; 62 | 63 | 64 | static void 65 | ibus_disconnected_cb (IBusBus *bus, 66 | gpointer user_data) 67 | { 68 | g_debug ("bus disconnected"); 69 | ibus_quit (); 70 | } 71 | 72 | 73 | static void 74 | start_component (void) 75 | { 76 | Pointer component; 77 | 78 | ibus_init (); 79 | Bus bus; 80 | 81 | if (!bus.isConnected ()) { 82 | g_warning ("Can not connect to ibus!"); 83 | exit (0); 84 | } 85 | 86 | if (!ibus_bus_get_config (bus)) { 87 | g_warning ("IBus config component is not ready!"); 88 | exit (0); 89 | } 90 | 91 | LibZhuyinBackEnd::init (); 92 | 93 | ZhuyinConfig::init (); 94 | 95 | g_signal_connect ((IBusBus *)bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); 96 | 97 | component = ibus_component_new ("org.freedesktop.IBus.Libzhuyin", 98 | N_("Libzhuyin input method"), 99 | VERSION, 100 | "GPL", 101 | "Peng Wu ", 102 | "https://github.com/libzhuyin/ibus-libzhuyin", 103 | "", 104 | "ibus-libzhuyin"); 105 | 106 | ibus_component_add_engine (component, 107 | ibus_engine_desc_new ("libzhuyin-debug", 108 | N_("New Zhuyin (debug)"), 109 | N_("New Zhuyin input method (debug)"), 110 | "zh_TW", 111 | "GPL", 112 | "Peng Wu \n" 113 | "Peng Huang \n" 114 | "BYVoid ", 115 | PKGDATADIR "/icons/ibus-zhuyin.svg", 116 | "us")); 117 | 118 | factory = ibus_factory_new (ibus_bus_get_connection (bus)); 119 | 120 | if (ibus) { 121 | ibus_factory_add_engine (factory, "libzhuyin", IBUS_TYPE_ZHUYIN_ENGINE); 122 | 123 | ibus_bus_request_name (bus, "org.freedesktop.IBus.Libzhuyin", 0); 124 | } 125 | else { 126 | ibus_factory_add_engine (factory, "libzhuyin-debug", IBUS_TYPE_ZHUYIN_ENGINE); 127 | ibus_bus_register_component (bus, component); 128 | } 129 | 130 | ibus_main (); 131 | } 132 | 133 | #include 134 | 135 | static void 136 | sigterm_cb (int sig) 137 | { 138 | LibZhuyinBackEnd::finalize (); 139 | 140 | ::exit (EXIT_FAILURE); 141 | } 142 | 143 | static void 144 | atexit_cb (void) 145 | { 146 | LibZhuyinBackEnd::finalize (); 147 | } 148 | 149 | 150 | int 151 | main (gint argc, gchar **argv) 152 | { 153 | GError *error = NULL; 154 | GOptionContext *context; 155 | 156 | setlocale (LC_ALL, ""); 157 | 158 | context = g_option_context_new ("- ibus zhuyin engine component"); 159 | 160 | g_option_context_add_main_entries (context, entries, "ibus-libzhuyin"); 161 | 162 | if (!g_option_context_parse (context, &argc, &argv, &error)) { 163 | g_print ("Option parsing failed: %s\n", error->message); 164 | exit (-1); 165 | } 166 | 167 | ::signal (SIGTERM, sigterm_cb); 168 | ::signal (SIGINT, sigterm_cb); 169 | g_atexit (atexit_cb); 170 | 171 | start_component (); 172 | return 0; 173 | } 174 | -------------------------------------------------------------------------------- /src/ZYEditor.h: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #ifndef __ZY_EDITOR_H_ 22 | #define __ZY_EDITOR_H_ 23 | 24 | #include 25 | #include "ZYSignal.h" 26 | #include "ZYString.h" 27 | #include "ZYUtil.h" 28 | 29 | namespace ZY { 30 | 31 | class Text; 32 | class LookupTable; 33 | class ZhuyinProperties; 34 | class Config; 35 | 36 | class Editor; 37 | typedef std::shared_ptr EditorPtr; 38 | 39 | class Editor { 40 | public: 41 | Editor (ZhuyinProperties & prop, Config & config); 42 | virtual ~Editor (void); 43 | 44 | virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); 45 | virtual void pageUp (void); 46 | virtual void pageDown (void); 47 | virtual void cursorUp (void); 48 | virtual void cursorDown (void); 49 | virtual void update (void); 50 | virtual void reset (void); 51 | virtual void candidateClicked (guint index, guint button, guint state); 52 | 53 | const String & text (void) const 54 | { 55 | return m_text; 56 | } 57 | 58 | void setText (const String & text, guint cursor) 59 | { 60 | m_text = text; 61 | m_cursor = cursor; 62 | } 63 | 64 | /* signals */ 65 | signal & signalCommitText (void) { return m_signal_commit_text; } 66 | 67 | signal & signalUpdatePreeditText (void) 68 | { return m_signal_update_preedit_text; } 69 | signal & signalShowPreeditText (void) { return m_signal_show_preedit_text; } 70 | signal & signalHidePreeditText (void) { return m_signal_hide_preedit_text; } 71 | 72 | signal & signalUpdateAuxiliaryText (void) 73 | { return m_signal_update_auxiliary_text; } 74 | signal & signalShowAuxiliaryText (void) { return m_signal_show_auxiliary_text; } 75 | signal & signalHideAuxiliaryText (void) { return m_signal_hide_auxiliary_text; } 76 | 77 | signal & signalUpdateLookupTable (void) 78 | { return m_signal_update_lookup_table; } 79 | signal & signalUpdateLookupTableFast (void) 80 | { return m_signal_update_lookup_table_fast; } 81 | signal & signalShowLookupTable (void) { return m_signal_show_lookup_table; } 82 | signal & signalHideLookupTable (void) { return m_signal_hide_lookup_table; } 83 | 84 | protected: 85 | /* methods */ 86 | void commitText (Text & text) const 87 | { 88 | m_signal_commit_text (text); 89 | } 90 | 91 | void updatePreeditText (Text & text, guint cursor, gboolean visible) const 92 | { 93 | m_signal_update_preedit_text (text, cursor, visible); 94 | } 95 | 96 | void showPreeditText (void) const 97 | { 98 | m_signal_show_preedit_text (); 99 | } 100 | 101 | void hidePreeditText (void) const 102 | { 103 | m_signal_hide_preedit_text (); 104 | } 105 | 106 | void updateAuxiliaryText (Text & text, gboolean visible) const 107 | { 108 | m_signal_update_auxiliary_text (text, visible); 109 | } 110 | 111 | void showAuxiliaryText (void) const 112 | { 113 | m_signal_show_auxiliary_text (); 114 | } 115 | 116 | void hideAuxiliaryText (void) const 117 | { 118 | m_signal_hide_auxiliary_text (); 119 | } 120 | 121 | void updateLookupTable (LookupTable & table, gboolean visible) const 122 | { 123 | m_signal_update_lookup_table (table, visible); 124 | } 125 | 126 | void updateLookupTableFast (LookupTable & table, gboolean visible) const 127 | { 128 | m_signal_update_lookup_table_fast (table, visible); 129 | } 130 | 131 | void showLookupTable (void) const 132 | { 133 | m_signal_show_lookup_table (); 134 | } 135 | 136 | void hideLookupTable (void) const 137 | { 138 | m_signal_hide_lookup_table (); 139 | } 140 | 141 | protected: 142 | /* signals */ 143 | signal m_signal_commit_text; 144 | signal m_signal_update_preedit_text; 145 | signal m_signal_show_preedit_text; 146 | signal m_signal_hide_preedit_text; 147 | signal m_signal_update_auxiliary_text; 148 | signal m_signal_show_auxiliary_text; 149 | signal m_signal_hide_auxiliary_text; 150 | signal m_signal_update_lookup_table; 151 | signal m_signal_update_lookup_table_fast; 152 | signal m_signal_show_lookup_table; 153 | signal m_signal_hide_lookup_table; 154 | 155 | protected: 156 | String m_text; 157 | guint m_cursor; 158 | ZhuyinProperties & m_props; 159 | Config & m_config; 160 | }; 161 | 162 | }; 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /src/ZYZhuyinProperties.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2008-2010 Peng Huang 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | #include "ZYZhuyinProperties.h" 22 | #include 23 | #include "ZYText.h" 24 | #include "ZYConfig.h" 25 | 26 | namespace ZY { 27 | 28 | #define _(text) (dgettext (GETTEXT_PACKAGE, text)) 29 | #define N_(text) text 30 | 31 | ZhuyinProperties::ZhuyinProperties (Config & config) 32 | : m_config (config), 33 | m_mode_chinese (m_config.initChinese ()), 34 | m_mode_full_width (m_config.initFullWidth ()), 35 | m_mode_trad (m_config.initTradChinese ()), 36 | m_prop_chinese ("InputMode", 37 | PROP_TYPE_NORMAL, 38 | StaticText (m_mode_chinese ? 39 | _("Chinese") : 40 | _("English")), 41 | m_mode_chinese ? 42 | PKGDATADIR"/icons/chinese.svg" : 43 | PKGDATADIR"/icons/english.svg", 44 | StaticText (m_mode_chinese ? 45 | _("Switch to English Mode") : 46 | _("Switch to Chinese Mode"))), 47 | m_prop_full_width ("mode.full", 48 | PROP_TYPE_NORMAL, 49 | StaticText (m_mode_full_width ? 50 | _("Full Width") : 51 | _("Half Width")), 52 | m_mode_full_width ? 53 | PKGDATADIR"/icons/full.svg" : 54 | PKGDATADIR"/icons/half.svg", 55 | StaticText (m_mode_full_width ? 56 | _("Switch to Half Width Mode"): 57 | _("Switch to Full Width Mode"))), 58 | m_prop_trad ( "mode.trad", 59 | PROP_TYPE_NORMAL, 60 | StaticText (m_mode_trad ? 61 | _("Traditional Chinese") : 62 | _("Simplified Chinese")), 63 | m_mode_trad ? 64 | PKGDATADIR"/icons/trad-chinese.svg" : 65 | PKGDATADIR"/icons/simp-chinese.svg", 66 | StaticText (m_mode_trad ? 67 | _("Switch to Simplfied Chinese Mode"): 68 | _("Switch to Traditional Chinese Mode"))), 69 | m_prop_setup ("setup", 70 | PROP_TYPE_NORMAL, 71 | StaticText (_("Preferences")), 72 | "ibus-setup", 73 | StaticText (_("Preferences"))) 74 | { 75 | if (m_mode_chinese) 76 | m_prop_chinese.setSymbol(N_("中")); 77 | else 78 | m_prop_chinese.setSymbol(N_("英")); 79 | 80 | m_props.append (m_prop_chinese); 81 | m_props.append (m_prop_full_width); 82 | m_props.append (m_prop_trad); 83 | m_props.append (m_prop_setup); 84 | 85 | } 86 | 87 | void 88 | ZhuyinProperties::toggleModeChinese (void) 89 | { 90 | m_mode_chinese = ! m_mode_chinese; 91 | m_prop_chinese.setLabel (m_mode_chinese ? 92 | _("Chinese") : 93 | _("English")); 94 | 95 | if (m_mode_chinese) 96 | m_prop_chinese.setSymbol(N_("中")); 97 | else 98 | m_prop_chinese.setSymbol(N_("英")); 99 | 100 | m_prop_chinese.setIcon (m_mode_chinese ? 101 | PKGDATADIR"/icons/chinese.svg" : 102 | PKGDATADIR"/icons/english.svg"); 103 | m_prop_chinese.setTooltip (m_mode_chinese ? 104 | _("Switch to English Mode") : 105 | _("Switch to Chinese Mode")); 106 | updateProperty (m_prop_chinese); 107 | } 108 | 109 | void 110 | ZhuyinProperties::toggleModeFullWidth (void) 111 | { 112 | m_mode_full_width = !m_mode_full_width; 113 | m_prop_full_width.setLabel (m_mode_full_width ? 114 | _("Full Width") : 115 | _("Half Width")); 116 | m_prop_full_width.setIcon (m_mode_full_width ? 117 | PKGDATADIR"/icons/full.svg" : 118 | PKGDATADIR"/icons/half.svg"); 119 | m_prop_full_width.setTooltip (m_mode_full_width ? 120 | _("Switch to Half Width Mode"): 121 | _("Switch to Full Width Mode")); 122 | updateProperty (m_prop_full_width); 123 | } 124 | 125 | void 126 | ZhuyinProperties::toggleModeTrad (void) 127 | { 128 | m_mode_trad = ! m_mode_trad; 129 | m_prop_trad.setLabel (m_mode_trad ? 130 | _("Traditional Chinese") : 131 | _("Simplified Chinese")); 132 | m_prop_trad.setIcon (m_mode_trad ? 133 | PKGDATADIR"/icons/trad-chinese.svg" : 134 | PKGDATADIR"/icons/simp-chinese.svg"); 135 | m_prop_trad.setTooltip(m_mode_trad ? 136 | _("Switch to Simplfied Chinese Mode"): 137 | _("Switch to Traditional Chinese Mode")); 138 | updateProperty (m_prop_trad); 139 | } 140 | 141 | void 142 | ZhuyinProperties::reset (void) 143 | { 144 | if (modeChinese () != m_config.initChinese ()) { 145 | toggleModeChinese (); 146 | } 147 | if (modeFullWidth () != m_config.initFullWidth ()) { 148 | toggleModeFullWidth (); 149 | } 150 | if (modeTrad () != m_config.initTradChinese ()) { 151 | toggleModeTrad (); 152 | } 153 | } 154 | 155 | gboolean 156 | ZhuyinProperties::propertyActivate (const gchar *prop_name, guint prop_state) { 157 | const static std::string mode_chinese ("InputMode"); 158 | const static std::string mode_full ("mode.full"); 159 | const static std::string mode_trad ("mode.trad"); 160 | 161 | if (mode_chinese == prop_name) { 162 | toggleModeChinese (); 163 | return TRUE; 164 | } 165 | else if (mode_full == prop_name) { 166 | toggleModeFullWidth (); 167 | return TRUE; 168 | } 169 | else if (mode_trad == prop_name) { 170 | toggleModeTrad (); 171 | return TRUE; 172 | } 173 | return FALSE; 174 | } 175 | 176 | 177 | }; 178 | -------------------------------------------------------------------------------- /src/ZYLibZhuyin.cc: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4: 2 | * 3 | * ibus-libzhuyin - New Zhuyin engine based on libzhuyin for IBus 4 | * 5 | * Copyright (c) 2014 Peng Wu 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "ZYLibZhuyin.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include "ZYZConfig.h" 28 | 29 | #define LIBZHUYIN_SAVE_TIMEOUT (5 * 60) 30 | 31 | namespace ZY { 32 | 33 | std::unique_ptr LibZhuyinBackEnd::m_instance; 34 | 35 | static LibZhuyinBackEnd libzhuyin_backend; 36 | 37 | LibZhuyinBackEnd::LibZhuyinBackEnd () { 38 | m_timeout_id = 0; 39 | m_timer = g_timer_new (); 40 | m_zhuyin_context = NULL; 41 | } 42 | 43 | LibZhuyinBackEnd::~LibZhuyinBackEnd () { 44 | g_timer_destroy (m_timer); 45 | if (m_timeout_id != 0) { 46 | saveUserDB (); 47 | g_source_remove (m_timeout_id); 48 | } 49 | 50 | if (m_zhuyin_context) 51 | zhuyin_fini (m_zhuyin_context); 52 | m_zhuyin_context = NULL; 53 | } 54 | 55 | zhuyin_context_t * 56 | LibZhuyinBackEnd::initZhuyinContext (Config *config) 57 | { 58 | zhuyin_context_t * context = NULL; 59 | 60 | gchar * userdir = g_build_filename (g_get_user_cache_dir (), 61 | "ibus", "libzhuyin", NULL); 62 | int retval = g_mkdir_with_parents (userdir, 0700); 63 | if (retval) { 64 | g_free (userdir); userdir = NULL; 65 | } 66 | context = zhuyin_init (MODEL_DATADIR, userdir); 67 | g_free (userdir); 68 | 69 | /* load user phrase library. */ 70 | zhuyin_load_phrase_library (context, USER_DICTIONARY); 71 | 72 | return context; 73 | } 74 | 75 | gboolean 76 | LibZhuyinBackEnd::setZhuyinOptions (Config *config) 77 | { 78 | if (NULL == m_zhuyin_context) 79 | return FALSE; 80 | 81 | if (config->isZhuyin ()) 82 | zhuyin_set_chewing_scheme (m_zhuyin_context, 83 | config->zhuyinScheme ()); 84 | else 85 | zhuyin_set_full_pinyin_scheme (m_zhuyin_context, 86 | config->pinyinScheme ()); 87 | 88 | zhuyin_option_t options = config->option (); 89 | 90 | if (config->needTone ()) 91 | options |= FORCE_TONE; 92 | 93 | zhuyin_set_options (m_zhuyin_context, options); 94 | return TRUE; 95 | } 96 | 97 | 98 | zhuyin_instance_t * 99 | LibZhuyinBackEnd::allocZhuyinInstance () 100 | { 101 | Config * config = &ZhuyinConfig::instance (); 102 | if (NULL == m_zhuyin_context) { 103 | m_zhuyin_context = initZhuyinContext (config); 104 | } 105 | 106 | setZhuyinOptions (config); 107 | return zhuyin_alloc_instance (m_zhuyin_context); 108 | } 109 | 110 | void 111 | LibZhuyinBackEnd::freeZhuyinInstance (zhuyin_instance_t *instance) 112 | { 113 | if (instance) 114 | zhuyin_free_instance (instance); 115 | } 116 | 117 | void 118 | LibZhuyinBackEnd::init (void) { 119 | g_assert (NULL == m_instance.get ()); 120 | LibZhuyinBackEnd * backend = new LibZhuyinBackEnd; 121 | m_instance.reset (backend); 122 | } 123 | 124 | void 125 | LibZhuyinBackEnd::finalize (void) { 126 | m_instance.reset (); 127 | } 128 | 129 | gboolean 130 | LibZhuyinBackEnd::saveUserDB (void) 131 | { 132 | if (m_zhuyin_context) 133 | zhuyin_save (m_zhuyin_context); 134 | return TRUE; 135 | } 136 | 137 | void 138 | LibZhuyinBackEnd::modified (void) 139 | { 140 | /* Restart the timer */ 141 | g_timer_start (m_timer); 142 | 143 | if (m_timeout_id != 0) 144 | return; 145 | 146 | m_timeout_id = g_timeout_add_seconds (LIBZHUYIN_SAVE_TIMEOUT, 147 | LibZhuyinBackEnd::timeoutCallback, 148 | static_cast (this)); 149 | } 150 | 151 | gboolean 152 | LibZhuyinBackEnd::importZhuyinDictionary (const char * filename) 153 | { 154 | /* user phrase library should be already loaded here. */ 155 | FILE * dictfile = fopen (filename, "r"); 156 | if (NULL == dictfile) 157 | return FALSE; 158 | 159 | import_iterator_t * iter = zhuyin_begin_add_phrases 160 | (m_zhuyin_context, USER_DICTIONARY); 161 | 162 | if (NULL == iter) { 163 | fclose(dictfile); 164 | return FALSE; 165 | } 166 | 167 | char* linebuf = NULL; size_t size = 0; ssize_t read; 168 | while ((read = getline (&linebuf, &size, dictfile)) != -1) { 169 | if (0 == strlen (linebuf)) 170 | continue; 171 | 172 | if ( '\n' == linebuf[strlen (linebuf) - 1] ) { 173 | linebuf[strlen (linebuf) - 1] = '\0'; 174 | } 175 | 176 | gchar ** items = g_strsplit_set (linebuf, " \t", 2); 177 | guint len = g_strv_length (items); 178 | 179 | if (2 != len) 180 | continue; 181 | 182 | gchar * phrase = items[0]; 183 | gchar * zhuyin = items[1]; 184 | 185 | zhuyin_iterator_add_phrase (iter, phrase, zhuyin, -1); 186 | 187 | g_strfreev (items); 188 | } 189 | 190 | zhuyin_end_add_phrases (iter); 191 | fclose (dictfile); 192 | 193 | zhuyin_save (m_zhuyin_context); 194 | return TRUE; 195 | } 196 | 197 | gboolean 198 | LibZhuyinBackEnd::clearZhuyinUserData (const char * target) 199 | { 200 | if (NULL == m_zhuyin_context) 201 | return FALSE; 202 | 203 | if (0 == strcmp ("all", target)) 204 | zhuyin_mask_out (m_zhuyin_context, 0x0, 0x0); 205 | else if (0 == strcmp ("user", target)) 206 | zhuyin_mask_out (m_zhuyin_context, PHRASE_INDEX_LIBRARY_MASK, 207 | PHRASE_INDEX_MAKE_TOKEN (USER_DICTIONARY, null_token)); 208 | else 209 | g_warning ("unknown clear target: %s.\n", target); 210 | 211 | zhuyin_save (m_zhuyin_context); 212 | return TRUE; 213 | } 214 | 215 | gboolean 216 | LibZhuyinBackEnd::timeoutCallback (gpointer data) 217 | { 218 | LibZhuyinBackEnd *self = static_cast(data); 219 | 220 | /* Get the elapsed time since last modification of database. */ 221 | guint elapsed = (guint)g_timer_elapsed (self->m_timer, NULL); 222 | 223 | if (elapsed >= LIBZHUYIN_SAVE_TIMEOUT && 224 | self->saveUserDB ()) { 225 | self->m_timeout_id = 0; 226 | return FALSE; 227 | } 228 | 229 | return TRUE; 230 | } 231 | 232 | }; 233 | -------------------------------------------------------------------------------- /data/icons/full.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 23 | 25 | 29 | 33 | 34 | 41 | 50 | 59 | 68 | 77 | 86 | 95 | 104 | 113 | 123 | 132 | 133 | 152 | 154 | 155 | 157 | image/svg+xml 158 | 160 | 161 | 162 | 163 | 167 | 177 | 187 | 197 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /po/ibus-libzhuyin.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR Free Software Foundation, Inc. 3 | # This file is distributed under the same license as the ibus-libzhuyin package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: ibus-libzhuyin 1.10.5\n" 10 | "Report-Msgid-Bugs-To: https://github.com/libzhuyin/ibus-libzhuyin/issues/" 11 | "new\n" 12 | "POT-Creation-Date: 2025-11-06 12:25+0800\n" 13 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 | "Last-Translator: FULL NAME \n" 15 | "Language-Team: LANGUAGE \n" 16 | "Language: \n" 17 | "MIME-Version: 1.0\n" 18 | "Content-Type: text/plain; charset=UTF-8\n" 19 | "Content-Transfer-Encoding: 8bit\n" 20 | 21 | #: src/ZYZhuyinProperties.cc:39 src/ZYZhuyinProperties.cc:92 22 | msgid "Chinese" 23 | msgstr "" 24 | 25 | #: src/ZYZhuyinProperties.cc:40 src/ZYZhuyinProperties.cc:93 26 | msgid "English" 27 | msgstr "" 28 | 29 | #: src/ZYZhuyinProperties.cc:45 src/ZYZhuyinProperties.cc:104 30 | msgid "Switch to English Mode" 31 | msgstr "" 32 | 33 | #: src/ZYZhuyinProperties.cc:46 src/ZYZhuyinProperties.cc:105 34 | msgid "Switch to Chinese Mode" 35 | msgstr "" 36 | 37 | #: src/ZYZhuyinProperties.cc:50 src/ZYZhuyinProperties.cc:114 38 | msgid "Full Width" 39 | msgstr "" 40 | 41 | #: src/ZYZhuyinProperties.cc:51 src/ZYZhuyinProperties.cc:115 42 | msgid "Half Width" 43 | msgstr "" 44 | 45 | #: src/ZYZhuyinProperties.cc:56 src/ZYZhuyinProperties.cc:120 46 | msgid "Switch to Half Width Mode" 47 | msgstr "" 48 | 49 | #: src/ZYZhuyinProperties.cc:57 src/ZYZhuyinProperties.cc:121 50 | msgid "Switch to Full Width Mode" 51 | msgstr "" 52 | 53 | #: src/ZYZhuyinProperties.cc:61 src/ZYZhuyinProperties.cc:130 54 | msgid "Traditional Chinese" 55 | msgstr "" 56 | 57 | #: src/ZYZhuyinProperties.cc:62 src/ZYZhuyinProperties.cc:131 58 | msgid "Simplified Chinese" 59 | msgstr "" 60 | 61 | #: src/ZYZhuyinProperties.cc:67 src/ZYZhuyinProperties.cc:136 62 | msgid "Switch to Simplfied Chinese Mode" 63 | msgstr "" 64 | 65 | #: src/ZYZhuyinProperties.cc:68 src/ZYZhuyinProperties.cc:137 66 | msgid "Switch to Traditional Chinese Mode" 67 | msgstr "" 68 | 69 | #: src/ZYZhuyinProperties.cc:71 src/ZYZhuyinProperties.cc:73 70 | msgid "Preferences" 71 | msgstr "" 72 | 73 | #: src/ZYZhuyinProperties.cc:76 src/ZYZhuyinProperties.cc:96 74 | msgid "中" 75 | msgstr "" 76 | 77 | #: src/ZYZhuyinProperties.cc:78 src/ZYZhuyinProperties.cc:98 78 | msgid "英" 79 | msgstr "" 80 | 81 | #: src/ZYMain.cc:98 82 | msgid "Libzhuyin input method" 83 | msgstr "" 84 | 85 | #: src/ZYMain.cc:108 86 | msgid "New Zhuyin (debug)" 87 | msgstr "" 88 | 89 | #: src/ZYMain.cc:109 90 | msgid "New Zhuyin input method (debug)" 91 | msgstr "" 92 | 93 | #: setup/main.py:281 94 | msgid "Please choose a file" 95 | msgstr "" 96 | 97 | #: setup/main.py:307 98 | #, python-format 99 | msgid "New Zhuyin %s" 100 | msgstr "" 101 | 102 | #: setup/config.py:29 103 | msgid "New Zhuyin" 104 | msgstr "" 105 | 106 | #: setup/ibus-libzhuyin-preferences.ui:23 107 | msgid "Standard" 108 | msgstr "" 109 | 110 | #: setup/ibus-libzhuyin-preferences.ui:28 111 | msgid "HSU" 112 | msgstr "" 113 | 114 | #: setup/ibus-libzhuyin-preferences.ui:33 115 | msgid "IBM" 116 | msgstr "" 117 | 118 | #: setup/ibus-libzhuyin-preferences.ui:38 119 | msgid "GinYieh" 120 | msgstr "" 121 | 122 | #: setup/ibus-libzhuyin-preferences.ui:43 123 | msgid "Eten" 124 | msgstr "" 125 | 126 | #: setup/ibus-libzhuyin-preferences.ui:48 127 | msgid "Eten26" 128 | msgstr "" 129 | 130 | #: setup/ibus-libzhuyin-preferences.ui:53 131 | msgid "Standard Dvorak" 132 | msgstr "" 133 | 134 | #: setup/ibus-libzhuyin-preferences.ui:58 135 | msgid "HSU Dvorak" 136 | msgstr "" 137 | 138 | #: setup/ibus-libzhuyin-preferences.ui:63 139 | msgid "DaChen CP26" 140 | msgstr "" 141 | 142 | #: setup/ibus-libzhuyin-preferences.ui:68 143 | msgid "Hanyu Pinyin" 144 | msgstr "" 145 | 146 | #: setup/ibus-libzhuyin-preferences.ui:73 147 | msgid "Luoma Pinyin" 148 | msgstr "" 149 | 150 | #: setup/ibus-libzhuyin-preferences.ui:78 151 | msgid "Secondary Bopomofo" 152 | msgstr "" 153 | 154 | #: setup/ibus-libzhuyin-preferences.ui:134 155 | msgid "Use Chinese Mode When Start-up" 156 | msgstr "" 157 | 158 | #: setup/ibus-libzhuyin-preferences.ui:152 159 | msgid "Use Full Width When Start-up" 160 | msgstr "" 161 | 162 | #: setup/ibus-libzhuyin-preferences.ui:170 163 | msgid "Use Traditional Chinese When Start-up" 164 | msgstr "" 165 | 166 | #: setup/ibus-libzhuyin-preferences.ui:188 167 | msgid "Always Input Numbers by Input Pad" 168 | msgstr "" 169 | 170 | #: setup/ibus-libzhuyin-preferences.ui:206 171 | msgid "Use Space Key to Show Candidates" 172 | msgstr "" 173 | 174 | #: setup/ibus-libzhuyin-preferences.ui:224 175 | msgid "Show Candidates After the Cursor" 176 | msgstr "" 177 | 178 | #: setup/ibus-libzhuyin-preferences.ui:246 179 | msgid "Inputting" 180 | msgstr "" 181 | 182 | #: setup/ibus-libzhuyin-preferences.ui:271 183 | msgid "Keyboard Layout" 184 | msgstr "" 185 | 186 | #: setup/ibus-libzhuyin-preferences.ui:285 187 | msgid "Candidate Choose Keys" 188 | msgstr "" 189 | 190 | #: setup/ibus-libzhuyin-preferences.ui:319 191 | msgid "Candidates per Page" 192 | msgstr "" 193 | 194 | #: setup/ibus-libzhuyin-preferences.ui:369 195 | msgid "Require tone information" 196 | msgstr "" 197 | 198 | #: setup/ibus-libzhuyin-preferences.ui:397 199 | msgid "Keyboard" 200 | msgstr "" 201 | 202 | #: setup/ibus-libzhuyin-preferences.ui:412 203 | msgid "Enable Fuzzy Zhuyin" 204 | msgstr "" 205 | 206 | #: setup/ibus-libzhuyin-preferences.ui:430 207 | msgid "l <=> n" 208 | msgstr "" 209 | 210 | #: setup/ibus-libzhuyin-preferences.ui:447 211 | msgid "f <=> h" 212 | msgstr "" 213 | 214 | #: setup/ibus-libzhuyin-preferences.ui:464 215 | msgid "l <=> r" 216 | msgstr "" 217 | 218 | #: setup/ibus-libzhuyin-preferences.ui:481 219 | msgid "g <=> k" 220 | msgstr "" 221 | 222 | #: setup/ibus-libzhuyin-preferences.ui:498 223 | msgid "c <=> ch" 224 | msgstr "" 225 | 226 | #: setup/ibus-libzhuyin-preferences.ui:515 227 | msgid "z <=> zh" 228 | msgstr "" 229 | 230 | #: setup/ibus-libzhuyin-preferences.ui:532 231 | msgid "s <=> sh" 232 | msgstr "" 233 | 234 | #: setup/ibus-libzhuyin-preferences.ui:549 235 | msgid "an <=> ang" 236 | msgstr "" 237 | 238 | #: setup/ibus-libzhuyin-preferences.ui:566 239 | msgid "in <=> ing" 240 | msgstr "" 241 | 242 | #: setup/ibus-libzhuyin-preferences.ui:583 243 | msgid "en <=> eng" 244 | msgstr "" 245 | 246 | #: setup/ibus-libzhuyin-preferences.ui:616 247 | msgid "Fuzzy Zhuyin" 248 | msgstr "" 249 | 250 | #: setup/ibus-libzhuyin-preferences.ui:638 251 | msgid "User Symbols" 252 | msgstr "" 253 | 254 | #: setup/ibus-libzhuyin-preferences.ui:654 255 | #: setup/ibus-libzhuyin-preferences.ui:697 256 | msgid "Edit" 257 | msgstr "" 258 | 259 | #: setup/ibus-libzhuyin-preferences.ui:681 260 | msgid "Easy Symbols" 261 | msgstr "" 262 | 263 | #: setup/ibus-libzhuyin-preferences.ui:727 264 | #: setup/ibus-libzhuyin-preferences.ui:844 265 | msgid "User Phrases" 266 | msgstr "" 267 | 268 | #: setup/ibus-libzhuyin-preferences.ui:737 269 | msgid "Clear" 270 | msgstr "" 271 | 272 | #: setup/ibus-libzhuyin-preferences.ui:752 273 | msgid "Import" 274 | msgstr "" 275 | 276 | #: setup/ibus-libzhuyin-preferences.ui:780 277 | msgid "Clear All Data" 278 | msgstr "" 279 | 280 | #: setup/ibus-libzhuyin-preferences.ui:811 281 | msgid "" 282 | "Dictionary File Format:\n" 283 | " Each line contains the following:\n" 284 | " \"phrase zhuyin\"\n" 285 | " like \"你好 ㄋㄧˇ ㄏㄠˇ\"." 286 | msgstr "" 287 | 288 | #: setup/ibus-libzhuyin-preferences.ui:822 289 | msgid "Help" 290 | msgstr "" 291 | 292 | #: setup/ibus-libzhuyin-preferences.ui:883 293 | msgid "IBus Zhuyin %s" 294 | msgstr "" 295 | 296 | #: setup/ibus-libzhuyin-preferences.ui:896 297 | msgid "New Zhuyin input method for IBus" 298 | msgstr "" 299 | 300 | #: setup/ibus-libzhuyin-preferences.ui:908 301 | msgid "Copyright (c) 2013-2014 Peng Wu" 302 | msgstr "" 303 | 304 | #: setup/ibus-libzhuyin-preferences.ui:936 305 | msgid "" 306 | "\n" 307 | "Authors:\n" 308 | "Peng Wu\n" 309 | "Peng Huang\n" 310 | "...\n" 311 | "\n" 312 | "Contributors:\n" 313 | "...\n" 314 | "" 315 | msgstr "" 316 | 317 | #: setup/ibus-libzhuyin-preferences.ui:965 318 | msgid "About" 319 | msgstr "" 320 | 321 | #: data/ibus-setup-libzhuyin.desktop.in:2 322 | msgid "IBus LibZhuyin Setup" 323 | msgstr "" 324 | 325 | #: data/ibus-setup-libzhuyin.desktop.in:3 326 | msgid "Set ibus-libzhuyin Preferences" 327 | msgstr "" 328 | -------------------------------------------------------------------------------- /po/ru.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR Free Software Foundation, Inc. 3 | # This file is distributed under the same license as the ibus-libzhuyin package. 4 | # Aleksandr Sidorenko , 2025. 5 | msgid "" 6 | msgstr "" 7 | "Project-Id-Version: ibus-libzhuyin 1.10.2\n" 8 | "Report-Msgid-Bugs-To: https://github.com/libzhuyin/ibus-libzhuyin/issues/" 9 | "new\n" 10 | "POT-Creation-Date: 2025-11-06 12:25+0800\n" 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: Automatically generated\n" 13 | "Language-Team: none\n" 14 | "Language: ru\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " 19 | "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" 20 | 21 | #: src/ZYZhuyinProperties.cc:39 src/ZYZhuyinProperties.cc:92 22 | msgid "Chinese" 23 | msgstr "" 24 | 25 | #: src/ZYZhuyinProperties.cc:40 src/ZYZhuyinProperties.cc:93 26 | msgid "English" 27 | msgstr "" 28 | 29 | #: src/ZYZhuyinProperties.cc:45 src/ZYZhuyinProperties.cc:104 30 | msgid "Switch to English Mode" 31 | msgstr "" 32 | 33 | #: src/ZYZhuyinProperties.cc:46 src/ZYZhuyinProperties.cc:105 34 | msgid "Switch to Chinese Mode" 35 | msgstr "" 36 | 37 | #: src/ZYZhuyinProperties.cc:50 src/ZYZhuyinProperties.cc:114 38 | msgid "Full Width" 39 | msgstr "" 40 | 41 | #: src/ZYZhuyinProperties.cc:51 src/ZYZhuyinProperties.cc:115 42 | msgid "Half Width" 43 | msgstr "" 44 | 45 | #: src/ZYZhuyinProperties.cc:56 src/ZYZhuyinProperties.cc:120 46 | msgid "Switch to Half Width Mode" 47 | msgstr "" 48 | 49 | #: src/ZYZhuyinProperties.cc:57 src/ZYZhuyinProperties.cc:121 50 | msgid "Switch to Full Width Mode" 51 | msgstr "" 52 | 53 | #: src/ZYZhuyinProperties.cc:61 src/ZYZhuyinProperties.cc:130 54 | msgid "Traditional Chinese" 55 | msgstr "" 56 | 57 | #: src/ZYZhuyinProperties.cc:62 src/ZYZhuyinProperties.cc:131 58 | msgid "Simplified Chinese" 59 | msgstr "" 60 | 61 | #: src/ZYZhuyinProperties.cc:67 src/ZYZhuyinProperties.cc:136 62 | msgid "Switch to Simplfied Chinese Mode" 63 | msgstr "" 64 | 65 | #: src/ZYZhuyinProperties.cc:68 src/ZYZhuyinProperties.cc:137 66 | msgid "Switch to Traditional Chinese Mode" 67 | msgstr "" 68 | 69 | #: src/ZYZhuyinProperties.cc:71 src/ZYZhuyinProperties.cc:73 70 | msgid "Preferences" 71 | msgstr "" 72 | 73 | #: src/ZYZhuyinProperties.cc:76 src/ZYZhuyinProperties.cc:96 74 | msgid "中" 75 | msgstr "" 76 | 77 | #: src/ZYZhuyinProperties.cc:78 src/ZYZhuyinProperties.cc:98 78 | msgid "英" 79 | msgstr "" 80 | 81 | #: src/ZYMain.cc:98 82 | msgid "Libzhuyin input method" 83 | msgstr "" 84 | 85 | #: src/ZYMain.cc:108 86 | msgid "New Zhuyin (debug)" 87 | msgstr "" 88 | 89 | #: src/ZYMain.cc:109 90 | msgid "New Zhuyin input method (debug)" 91 | msgstr "" 92 | 93 | #: setup/main.py:281 94 | msgid "Please choose a file" 95 | msgstr "" 96 | 97 | #: setup/main.py:307 98 | #, python-format 99 | msgid "New Zhuyin %s" 100 | msgstr "" 101 | 102 | #: setup/config.py:29 103 | msgid "New Zhuyin" 104 | msgstr "" 105 | 106 | #: setup/ibus-libzhuyin-preferences.ui:23 107 | msgid "Standard" 108 | msgstr "" 109 | 110 | #: setup/ibus-libzhuyin-preferences.ui:28 111 | msgid "HSU" 112 | msgstr "" 113 | 114 | #: setup/ibus-libzhuyin-preferences.ui:33 115 | msgid "IBM" 116 | msgstr "" 117 | 118 | #: setup/ibus-libzhuyin-preferences.ui:38 119 | msgid "GinYieh" 120 | msgstr "" 121 | 122 | #: setup/ibus-libzhuyin-preferences.ui:43 123 | msgid "Eten" 124 | msgstr "" 125 | 126 | #: setup/ibus-libzhuyin-preferences.ui:48 127 | msgid "Eten26" 128 | msgstr "" 129 | 130 | #: setup/ibus-libzhuyin-preferences.ui:53 131 | msgid "Standard Dvorak" 132 | msgstr "" 133 | 134 | #: setup/ibus-libzhuyin-preferences.ui:58 135 | msgid "HSU Dvorak" 136 | msgstr "" 137 | 138 | #: setup/ibus-libzhuyin-preferences.ui:63 139 | msgid "DaChen CP26" 140 | msgstr "" 141 | 142 | #: setup/ibus-libzhuyin-preferences.ui:68 143 | msgid "Hanyu Pinyin" 144 | msgstr "" 145 | 146 | #: setup/ibus-libzhuyin-preferences.ui:73 147 | msgid "Luoma Pinyin" 148 | msgstr "" 149 | 150 | #: setup/ibus-libzhuyin-preferences.ui:78 151 | msgid "Secondary Bopomofo" 152 | msgstr "" 153 | 154 | #: setup/ibus-libzhuyin-preferences.ui:134 155 | msgid "Use Chinese Mode When Start-up" 156 | msgstr "" 157 | 158 | #: setup/ibus-libzhuyin-preferences.ui:152 159 | msgid "Use Full Width When Start-up" 160 | msgstr "" 161 | 162 | #: setup/ibus-libzhuyin-preferences.ui:170 163 | msgid "Use Traditional Chinese When Start-up" 164 | msgstr "" 165 | 166 | #: setup/ibus-libzhuyin-preferences.ui:188 167 | msgid "Always Input Numbers by Input Pad" 168 | msgstr "" 169 | 170 | #: setup/ibus-libzhuyin-preferences.ui:206 171 | msgid "Use Space Key to Show Candidates" 172 | msgstr "" 173 | 174 | #: setup/ibus-libzhuyin-preferences.ui:224 175 | msgid "Show Candidates After the Cursor" 176 | msgstr "" 177 | 178 | #: setup/ibus-libzhuyin-preferences.ui:246 179 | msgid "Inputting" 180 | msgstr "" 181 | 182 | #: setup/ibus-libzhuyin-preferences.ui:271 183 | msgid "Keyboard Layout" 184 | msgstr "" 185 | 186 | #: setup/ibus-libzhuyin-preferences.ui:285 187 | msgid "Candidate Choose Keys" 188 | msgstr "" 189 | 190 | #: setup/ibus-libzhuyin-preferences.ui:319 191 | msgid "Candidates per Page" 192 | msgstr "" 193 | 194 | #: setup/ibus-libzhuyin-preferences.ui:369 195 | msgid "Require tone information" 196 | msgstr "" 197 | 198 | #: setup/ibus-libzhuyin-preferences.ui:397 199 | msgid "Keyboard" 200 | msgstr "" 201 | 202 | #: setup/ibus-libzhuyin-preferences.ui:412 203 | msgid "Enable Fuzzy Zhuyin" 204 | msgstr "" 205 | 206 | #: setup/ibus-libzhuyin-preferences.ui:430 207 | msgid "l <=> n" 208 | msgstr "" 209 | 210 | #: setup/ibus-libzhuyin-preferences.ui:447 211 | msgid "f <=> h" 212 | msgstr "" 213 | 214 | #: setup/ibus-libzhuyin-preferences.ui:464 215 | msgid "l <=> r" 216 | msgstr "" 217 | 218 | #: setup/ibus-libzhuyin-preferences.ui:481 219 | msgid "g <=> k" 220 | msgstr "" 221 | 222 | #: setup/ibus-libzhuyin-preferences.ui:498 223 | msgid "c <=> ch" 224 | msgstr "" 225 | 226 | #: setup/ibus-libzhuyin-preferences.ui:515 227 | msgid "z <=> zh" 228 | msgstr "" 229 | 230 | #: setup/ibus-libzhuyin-preferences.ui:532 231 | msgid "s <=> sh" 232 | msgstr "" 233 | 234 | #: setup/ibus-libzhuyin-preferences.ui:549 235 | msgid "an <=> ang" 236 | msgstr "" 237 | 238 | #: setup/ibus-libzhuyin-preferences.ui:566 239 | msgid "in <=> ing" 240 | msgstr "" 241 | 242 | #: setup/ibus-libzhuyin-preferences.ui:583 243 | msgid "en <=> eng" 244 | msgstr "" 245 | 246 | #: setup/ibus-libzhuyin-preferences.ui:616 247 | msgid "Fuzzy Zhuyin" 248 | msgstr "" 249 | 250 | #: setup/ibus-libzhuyin-preferences.ui:638 251 | msgid "User Symbols" 252 | msgstr "" 253 | 254 | #: setup/ibus-libzhuyin-preferences.ui:654 255 | #: setup/ibus-libzhuyin-preferences.ui:697 256 | msgid "Edit" 257 | msgstr "" 258 | 259 | #: setup/ibus-libzhuyin-preferences.ui:681 260 | msgid "Easy Symbols" 261 | msgstr "" 262 | 263 | #: setup/ibus-libzhuyin-preferences.ui:727 264 | #: setup/ibus-libzhuyin-preferences.ui:844 265 | msgid "User Phrases" 266 | msgstr "" 267 | 268 | #: setup/ibus-libzhuyin-preferences.ui:737 269 | msgid "Clear" 270 | msgstr "" 271 | 272 | #: setup/ibus-libzhuyin-preferences.ui:752 273 | msgid "Import" 274 | msgstr "" 275 | 276 | #: setup/ibus-libzhuyin-preferences.ui:780 277 | msgid "Clear All Data" 278 | msgstr "" 279 | 280 | #: setup/ibus-libzhuyin-preferences.ui:811 281 | msgid "" 282 | "Dictionary File Format:\n" 283 | " Each line contains the following:\n" 284 | " \"phrase zhuyin\"\n" 285 | " like \"你好 ㄋㄧˇ ㄏㄠˇ\"." 286 | msgstr "" 287 | 288 | #: setup/ibus-libzhuyin-preferences.ui:822 289 | msgid "Help" 290 | msgstr "" 291 | 292 | #: setup/ibus-libzhuyin-preferences.ui:883 293 | msgid "IBus Zhuyin %s" 294 | msgstr "" 295 | 296 | #: setup/ibus-libzhuyin-preferences.ui:896 297 | msgid "New Zhuyin input method for IBus" 298 | msgstr "" 299 | 300 | #: setup/ibus-libzhuyin-preferences.ui:908 301 | msgid "Copyright (c) 2013-2014 Peng Wu" 302 | msgstr "" 303 | 304 | #: setup/ibus-libzhuyin-preferences.ui:936 305 | msgid "" 306 | "\n" 307 | "Authors:\n" 308 | "Peng Wu\n" 309 | "Peng Huang\n" 310 | "...\n" 311 | "\n" 312 | "Contributors:\n" 313 | "...\n" 314 | "" 315 | msgstr "" 316 | 317 | #: setup/ibus-libzhuyin-preferences.ui:965 318 | msgid "About" 319 | msgstr "" 320 | 321 | #: data/ibus-setup-libzhuyin.desktop.in:2 322 | msgid "IBus LibZhuyin Setup" 323 | msgstr "" 324 | 325 | #: data/ibus-setup-libzhuyin.desktop.in:3 326 | msgid "Set ibus-libzhuyin Preferences" 327 | msgstr "" 328 | --------------------------------------------------------------------------------