├── NEWS ├── ChangeLog ├── debian ├── compat ├── source │ └── format ├── watch ├── control ├── rules ├── copyright └── changelog ├── m4 ├── .gitignore ├── Makefile.am └── as-version.m4 ├── setup ├── python2 │ ├── _config.py.in │ ├── ibus-setup-anthy.desktop.in.in │ ├── ibus-setup-anthy.in │ └── Makefile.am ├── python3 │ ├── _config.py.in │ ├── ibus-setup-anthy.desktop.in.in │ ├── ibus-setup-anthy.in │ ├── Makefile.am │ └── anthyprefs.py └── Makefile.am ├── engine ├── .gitignore ├── python2 │ ├── test.py │ ├── default.inputMethod.xml.in.in │ ├── anthy.inputMethod.xml.in.in │ ├── ibus-engine-anthy.in │ ├── _config.py.in │ ├── factory.py │ ├── segment.py │ ├── anthy.i │ ├── Makefile.am │ ├── kana.py │ ├── main.py │ └── romaji.py ├── python3 │ ├── test.py │ ├── default.inputMethod.xml.in.in │ ├── anthy.inputMethod.xml.in.in │ ├── ibus-engine-anthy.in │ ├── _config.py.in │ ├── factory.py │ ├── segment.py │ ├── anthy.i │ ├── Makefile.am │ ├── kana.py │ ├── main.py │ └── romaji.py └── Makefile.am ├── tests ├── meta.test.in ├── Makefile.am ├── anthycases.py ├── test-build.sh └── test-console.sh ├── icons ├── ibus-anthy.png ├── ibus-anthy-old.png ├── Makefile.am └── ibus-anthy.svg ├── codereview.settings ├── po ├── LINGUAS ├── .gitignore ├── POTFILES.skip ├── POTFILES.in └── Makevars ├── AUTHORS ├── .gitignore ├── gir ├── test.py ├── test.c ├── Makefile.am ├── anthygcontext.h └── anthygcontext.c ├── autogen.sh ├── .github ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ └── bug_report.yml └── workflows │ └── main.yml ├── data ├── oldchar.t ├── ibus-anthy.appdata.xml.in ├── zipcode-textdic.py └── Makefile.am ├── python-config.py ├── .travis.yml ├── Makefile.am ├── ibus-anthy.spec.in └── README /NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | *.m4 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /setup/python2/_config.py.in: -------------------------------------------------------------------------------- 1 | ../../engine/python2/_config.py.in -------------------------------------------------------------------------------- /setup/python3/_config.py.in: -------------------------------------------------------------------------------- 1 | ../../engine/python3/_config.py.in -------------------------------------------------------------------------------- /engine/.gitignore: -------------------------------------------------------------------------------- 1 | anthy.py 2 | anthy_wrap.c 3 | ibus-engine-anthy 4 | -------------------------------------------------------------------------------- /tests/meta.test.in: -------------------------------------------------------------------------------- 1 | [Test] 2 | Type=session 3 | Exec=@TEST_EXEC@ --tap 4 | Output=TAP 5 | -------------------------------------------------------------------------------- /icons/ibus-anthy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibus/ibus-anthy/HEAD/icons/ibus-anthy.png -------------------------------------------------------------------------------- /icons/ibus-anthy-old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibus/ibus-anthy/HEAD/icons/ibus-anthy-old.png -------------------------------------------------------------------------------- /codereview.settings: -------------------------------------------------------------------------------- 1 | # This file is used by "git cl" to get code review information. 2 | CODE_REVIEW_SERVER: codereview.appspot.com 3 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | http://code.google.com/p/ibus/downloads/list \ 3 | http://ibus.googlecode.com/files/ibus-anthy-([0-9].*)\.tar\.gz 4 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | # please keep this list sorted alphabetically 2 | # 3 | ca 4 | cs 5 | de 6 | el 7 | es 8 | fi 9 | fr 10 | hu 11 | id 12 | ja 13 | ka 14 | kab 15 | ko 16 | pt_BR 17 | pt_PT 18 | si 19 | sv 20 | tr 21 | uk 22 | zh_CN 23 | -------------------------------------------------------------------------------- /setup/python2/ibus-setup-anthy.desktop.in.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=IBus Anthy Setup 3 | Comment=Set up IBus Anthy engine 4 | Exec=@libexecdir@/ibus-setup-anthy 5 | Icon=ibus-anthy 6 | NoDisplay=true 7 | Type=Application 8 | StartupNotify=true 9 | -------------------------------------------------------------------------------- /setup/python3/ibus-setup-anthy.desktop.in.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=IBus Anthy Setup 3 | Comment=Set up IBus Anthy engine 4 | Exec=@libexecdir@/ibus-setup-anthy 5 | Icon=ibus-anthy 6 | NoDisplay=true 7 | Type=Application 8 | StartupNotify=true 9 | -------------------------------------------------------------------------------- /po/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | Makefile.in.in 4 | Makevars.template 5 | POTFILES 6 | Rules-quot 7 | boldquot.sed 8 | en@boldquot.header 9 | en@quot.header 10 | insert-header.sin 11 | quot.sed 12 | remove-potcdate.sed 13 | remove-potcdate.sin 14 | -------------------------------------------------------------------------------- /po/POTFILES.skip: -------------------------------------------------------------------------------- 1 | # Files with translatable strings to skip. 2 | # Please keep this file in alphabetical order. 3 | engine/python2/default.xml.in 4 | engine/python3/default.xml.in 5 | setup/python2/anthyprefs.py 6 | setup/python2/ibus-setup-anthy.desktop.in 7 | setup/python3/anthyprefs.py 8 | setup/python3/ibus-setup-anthy.desktop.in 9 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | Huang Peng 3 | Hideaki ABE 4 | Takao Fujiwara 5 | 6 | Translators: 7 | ----------- 8 | fr.po: 9 | Humbert Julien 10 | zh_CN.po: 11 | Huang Peng 12 | ja.po: 13 | UTUMI Hirosi 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.la 3 | *.lo 4 | *.loT 5 | *.o 6 | *.so 7 | *~ 8 | tags 9 | Makefile.qmake 10 | Makefile 11 | Makefile.in 12 | .deps 13 | .libs 14 | ABOUT-NLS 15 | INSTALL 16 | aclocal.m4 17 | autom4te.cache 18 | compile 19 | config.guess 20 | config.h 21 | config.h.in 22 | config.log 23 | config.rpath 24 | config.status 25 | config.sub 26 | configure 27 | depcomp 28 | gtk-doc.make 29 | install-sh 30 | libtool 31 | ltmain.sh 32 | missing 33 | stamp-h1 34 | py-compile 35 | ibus-anthy*.tar.* 36 | ibus-anthy.spec 37 | -------------------------------------------------------------------------------- /gir/test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from gi.repository import GObject 3 | from gi.repository import Anthy 4 | 5 | anthy = Anthy.GContext() 6 | anthy.set_encoding(Anthy.UTF8_ENCODING) 7 | anthy.init_personality() 8 | anthy.do_set_personality('ibus__ibus_symbol') 9 | anthy.set_string('てすと') 10 | anthy.resize_segment(0, -1) 11 | print anthy.get_nr_segments() 12 | print anthy.get_nr_candidates(0) 13 | print anthy.get_segment(0, 0) 14 | print anthy.commit_segment(0, 0) 15 | anthy.set_prediction_string('てすと') 16 | print anthy.get_nr_predictions() 17 | print anthy.get_prediction(0) 18 | print anthy.commit_prediction(0) 19 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # Files with translatable strings. 2 | # Please keep this file in alphabetical order. 3 | data/ibus-anthy.appdata.xml.in 4 | engine/python2/default.inputMethod.xml.in.in 5 | engine/python2/engine.py 6 | engine/python2/factory.py 7 | engine/python3/default.inputMethod.xml.in.in 8 | engine/python3/engine.py 9 | engine/python3/factory.py 10 | setup/python2/anthyprefs.py 11 | setup/python2/ibus-setup-anthy.desktop.in.in 12 | setup/python2/main.py 13 | setup/python2/setup.ui 14 | setup/python3/anthyprefs.py 15 | setup/python3/ibus-setup-anthy.desktop.in.in 16 | setup/python3/main.py 17 | setup/python3/setup.ui 18 | -------------------------------------------------------------------------------- /engine/python2/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import anthy 4 | import sys 5 | 6 | ctx = anthy.anthy_context () 7 | ctx._set_encoding (2) 8 | if len(sys.argv) >= 2: 9 | ctx.set_string (sys.argv[1]) 10 | else: 11 | ctx.set_string ("かまぁく") 12 | conv_stat = anthy.anthy_conv_stat () 13 | seg_stat = anthy.anthy_segment_stat () 14 | ctx.get_stat (conv_stat) 15 | for i in range (0, conv_stat.nr_segment): 16 | ctx.get_segment_stat (i, seg_stat) 17 | buf = " " 18 | i = ctx.get_segment (i, 0, buf, 10) 19 | print buf[:i] 20 | # anthy.anthy_release_context (ctx) 21 | ctx = None 22 | -------------------------------------------------------------------------------- /engine/python3/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import anthy 4 | import sys 5 | 6 | ctx = anthy.anthy_context () 7 | ctx._set_encoding (2) 8 | if len(sys.argv) >= 2: 9 | ctx.set_string (sys.argv[1]) 10 | else: 11 | ctx.set_string ("かまぁく") 12 | conv_stat = anthy.anthy_conv_stat () 13 | seg_stat = anthy.anthy_segment_stat () 14 | ctx.get_stat (conv_stat) 15 | for i in range (0, conv_stat.nr_segment): 16 | ctx.get_segment_stat (i, seg_stat) 17 | buf = " " 18 | i = ctx.get_segment (i, 0, buf, 10) 19 | print buf[:i] 20 | # anthy.anthy_release_context (ctx) 21 | ctx = None 22 | -------------------------------------------------------------------------------- /engine/python2/default.inputMethod.xml.in.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | anthy 5 | ja 6 | GPL 7 | Peng Huang <shawn.p.huang@gmail.com> 8 | ibus-anthy 9 | @LAYOUT_XML@ 10 | 11 | 12 | Anthy 13 | Anthy Input Method 14 | 99 15 | @HOTKEYS_XML@ 16 | @SYMBOL_XML@ 17 | @ICON_PROP_KEY_XML@ 18 | @PACKAGE_VERSION@ 19 | ibus-anthy 20 | 21 | 22 | -------------------------------------------------------------------------------- /engine/python3/default.inputMethod.xml.in.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | anthy 5 | ja 6 | GPL 7 | Peng Huang <shawn.p.huang@gmail.com> 8 | ibus-anthy 9 | @LAYOUT_XML@ 10 | 11 | 12 | Anthy 13 | Anthy Input Method 14 | 99 15 | @HOTKEYS_XML@ 16 | @SYMBOL_XML@ 17 | @ICON_PROP_KEY_XML@ 18 | @PACKAGE_VERSION@ 19 | ibus-anthy 20 | 21 | 22 | -------------------------------------------------------------------------------- /engine/python2/anthy.inputMethod.xml.in.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.freedesktop.IBus.Anthy 5 | Anthy Component 6 | @LIBEXECDIR@/ibus-engine-anthy --ibus 7 | @PACKAGE_VERSION@ 8 | Peng Huang <shawn.p.huang@gmail.com> 9 | GPL 10 | https://github.com/ibus/ibus/wiki 11 | ibus-anthy 12 | 13 | 14 | 15 | ~/.config/ibus-anthy/engines.xml 16 | @PKGDATADIR@/engine/default.xml 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /engine/python3/anthy.inputMethod.xml.in.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.freedesktop.IBus.Anthy 5 | Anthy Component 6 | @LIBEXECDIR@/ibus-engine-anthy --ibus 7 | @PACKAGE_VERSION@ 8 | Peng Huang <shawn.p.huang@gmail.com> 9 | GPL 10 | https://github.com/ibus/ibus/wiki 11 | ibus-anthy 12 | 13 | 14 | 15 | ~/.config/ibus-anthy/engines.xml 16 | @PKGDATADIR@/engine/default.xml 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: ibus-anthy 2 | Section: utils 3 | Priority: optional 4 | Maintainer: IME Packaging Team 5 | Uploaders: LI Daobing 6 | Build-Depends: debhelper (>= 7), autotools-dev, swig, python-dev (>= 2.5), 7 | pkg-config, libanthy-dev, python-support, intltool 8 | Standards-Version: 3.9.1 9 | Homepage: http://code.google.com/p/ibus 10 | XS-Python-Version: >= 2.5 11 | Vcs-Bzr: lp:~pkg-ime/ibus/debian-ibus-anthy 12 | Vcs-Browser: https://code.launchpad.net/~pkg-ime/ibus/debian-ibus-anthy 13 | 14 | Package: ibus-anthy 15 | Architecture: any 16 | Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, ibus (>= 1.2), anthy, kasumi 17 | XB-Python-Version: ${python:Versions} 18 | Description: anthy engine for IBus 19 | IBus is an Intelligent Input Bus. It is a new input framework for Linux 20 | OS. It provides full featured and user friendly input method user interface. 21 | It also may help developers to develop input method easily. 22 | . 23 | IBus-Anthy is an input method (IM) for Japanese, based on IBus. 24 | -------------------------------------------------------------------------------- /setup/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2014 Takao Fujiwara 6 | # Copyright (c) 2014 Red Hat, Inc. 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 of the License, or 11 | # (at your option) 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 along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | SUBDIRS = 23 | 24 | if ENABLE_PYTHON2 25 | SUBDIRS += python2 26 | endif 27 | 28 | if ENABLE_PYTHON3 29 | SUBDIRS += python3 30 | endif 31 | -------------------------------------------------------------------------------- /engine/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2014 Takao Fujiwara 6 | # Copyright (c) 2014 Red Hat, Inc. 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 of the License, or 11 | # (at your option) 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 along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | SUBDIRS = 23 | 24 | if ENABLE_PYTHON2 25 | SUBDIRS += python2 26 | endif 27 | 28 | if ENABLE_PYTHON3 29 | SUBDIRS += python3 30 | endif 31 | -------------------------------------------------------------------------------- /setup/python2/ibus-setup-anthy.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 | # Copyright (c) 2010-2021 Takao Fujiwara 8 | # Copyright (c) 2007-2016 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | export IBUS_LOCALEDIR=@localedir@ 25 | exec @PYTHON@ @prefix@/share/ibus-anthy/setup/main.py "$@" 26 | -------------------------------------------------------------------------------- /setup/python3/ibus-setup-anthy.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 | # Copyright (c) 2010-2021 Takao Fujiwara 8 | # Copyright (c) 2007-2016 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | export IBUS_LOCALEDIR=@localedir@ 25 | exec @PYTHON@ @prefix@/share/ibus-anthy/setup/main.py "$@" 26 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to generate all the initial makefiles, etc. 3 | test -n "$srcdir" || srcdir=$(dirname "$0") 4 | test -n "$srcdir" || srcdir=. 5 | 6 | olddir=$(pwd) 7 | 8 | cd "$srcdir" 9 | 10 | (test -f configure.ac) || { 11 | echo "*** ERROR: Directory '$srcdir' does not look like the top-level project directory ***" 12 | exit 1 13 | } 14 | 15 | # shellcheck disable=SC2016 16 | PKG_NAME=$(autoconf --trace 'AC_INIT:$1' configure.ac) 17 | 18 | if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then 19 | echo "*** WARNING: I am going to run 'configure' with no arguments." >&2 20 | echo "*** If you wish to pass any to it, please specify them on the" >&2 21 | echo "*** '$0' command line." >&2 22 | echo "" >&2 23 | fi 24 | 25 | autoreconf --verbose --force --install || exit 1 26 | 27 | cd "$olddir" 28 | if [ "$NOCONFIGURE" = "" ]; then 29 | $srcdir/configure "$@" || exit 1 30 | 31 | if [ "$1" = "--help" ]; then 32 | exit 0 33 | else 34 | echo "Now type 'make' to compile $PKG_NAME" || exit 1 35 | fi 36 | else 37 | echo "Skipping configure process." 38 | fi 39 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | config.status: 4 | dh_testdir 5 | cp -f /usr/share/misc/config.sub config.sub 6 | cp -f /usr/share/misc/config.guess config.guess 7 | dh_auto_configure -- \ 8 | --with-anthy-zipcode="/usr/share/anthy/dic/zipcode.t" 9 | 10 | build: build-stamp 11 | build-stamp: config.status 12 | dh_testdir 13 | cd po; intltool-update --pot 14 | touch $@ 15 | 16 | clean: 17 | dh_testdir 18 | dh_testroot 19 | [ ! -f Makefile ] || $(MAKE) distclean 20 | rm -f config.sub config.guess 21 | rm -f po/*.gmo 22 | dh_clean build-stamp 23 | 24 | install: build 25 | dh_testdir 26 | dh_testroot 27 | dh_prep 28 | dh_installdirs 29 | $(MAKE) DESTDIR=$(CURDIR)/debian/ibus-anthy install 30 | 31 | binary-indep: install 32 | 33 | binary-arch: install 34 | dh_testdir 35 | dh_testroot 36 | dh_installchangelogs -s 37 | dh_installdocs -s AUTHORS README 38 | dh_installexamples -s 39 | dh_pysupport -s 40 | dh_installman -s 41 | dh_lintian -s 42 | dh_link -s 43 | dh_strip -s 44 | dh_compress -s 45 | dh_fixperms -s 46 | dh_installdeb -s 47 | dh_shlibdeps -s 48 | dh_gencontrol -s 49 | dh_md5sums -s 50 | dh_builddeb -s 51 | 52 | binary: binary-indep binary-arch 53 | .PHONY: build clean binary-indep binary-arch binary install 54 | -------------------------------------------------------------------------------- /m4/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2007-2008 Peng Huang 6 | # Copyright (c) 2010-2013 Takao Fujiwara 7 | # Copyright (c) 2007-2013 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | EXTRA_DIST = \ 24 | as-version.m4 \ 25 | gettext.m4 \ 26 | iconv.m4 \ 27 | lib-ld.m4 \ 28 | lib-link.m4 \ 29 | lib-prefix.m4 \ 30 | nls.m4 \ 31 | po.m4 \ 32 | progtest.m4 \ 33 | $(NULL) 34 | -------------------------------------------------------------------------------- /gir/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "anthygcontext.h" 4 | 5 | int 6 | main (int argc, char *argv[]) 7 | { 8 | AnthyGContext *obj = NULL; 9 | gchar *string = NULL; 10 | 11 | #if !GLIB_CHECK_VERSION(2,35,0) 12 | g_type_init (); 13 | #endif 14 | 15 | anthy_gcontext_set_logger (0); 16 | obj = anthy_gcontext_new (); 17 | 18 | anthy_gcontext_set_encoding (obj, ANTHY_UTF8_ENCODING); 19 | anthy_gcontext_init_personality (obj); 20 | anthy_gcontext_do_set_personality(obj, "ibus__ibus_symbol"); 21 | anthy_gcontext_set_string (obj, "てすと"); 22 | anthy_gcontext_resize_segment (obj, 0, -1); 23 | printf ("%d\n", anthy_gcontext_get_nr_segments (obj)); 24 | printf ("%d\n", anthy_gcontext_get_nr_candidates (obj, 0)); 25 | string = anthy_gcontext_get_segment (obj, 0, 0); 26 | printf ("%s\n", string ? string : "(null)"); 27 | anthy_gcontext_commit_segment (obj, 0, 0); 28 | anthy_gcontext_set_prediction_string (obj, "てすと"); 29 | printf ("%d\n", anthy_gcontext_get_nr_predictions (obj)); 30 | string = anthy_gcontext_get_prediction (obj, 0); 31 | printf ("%s\n", string ? string : "(null)"); 32 | anthy_gcontext_commit_prediction (obj, 0); 33 | 34 | g_object_unref (obj); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /engine/python2/ibus-engine-anthy.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # vim:set noet ts=4: 4 | # 5 | # ibus-anthy - The Anthy engine for IBus 6 | # 7 | # Copyright (c) 2007-2008 Peng Huang 8 | # Copyright (c) 2010-2021 Takao Fujiwara 9 | # Copyright (c) 2007-2016 Red Hat, Inc. 10 | # 11 | # This program is free software; you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation; either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License along 22 | # with this program; if not, write to the Free Software Foundation, Inc., 23 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | export IBUS_PREFIX=@prefix@ 26 | export IBUS_ANTHY_PKGDATADIR=@datarootdir@/@PACKAGE@ 27 | export LIBEXECDIR=@libexecdir@ 28 | exec @ENV_IBUS_ENGINE@ @PYTHON@ @datarootdir@/@PACKAGE@/engine/main.py "$@" 29 | -------------------------------------------------------------------------------- /engine/python3/ibus-engine-anthy.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # vim:set noet ts=4: 4 | # 5 | # ibus-anthy - The Anthy engine for IBus 6 | # 7 | # Copyright (c) 2007-2008 Peng Huang 8 | # Copyright (c) 2010-2021 Takao Fujiwara 9 | # Copyright (c) 2007-2016 Red Hat, Inc. 10 | # 11 | # This program is free software; you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation; either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License along 22 | # with this program; if not, write to the Free Software Foundation, Inc., 23 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | export IBUS_PREFIX=@prefix@ 26 | export IBUS_ANTHY_PKGDATADIR=@datarootdir@/@PACKAGE@ 27 | export LIBEXECDIR=@libexecdir@ 28 | exec @ENV_IBUS_ENGINE@ @PYTHON@ @datarootdir@/@PACKAGE@/engine/main.py "$@" 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *** The template file at the root(.github/foo.md) is no longer used in GitHub issue *** 2 | 3 | Please fill in the following items if you don't know the root cause. 4 | 5 | Which distribution and version?: 6 | (E.g. Fedora 27. Check /etc/fedora-release) 7 | 8 | Which desktop environment and version?: 9 | (E.g. GNOME 3.24. Check $XDG_CURRENT_DESKTOP and your ISO image.) 10 | 11 | Which session type?: 12 | (X11 or Wayland. Check $XDG_SESSION_TYPE) 13 | 14 | Which application and version?: 15 | (E.g. gedit 3.24, leafpad, kate, xterm) 16 | 17 | IBus version?: 18 | (Run `ibus version`) 19 | 20 | ibus-anthy version?: 21 | (Open "IBus Anthy preferences" dialog (`ibus-setup-anthy`) from IBus panel menu or ibus-setup, and select "About" tab) 22 | 23 | Issue description: 24 | 25 | 26 | Steps to reproduce: 27 | 1. 28 | 1. 29 | 1. 30 | 1. 31 | 32 | Can you reproduce your problem when you restart ibus-daemon? (yes / no): 33 | (Run `ibus exit` and `ibus-daemon --xim &`) 34 | 35 | Do you see any errors when you run ibus-daemon with the verbose option?: 36 | (Run `ibus-daemon --xim --verbose &` and look at the output when you encounter your problem.) 37 | 38 | 39 | Can you reproduce your problem with a new user account instead of the current your account? (yes / no): 40 | 41 | -------------------------------------------------------------------------------- /engine/python3/_config.py.in: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2019 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | ANTHY_PC= '@ANTHY_PC@' 25 | PKGDATADIR = '@pkgdatadir@' 26 | LIBEXECDIR = '@libexecdir@' 27 | LOCALEDIR = '@datadir@/locale' 28 | LAYOUT = '@LAYOUT@' 29 | SYMBOL_CHAR = chr(@SYMBOL_CHAR_INT@) 30 | ICON_PREFERENCE = '@ICON_PREFERENCE@' 31 | VERSION = '@VERSION@' 32 | DEBUG = False 33 | -------------------------------------------------------------------------------- /engine/python2/_config.py.in: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2019 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | ANTHY_PC= '@ANTHY_PC@' 25 | PKGDATADIR = '@pkgdatadir@' 26 | LIBEXECDIR = '@libexecdir@' 27 | LOCALEDIR = '@datadir@/locale' 28 | LAYOUT = '@LAYOUT@' 29 | SYMBOL_CHAR = unichr(@SYMBOL_CHAR_INT@) 30 | ICON_PREFERENCE = '@ICON_PREFERENCE@' 31 | VERSION = '@VERSION@' 32 | DEBUG = False 33 | -------------------------------------------------------------------------------- /data/oldchar.t: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2010-2013 Takao Fujiwara 6 | # Copyright (c) 2010-2013 Red Hat, Inc. 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 of the License, or 11 | # (at your option) 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 along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | # 22 | # This file was imported from im-dict-ja 23 | # im-dict-ja - Japanese word dictionary set for input method 24 | # http://github.com/fujiwarat/im-dict-ja 25 | # 26 | # Typing 'va' can convert 'ヷ' with this dictionary. 27 | う゛ぁ #T35*500 ヷ 28 | う゛ぃ #T35*500 ヸ 29 | う゛ぇ #T35*500 ヹ 30 | う゛ぉ #T35*500 ヺ 31 | # 〳, 〵and 〴 can be used instead. 32 | おなじ #T35*500 〱 33 | おなじ #T35*500 〲 34 | くのじ #T35*500 〱 35 | くのじ #T35*500 〲 36 | くりかえし #T35*500 〱 37 | くりかえし #T35*500 〲 38 | てん #T35*500 〱 39 | てん #T35*500 〲 40 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by: 2 | 3 | LI Daobing on Sun, 28 Dec 2008 20:30:06 +0800 4 | 5 | It was downloaded from: 6 | 7 | http://code.google.com/p/ibus/downloads/list 8 | 9 | Upstream Author: 10 | 11 | Huang Peng 12 | 13 | Copyright: 14 | 15 | Copyright (C) 2007-2008 Huang Peng 16 | 17 | License: 18 | 19 | This package is free software; you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation; either version 2 of the License, or 22 | (at your option) any later version. 23 | 24 | This package is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | 29 | You should have received a copy of the GNU General Public License 30 | along with this package; if not, write to the Free Software 31 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 32 | 33 | On Debian systems, the complete text of the GNU General 34 | Public License can be found in `/usr/share/common-licenses/GPL'. 35 | 36 | The Debian packaging is: 37 | 38 | Copyright (C) 2008, LI Daobing 39 | 40 | and is licensed under the GPL, see above. 41 | -------------------------------------------------------------------------------- /icons/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2007-2008 Peng Huang 6 | # Copyright (c) 2010-2013 Takao Fujiwara 7 | # Copyright (c) 2007-2013 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | if HAVE_PRIVATE_PNG 24 | pngicons_DATA = \ 25 | ibus-anthy.png \ 26 | $(NULL) 27 | else 28 | pngicons_files = \ 29 | ibus-anthy.png \ 30 | $(NULL) 31 | endif 32 | 33 | pngiconsdir = $(pkgdatadir)/icons 34 | 35 | scalable_icons_DATA = \ 36 | ibus-anthy.svg \ 37 | $(NULL) 38 | 39 | # You need to run gtk-update-icon-cache after the icons are installed. 40 | scalable_iconsdir = $(datadir)/icons/hicolor/scalable/apps/ 41 | 42 | EXTRA_DIST = \ 43 | $(pngicons_DATA) \ 44 | $(pngicons_files) \ 45 | $(scalable_icons_DATA) \ 46 | $(NULL) 47 | -------------------------------------------------------------------------------- /python-config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2.5 2 | 3 | import sys 4 | import os 5 | import getopt 6 | from distutils import sysconfig 7 | 8 | valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', 9 | 'ldflags', 'help'] 10 | 11 | def exit_with_usage(code=1): 12 | print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0], 13 | '|'.join('--'+opt for opt in valid_opts)) 14 | sys.exit(code) 15 | 16 | try: 17 | opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) 18 | except getopt.error: 19 | exit_with_usage() 20 | 21 | if not opts: 22 | exit_with_usage() 23 | 24 | opt = opts[0][0] 25 | 26 | pyver = sysconfig.get_config_var('VERSION') 27 | getvar = sysconfig.get_config_var 28 | 29 | if opt == '--help': 30 | exit_with_usage(0) 31 | 32 | elif opt == '--prefix': 33 | print sysconfig.PREFIX 34 | 35 | elif opt == '--exec-prefix': 36 | print sysconfig.EXEC_PREFIX 37 | 38 | elif opt in ('--includes', '--cflags'): 39 | flags = ['-I' + sysconfig.get_python_inc(), 40 | '-I' + sysconfig.get_python_inc(plat_specific=True)] 41 | if opt == '--cflags': 42 | flags.extend(getvar('CFLAGS').split()) 43 | print ' '.join(flags) 44 | 45 | elif opt in ('--libs', '--ldflags'): 46 | libs = getvar('LIBS').split() + getvar('SYSLIBS').split() 47 | libs.append('-lpython'+pyver) 48 | # add the prefix/lib/pythonX.Y/config dir, but only if there is no 49 | # shared library in prefix/lib/. 50 | if opt == '--ldflags' and not getvar('Py_ENABLE_SHARED'): 51 | libs.insert(0, '-L' + getvar('LIBPL')) 52 | print ' '.join(libs) 53 | 54 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: gcc 3 | os: linux 4 | 5 | # Require gettext-0.19.8 6 | dist: focal 7 | 8 | branches: 9 | only: 10 | - main 11 | 12 | arch: 13 | - amd64 14 | #- ppc64le 15 | #- s390x 16 | #- arm64 17 | 18 | addons: 19 | apt: 20 | packages: 21 | # For autogen.sh 22 | - autopoint 23 | # For make from 24 | # https://packages.ubuntu.com/search?searchon=sourcenames&keywords=ibus-anthy 25 | - desktop-file-utils 26 | - gir1.2-ibus-1.0 27 | - gobject-introspection 28 | - gettext 29 | - libanthy-dev 30 | - libgirepository1.0-dev 31 | - libglib2.0-dev 32 | - pkg-config 33 | - python3-dev 34 | - python3-gi 35 | 36 | jobs: 37 | include: 38 | - name: Build 39 | before_script: 40 | - sudo apt-get -qq update 41 | script: 42 | - set -e 43 | - git config pull.rebase false 44 | - git pull --depth=200 45 | # configure options from 46 | # https://salsa.debian.org/debian/ibus-anthy/-/blob/master/debian/rules 47 | - > 48 | ./autogen.sh 49 | --libexecdir=/usr/lib/ibus 50 | --with-layout='default' 51 | --with-python=python3 52 | --with-hotkeys 53 | --with-on-off-keys="'Zenkaku_Hankaku', 'Ctrl+space', 'Ctrl+J'" 54 | --enable-installed-tests 55 | --disable-static 56 | # Set the cutom DESTDIR because the default DESTDIR 57 | # /home/travis/bulid/fujiwarat/$PKG/ibus/ibus-$VERSION/_inst seems to be 58 | # too long and failed to set DESTDIR to install bindings/pygobject/IBus.py 59 | - > 60 | make 61 | VERBOSE=1 62 | DESTDIR="$HOME/build/$USER/dest" 63 | - > 64 | desktop-file-validate 65 | ./setup/python3/ibus-setup-anthy.desktop 66 | 67 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2017-2021 Takao Fujiwara 6 | # Copyright (c) 2017-2019 Red Hat, Inc. 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 of the License, or 11 | # (at your option) 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 along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | 23 | CLEANFILES = 24 | 25 | check: 26 | bash -x $(srcdir)/test-build.sh --builddir=$(builddir) --srcdir=$(srcdir) 27 | 28 | if ENABLE_INSTALLED_TESTS 29 | test_execsdir = $(libexecdir)/installed-tests/ibus-anthy 30 | test_execs = anthytest 31 | test_execs_SCRIPTS = \ 32 | anthycases.py \ 33 | anthytest.py \ 34 | $(NULL) 35 | 36 | test_metas_in = meta.test.in 37 | test_metas = $(addsuffix .test, $(test_execs)) 38 | test_sources_DATA = \ 39 | $(test_metas) \ 40 | $(NULL) 41 | test_sourcesdir = $(datadir)/installed-tests/ibus-anthy 42 | 43 | CLEANFILES += \ 44 | $(test_metas) \ 45 | $(NULL) 46 | endif 47 | 48 | $(test_metas): $(test_metas_in) 49 | f=`echo $@ | sed -e 's/\.test//'`; \ 50 | TEST_EXEC=$(test_execsdir)/$${f}.py; \ 51 | sed -e "s|@TEST_EXEC[@]|$$TEST_EXEC|g" $(test_metas_in) > $@.tmp; \ 52 | mv $@.tmp $@; \ 53 | $(NULL) 54 | 55 | EXTRA_DIST = \ 56 | anthycases.py \ 57 | anthytest.py \ 58 | meta.test.in \ 59 | test-build.sh \ 60 | test-console.sh \ 61 | $(NULL) 62 | -------------------------------------------------------------------------------- /data/ibus-anthy.appdata.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.freedesktop.ibus.engine.anthy 5 | GFDL-1.3 6 | GPL-2.0 7 | Anthy 8 | Japanese input method 9 | https://raw.githubusercontent.com/ibus/ibus-anthy/main/icons/ibus-anthy.png 10 | 11 |

12 | The Anthy input method is designed for entering Japanese text. 13 |

14 |

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

19 |
20 | 21 | input-method 22 | Japanese 23 | 24 | https://github.com/ibus/ibus/wiki 25 | https://github.com/ibus/ibus-anthy/issues 26 | https://github.com/ibus/ibus/wiki/FAQ 27 | https://translate.fedoraproject.org/projects/ibus/ibus-anthy/ 28 | 29 | 30 | 31 |

See the upstream release list.

32 |
33 | https://github.com/ibus/ibus-anthy/releases 34 |
35 |
36 | IBus 37 | 38 | 39 | The Anthy input method is designed for entering Japanese text. 40 | http://ibus.github.io/images/2.png 41 | 42 | 43 | ibus-anthy 44 | tfujiwar_AT_redhat.com 45 |
46 | -------------------------------------------------------------------------------- /data/zipcode-textdic.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Finally decided to import anthy zipcode.t with UTF-8 into ibus-anthy 4 | # because if digits without hyphen is grepped by engine, it could cause 5 | # the timeout issue. If digits without hyphen are sent to anthy, 6 | # digits with hyphen also need to be sent to anthy so the lookup could 7 | # include too many and unnecessary candidates. 8 | # Also wish to install the filename of 'zipcode.t' to simplify enigne. 9 | 10 | # for python2 11 | from __future__ import print_function 12 | 13 | import codecs 14 | import sys 15 | 16 | if len(sys.argv) < 2: 17 | print('usage: %s /usr/share/anthy/zipcode.t' % sys.argv[0], 18 | file=sys.stderr) 19 | exit(-1) 20 | 21 | anthy_zipfile = sys.argv[1] 22 | 23 | try: 24 | contents = codecs.open(anthy_zipfile, 'r', 'euc_jp').read() 25 | except UnicodeDecodeError as e: 26 | print('Your file is not eucJP? %s' % anthy_zipfile, file=sys.stderr) 27 | contents = open(anthy_zipfile).read() 28 | 29 | output_zipfile = codecs.open('zipcode.t', 'w', 'utf-8') 30 | output_zipfile.write('# copied %s with UTF-8.\n#\n' % anthy_zipfile) 31 | 32 | for line in contents.split('\n'): 33 | if len(line) == 0 or line[0] == '#': 34 | output_zipfile.write('%s\n' % line) 35 | continue 36 | 37 | words = line.split() 38 | if len(words) < 3: 39 | continue 40 | 41 | if len(words[0]) < 1 or ord(words[0][0]) > 0xff: 42 | mbcs_addr = words[0] 43 | else: 44 | uni_addr = '' 45 | i = 0 46 | for word in words[0]: 47 | # Convert ASCII number char to wide number char. 48 | if sys.version < '3': 49 | uni_addr += unichr(0xfee0 + ord(word)) 50 | else: 51 | uni_addr += chr(0xfee0 + ord(word)) 52 | if i == 2: 53 | # Insert wide hyphen 54 | if sys.version < '3': 55 | uni_addr += unichr(0x30fc) 56 | else: 57 | uni_addr += chr(0x30fc) 58 | i += 1 59 | mbcs_addr = uni_addr 60 | 61 | output_zipfile.write('%s %s %s\n' % \ 62 | (mbcs_addr, '#T35*500', words[2])) 63 | 64 | output_zipfile.flush() 65 | output_zipfile.close() 66 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/anthycases.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | 4 | # 'init' has one array which is [keysym, keycode, modifier] and to be run 5 | # before the main tests. E.g. 6 | # Ctrl-space to enable Hiragana mode 7 | # 8 | # 'tests' cases are the main test cases. 9 | # 'preedit' case runs to create a preedit text. 10 | # 'commit' case runs to commit the preedit text. 11 | # 'result' case is the expected output. 12 | # 'preedit' and 'commit' can choose the type of either 'string' or 'keys' 13 | # 'string' type is a string sequence which does not need modifiers 14 | 15 | from gi import require_version as gi_require_version 16 | gi_require_version('IBus', '1.0') 17 | from gi.repository import IBus 18 | 19 | TestCases = { 20 | #'init': [ord(' '), 0, IBus.ModifierType.CONTROL_MASK] 21 | 'init': [IBus.KEY_j, 0, IBus.ModifierType.CONTROL_MASK], 22 | 'tests': [ 23 | { 'preedit': { 'string': 'watashinonamaeha,pendesu.' }, 24 | 'conversion': { 'string': ' ' }, 25 | 'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] }, 26 | 'result': { 'string': '私の名前は、ペンです。' } 27 | }, 28 | { 'preedit': { 'string': 'toukyou' }, 29 | 'conversion': { 'string': ' ' }, 30 | 'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] }, 31 | 'result': { 'string': '東京' } 32 | }, 33 | { 'preedit': { 'string': 'toukyo' }, 34 | 'conversion': { 'keys': [[IBus.KEY_Tab, 0, 0], 35 | [IBus.KEY_Tab, 0, 0], 36 | ] 37 | }, 38 | 'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] }, 39 | 'result': { 'string': '東京' } 40 | }, 41 | { 'preedit': { 'string': 'myuutu-' }, 42 | 'conversion': { 'keys': [[IBus.KEY_F7, 0, IBus.ModifierType.SHIFT_MASK]] }, 43 | 'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] }, 44 | 'result': { 'string': 'ミュウツー' } 45 | }, 46 | { 'preedit': { 'string': 'myuutu-' }, 47 | 'conversion': { 'keys': [[IBus.KEY_space, 0, 0], 48 | [IBus.KEY_Right, 0, IBus.ModifierType.SHIFT_MASK], 49 | [IBus.KEY_Right, 0, IBus.ModifierType.SHIFT_MASK], 50 | [IBus.KEY_Right, 0, IBus.ModifierType.SHIFT_MASK], 51 | [IBus.KEY_F7, 0, 0] 52 | ] 53 | }, 54 | 'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] }, 55 | 'result': { 'string': 'ミュウツー' } 56 | }, 57 | ] 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2007-2008 Peng Huang 6 | # Copyright (c) 2010-2025 Takao Fujiwara 7 | # Copyright (c) 2007-2025 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | SUBDIRS = \ 24 | m4 \ 25 | po \ 26 | data \ 27 | gir \ 28 | engine \ 29 | icons \ 30 | setup \ 31 | tests \ 32 | $(NULL) 33 | 34 | ACLOCAL_AMFLAGS = -I m4 35 | 36 | EXTRA_DIST = \ 37 | autogen.sh \ 38 | ibus-anthy.spec.in \ 39 | python-config.py \ 40 | $(NULL) 41 | 42 | noinst_DIST = \ 43 | $(NULL) 44 | 45 | 46 | DISTCLEANFILES = \ 47 | po/stamp-it \ 48 | $(NULL) 49 | 50 | dist-hook: 51 | if test -d .git ; then \ 52 | git log --name-status --date=iso > $(distdir)/ChangeLog ; \ 53 | PREV_MICRO_VERSION=`expr $(PACKAGE_VERSION_MICRO) - 1`; \ 54 | PREV_VERSION=\ 55 | "$(PACKAGE_VERSION_MAJOR).$(PACKAGE_VERSION_MINOR).$$PREV_MICRO_VERSION"; \ 56 | echo "Changes in $(PACKAGE_NAME) $(PACKAGE_VERSION)" \ 57 | > $(distdir)/NEWS; \ 58 | echo "" >> $(distdir)/NEWS; \ 59 | git shortlog $$PREV_VERSION...$(PACKAGE_VERSION) \ 60 | >> $(distdir)/NEWS; \ 61 | echo "" >> $(distdir)/NEWS; \ 62 | git log $$PREV_VERSION...$(PACKAGE_VERSION) --reverse \ 63 | --pretty=format:'%s (%an) %h' >> $(distdir)/NEWS; \ 64 | fi 65 | 66 | rpm: dist @PACKAGE_NAME@.spec 67 | rpmbuild -bb \ 68 | --define "_sourcedir `pwd`" \ 69 | --define "_builddir `pwd`" \ 70 | --define "_srcrpmdir `pwd`" \ 71 | --define "_rpmdir `pwd`" \ 72 | --define "_specdir `pwd`" \ 73 | @PACKAGE_NAME@.spec 74 | 75 | srpm: dist @PACKAGE_NAME@.spec 76 | rpmbuild -bs \ 77 | --define "_sourcedir `pwd`" \ 78 | --define "_builddir `pwd`" \ 79 | --define "_srcrpmdir `pwd`" \ 80 | --define "_rpmdir `pwd`" \ 81 | --define "_specdir `pwd`" \ 82 | @PACKAGE_NAME@.spec 83 | 84 | @PACKAGE_NAME@-@PACKAGE_VERSION@.%.sum: @PACKAGE_NAME@-@PACKAGE_VERSION@.% 85 | f=`basename $@ .sum`; \ 86 | printf "cksum %s %s %s\n" `cksum $$f` > $@; \ 87 | printf "sha1sum %s %s\n" `sha1sum $$f` >> $@; \ 88 | printf "sha256sum %s %s\n" `sha256sum $$f` >> $@; \ 89 | printf "sha512sum %s %s\n" `sha512sum $$f` >> $@; \ 90 | $(NULL) 91 | 92 | clean-rpm: 93 | $(RM) -r "`uname -i`" 94 | 95 | clean-local: clean-rpm 96 | -------------------------------------------------------------------------------- /engine/python2/factory.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2017 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import os 25 | import sys 26 | 27 | from gi import require_version as gi_require_version 28 | gi_require_version('IBus', '1.0') 29 | 30 | from gi.repository import IBus 31 | 32 | import _config as config 33 | import engine 34 | 35 | 36 | class EngineFactory(IBus.Factory): 37 | FACTORY_PATH = '/com/redhat/IBus/engines/Anthy/Factory' 38 | ENGINE_PATH = '/com/redhat/IBus/engines/Anthy/Engine' 39 | NAME = 'Anthy' 40 | LANG = 'ja' 41 | ICON = config.PKGDATADIR + '/icons/ibus-anthy.png' 42 | AUTHORS = 'Huang Peng ' 43 | CREDITS = 'GPLv2' 44 | 45 | def __init__(self, bus): 46 | self.__bus = bus 47 | engine.Engine.CONFIG_RELOADED() 48 | super(EngineFactory, self).__init__(object_path=IBus.PATH_FACTORY, 49 | connection=bus.get_connection()) 50 | 51 | self.__id = 0 52 | 53 | bus.get_connection().signal_subscribe('org.freedesktop.DBus', 54 | 'org.freedesktop.DBus', 55 | 'NameOwnerChanged', 56 | '/org/freedesktop/DBus', 57 | None, 58 | 0, 59 | self.__name_owner_changed_cb, 60 | bus) 61 | 62 | def do_create_engine(self, engine_name): 63 | if engine_name == 'anthy': 64 | self.__id += 1 65 | return engine.Engine(self.__bus, '%s/%d' % (self.ENGINE_PATH, self.__id)) 66 | 67 | return super(EngineFactory, self).do_create_engine(engine_name) 68 | 69 | def __name_owner_changed_cb(self, connection, sender_name, object_path, 70 | interface_name, signal_name, parameters, 71 | user_data): 72 | if signal_name == 'NameOwnerChanged': 73 | engine.Engine.CONFIG_RELOADED() 74 | -------------------------------------------------------------------------------- /engine/python3/factory.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2017 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import os 25 | import sys 26 | 27 | from gi import require_version as gi_require_version 28 | gi_require_version('IBus', '1.0') 29 | 30 | from gi.repository import IBus 31 | 32 | import _config as config 33 | import engine 34 | 35 | 36 | class EngineFactory(IBus.Factory): 37 | FACTORY_PATH = '/com/redhat/IBus/engines/Anthy/Factory' 38 | ENGINE_PATH = '/com/redhat/IBus/engines/Anthy/Engine' 39 | NAME = 'Anthy' 40 | LANG = 'ja' 41 | ICON = config.PKGDATADIR + '/icons/ibus-anthy.png' 42 | AUTHORS = 'Huang Peng ' 43 | CREDITS = 'GPLv2' 44 | 45 | def __init__(self, bus): 46 | self.__bus = bus 47 | engine.Engine.CONFIG_RELOADED() 48 | super(EngineFactory, self).__init__(object_path=IBus.PATH_FACTORY, 49 | connection=bus.get_connection()) 50 | 51 | self.__id = 0 52 | 53 | bus.get_connection().signal_subscribe('org.freedesktop.DBus', 54 | 'org.freedesktop.DBus', 55 | 'NameOwnerChanged', 56 | '/org/freedesktop/DBus', 57 | None, 58 | 0, 59 | self.__name_owner_changed_cb, 60 | bus) 61 | 62 | def do_create_engine(self, engine_name): 63 | if engine_name == 'anthy': 64 | self.__id += 1 65 | return engine.Engine(self.__bus, '%s/%d' % (self.ENGINE_PATH, self.__id)) 66 | 67 | return super(EngineFactory, self).do_create_engine(engine_name) 68 | 69 | def __name_owner_changed_cb(self, connection, sender_name, object_path, 70 | interface_name, signal_name, parameters, 71 | user_data): 72 | if signal_name == 'NameOwnerChanged': 73 | engine.Engine.CONFIG_RELOADED() 74 | -------------------------------------------------------------------------------- /gir/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2012-2019 Takao Fujiwara 6 | # Copyright (c) 2012 Peng Huang 7 | # Copyright (c) 2012-2013 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | INTROSPECTION_GIRS = 24 | 25 | libanthygobject = libanthygobject-1.0.la 26 | 27 | AM_CPPFLAGS = \ 28 | @GOBJECT2_CFLAGS@ \ 29 | @ANTHY_CFLAGS@ \ 30 | $(NULL) 31 | 32 | libanthygobject_LTLIBRARIES = $(libanthygobject) 33 | libanthygobjectdir = @ANTHY_GOBJECT_LIBDIR@ 34 | 35 | libanthygobject_1_0_la_SOURCES = \ 36 | anthygcontext.c \ 37 | $(NULL) 38 | 39 | libanthygobject_1_0_la_LIBADD = \ 40 | @GOBJECT2_LIBS@ \ 41 | @ANTHY_LIBS@ \ 42 | $(NULL) 43 | 44 | libanthygobject_1_0_la_LDFLAGS = \ 45 | -no-undefined \ 46 | -export-symbols-regex "anthy_.*" \ 47 | -version-info @LT_VERSION_INFO@ \ 48 | $(NULL) 49 | 50 | ANTHY_INCLUDEDIR = $(shell pkg-config --variable=includedir $(ANTHY_PC)) 51 | 52 | anthyincludedir = $(includedir)/ibus-anthy-1.0 53 | anthyinclude_HEADERS = \ 54 | anthygcontext.h \ 55 | $(NULL) 56 | 57 | # gobject introspection 58 | -include $(INTROSPECTION_MAKEFILE) 59 | 60 | Anthy-9000.gir: $(libanthygobject) Makefile 61 | Anthy_9000_gir_SCANNERFLAGS = \ 62 | --pkg=$(ANTHY_PC) \ 63 | --external-library \ 64 | --reparse-validate \ 65 | --identifier-prefix=Anthy \ 66 | --symbol-prefix=anthy \ 67 | --accept-unprefixed \ 68 | --warn-all \ 69 | $(NULL) 70 | Anthy_9000_gir_INCLUDES = GObject-2.0 71 | Anthy_9000_gir_LIBS = $(libanthygobject) $(ANTHY_PC) 72 | Anthy_9000_gir_CFLAGS = @ANTHY_CFLAGS@ 73 | Anthy_9000_gir_FILES = \ 74 | $(libanthygobject_1_0_la_SOURCES) \ 75 | $(anthyinclude_HEADERS) \ 76 | $(ANTHY_INCLUDEDIR)/anthy/anthy.h \ 77 | $(NULL) 78 | INTROSPECTION_GIRS += Anthy-9000.gir 79 | 80 | girdir = @ANTHY_GOBJECT_GIRDIR@ 81 | dist_gir_DATA = $(INTROSPECTION_GIRS) 82 | 83 | typelibsdir = @ANTHY_GOBJECT_TYPELIBSDIR@ 84 | typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) 85 | 86 | noinst_PROGRAMS = test 87 | 88 | test_SOURCES = test.c 89 | test_LDADD = \ 90 | $(libanthygobject) \ 91 | @GOBJECT2_LIBS@ \ 92 | @ANTHY_LIBS@ \ 93 | $(NULL) 94 | 95 | CLEANFILES = \ 96 | $(dist_gir_DATA) \ 97 | $(typelibs_DATA) \ 98 | $(NULL) 99 | 100 | DISTCLEANFILES = \ 101 | $(NULL) 102 | 103 | -------------------------------------------------------------------------------- /engine/python3/segment.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2014 Takao Fujiwara 8 | # Copyright (c) 2007-2014 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | from tables import * 25 | 26 | _half_full_table = [ 27 | (0x0020, 0x3000, 1), 28 | (0x0021, 0xFF01, 0x5E), 29 | ] 30 | 31 | def _h_to_f(c): 32 | code = ord (c) 33 | for half, full, size in _half_full_table: 34 | if code >= half and code < half + size: 35 | return chr(full + code - half) 36 | return c 37 | 38 | def unichar_half_to_full(c): 39 | tdl = {'"': '\u201d', "'": '\u2019', '`': '\u2018'} 40 | return tdl[c] if c in tdl else _h_to_f(c) 41 | 42 | class Segment(object): 43 | def __init__(self, enchars='', jachars=''): 44 | self._enchars = enchars 45 | self._jachars = jachars 46 | 47 | def append(self, enchar): 48 | raise NotImplementedError('append() is not implemented') 49 | 50 | def prepend(self, enchar): 51 | raise NotImplementedError('prepend() is not implemented') 52 | 53 | def pop(self, index=-1): 54 | raise NotImplementedError('pop() is not implemented') 55 | 56 | def is_finished(self): 57 | raise NotImplementedError('is_finised() is not implemented') 58 | 59 | def set_enchars(self, enchars): 60 | self.enchars = enchars 61 | 62 | def get_enchars(self): 63 | return self._enchars 64 | 65 | def set_jachars(self, jachars): 66 | self._jachars = jachars 67 | 68 | def get_jachars(self): 69 | return self._jachars 70 | 71 | def to_hiragana(self): 72 | if self._jachars: 73 | return self._jachars 74 | return self._enchars 75 | 76 | def to_katakana(self): 77 | if self._jachars: 78 | return ''.join([hiragana_katakana_table.get(c, (c, c, c))[0] for c in self._jachars]) 79 | return self._enchars 80 | 81 | def to_half_width_katakana(self): 82 | if self._jachars: 83 | return ''.join([hiragana_katakana_table.get(c, (c, c, c))[1] for c in self._jachars]) 84 | return self._enchars 85 | 86 | def to_latin(self): 87 | return self._enchars 88 | 89 | def to_wide_latin(self): 90 | return ''.join(map(unichar_half_to_full, self._enchars)) 91 | 92 | def is_empty(self): 93 | if self._enchars or self._jachars: 94 | return False 95 | return True 96 | -------------------------------------------------------------------------------- /engine/python2/segment.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2013 Takao Fujiwara 8 | # Copyright (c) 2007-2013 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | from tables import * 25 | 26 | _half_full_table = [ 27 | (0x0020, 0x3000, 1), 28 | (0x0021, 0xFF01, 0x5E), 29 | ] 30 | 31 | def _h_to_f(c): 32 | code = ord (c) 33 | for half, full, size in _half_full_table: 34 | if code >= half and code < half + size: 35 | return unichr (full + code - half) 36 | return c 37 | 38 | def unichar_half_to_full(c): 39 | tdl = {'"': u'\u201d', "'": u'\u2019', '`': u'\u2018'} 40 | return tdl[c] if c in tdl else _h_to_f(c) 41 | 42 | class Segment(object): 43 | def __init__(self, enchars=u'', jachars=u''): 44 | self._enchars = enchars 45 | self._jachars = jachars 46 | 47 | def append(self, enchar): 48 | raise NotImplementedError('append() is not implemented') 49 | 50 | def prepend(self, enchar): 51 | raise NotImplementedError('prepend() is not implemented') 52 | 53 | def pop(self, index=-1): 54 | raise NotImplementedError('pop() is not implemented') 55 | 56 | def is_finished(self): 57 | raise NotImplementedError('is_finised() is not implemented') 58 | 59 | def set_enchars(self, enchars): 60 | self.enchars = enchars 61 | 62 | def get_enchars(self): 63 | return self._enchars 64 | 65 | def set_jachars(self, jachars): 66 | self._jachars = jachars 67 | 68 | def get_jachars(self): 69 | return self._jachars 70 | 71 | def to_hiragana(self): 72 | if self._jachars: 73 | return self._jachars 74 | return self._enchars 75 | 76 | def to_katakana(self): 77 | if self._jachars: 78 | return u''.join(map(lambda c: hiragana_katakana_table.get(c, (c, c, c))[0], self._jachars)) 79 | return self._enchars 80 | 81 | def to_half_width_katakana(self): 82 | if self._jachars: 83 | return u''.join(map(lambda c: hiragana_katakana_table.get(c, (c, c, c))[1], self._jachars)) 84 | return self._enchars 85 | 86 | def to_latin(self): 87 | return self._enchars 88 | 89 | def to_wide_latin(self): 90 | return u''.join(map(unichar_half_to_full, self._enchars)) 91 | 92 | def is_empty(self): 93 | if self._enchars or self._jachars: 94 | return False 95 | return True 96 | -------------------------------------------------------------------------------- /ibus-anthy.spec.in: -------------------------------------------------------------------------------- 1 | %{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} 2 | %{!?enable_kasumi: %define enable_kasumi 0} 3 | 4 | %define sub_version 1.0 5 | %define require_ibus_version 1.4.2 6 | 7 | Name: @PACKAGE_NAME@ 8 | Version: @PACKAGE_VERSION@ 9 | Release: 1%{?dist} 10 | Summary: The Anthy engine for IBus input platform 11 | License: GPLv2+ 12 | Group: System Environment/Libraries 13 | URL: https://github.com/ibus/ibus/wiki 14 | Source0: https://github.com/ibus/ibus/releases/download/%{version}/%{name}-%{version}.tar.gz 15 | 16 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 17 | 18 | BuildRequires: anthy-devel 19 | BuildRequires: glib2-devel 20 | BuildRequires: gettext-devel 21 | BuildRequires: ibus 22 | BuildRequires: libtool 23 | BuildRequires: pkgconfig 24 | BuildRequires: gobject-introspection-devel 25 | 26 | Requires: ibus >= %require_ibus_version 27 | Requires: pygobject3 28 | Requires: anthy 29 | %if %enable_kasumi 30 | Requires: kasumi 31 | %endif 32 | 33 | %description 34 | The Anthy engine for IBus platform. It provides Japanese input method from 35 | libanthy. 36 | 37 | %package devel 38 | Summary: Development tools for ibus 39 | Group: Development/Libraries 40 | Requires: %{name} = %{version}-%{release} 41 | Requires: glib2-devel 42 | Requires: anthy-devel 43 | 44 | %description devel 45 | The ibus-anthy-devel package contains .so file and .gir files 46 | for developers. 47 | 48 | %prep 49 | %setup -q 50 | 51 | %build 52 | %configure --disable-static 53 | # make -C po update-gmo 54 | make %{?_smp_mflags} 55 | 56 | %install 57 | rm -rf $RPM_BUILD_ROOT 58 | make DESTDIR=${RPM_BUILD_ROOT} install 59 | rm -f $RPM_BUILD_ROOT%{_libdir}/libanthygobject-%{sub_version}.la 60 | 61 | %find_lang %{name} 62 | 63 | %clean 64 | rm -rf $RPM_BUILD_ROOT 65 | 66 | %post 67 | # recreate icon cache 68 | touch --no-create %{_datadir}/icons/hicolor || : 69 | [ -x %{_bindir}/gtk-update-icon-cache ] && \ 70 | %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || : 71 | [ -x %{_bindir}/glib-compile-schemas ] && \ 72 | [ -d %{_datadir}/glib-2.0/schemas ] && \ 73 | %{_bindir}/glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || : 74 | 75 | %postun 76 | # recreate icon cache 77 | touch --no-create %{_datadir}/icons/hicolor || : 78 | [ -x %{_bindir}/gtk-update-icon-cache ] && \ 79 | %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || : 80 | [ -x %{_bindir}/glib-compile-schemas ] && \ 81 | [ -d %{_datadir}/glib-2.0/schemas ] && \ 82 | %{_bindir}/glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || : 83 | 84 | %files -f %{name}.lang 85 | %defattr(-,root,root,-) 86 | %doc AUTHORS COPYING README 87 | # %dir %{python_sitearch}/ibus 88 | %{_libdir}/girepository-1.0/Anthy*.typelib 89 | %{_libdir}/libanthygobject-%{sub_version}.so.* 90 | %{_libexecdir}/ibus-*-anthy 91 | %{_datadir}/appdata/*.appdata.xml 92 | %{_datadir}/applications/ibus-setup-anthy.desktop 93 | %{_datadir}/glib-2.0/schemas/org.freedesktop.ibus.engine.anthy.gschema.xml 94 | %{_datadir}/ibus-anthy 95 | %{_datadir}/ibus/component/* 96 | %{_datadir}/icons/hicolor/scalable/apps/ibus-anthy.svg 97 | 98 | %files devel 99 | %{_datadir}/gir-1.0/Anthy*.gir 100 | %{_includedir}/ibus-anthy-%{sub_version} 101 | %{_libdir}/libanthygobject-%{sub_version}.so 102 | 103 | %changelog 104 | * @DATE_DISPLAY@ Peng Huang - @PACKAGE_VERSION@-1 105 | - Current version. 106 | -------------------------------------------------------------------------------- /setup/python3/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2007-2008 Peng Huang 6 | # Copyright (c) 2009 Hideaki ABE 7 | # Copyright (c) 2010-2021 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | desktop_in_in_files = ibus-setup-anthy.desktop.in.in 25 | desktop_in_files = $(desktop_in_in_files:.in.in=.in) 26 | 27 | $(desktop_in_files): %.desktop.in: %.desktop.in.in Makefile 28 | $(AM_V_GEN) sed \ 29 | -e "s|\@libexecdir\@|$(libexecdir)|" \ 30 | -e "s|\@pkgdatadir\@|$(pkgdatadir)|" \ 31 | $< > $@.tmp && mv $@.tmp $@ 32 | 33 | desktopdir=$(datadir)/applications 34 | desktop_DATA = ibus-setup-anthy.desktop 35 | 36 | $(desktop_DATA): $(desktop_in_files) Makefile 37 | $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@ 38 | 39 | BUILT_SOURCES = \ 40 | _config.py \ 41 | $(NULL) 42 | 43 | libexec_SCRIPTS = ibus-setup-anthy 44 | 45 | setup_anthy_PYTHON = \ 46 | _config.py \ 47 | anthyprefs.py \ 48 | main.py \ 49 | prefs.py \ 50 | setup.ui \ 51 | $(NULL) 52 | 53 | setup_anthy_built_files = \ 54 | $(BUILT_SOURCES) \ 55 | $(libexec_SCRIPTS) \ 56 | $(NULL) 57 | 58 | setup_anthy_built_in_files = $(addsuffix .in, $(setup_anthy_built_files)) 59 | 60 | setup_anthydir = $(datadir)/ibus-anthy/setup 61 | 62 | CONFIG_CLEAN_FILES = \ 63 | $(BUILT_SOURCES) \ 64 | $(NULL) 65 | 66 | CLEANFILES = \ 67 | $(BUILT_SOURCES) \ 68 | $(desktop_DATA) \ 69 | $(desktop_in_files) \ 70 | $(libexec_SCRIPTS) \ 71 | *.pyc \ 72 | $(NULL) 73 | 74 | EXTRA_DIST = \ 75 | $(desktop_in_in_files) \ 76 | $(setup_anthy_built_in_files) \ 77 | $(NULL) 78 | 79 | ibus-setup-anthy: ibus-setup-anthy.in 80 | sed -e "s|\@prefix\@|$(prefix)|g" \ 81 | -e "s|\@localedir\@|$(localedir)|g" \ 82 | -e "s|\@PYTHON\@|$(PYTHON)|g" \ 83 | $< > $@ 84 | 85 | _config.py: _config.py.in 86 | sed -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ 87 | -e "s|\@libexecdir\@|$(libexecdir)|g" \ 88 | -e "s|\@datadir\@|$(datadir)|g" \ 89 | -e "s|\@ANTHY_PC\@|$(ANTHY_PC)|g" \ 90 | -e "s|\@LAYOUT\@|$(LAYOUT)|g" \ 91 | -e "s|\@SYMBOL_CHAR_INT\@|$(SYMBOL_CHAR_INT)|g" \ 92 | -e "s|\@ICON_PREFERENCE\@|$(ICON_PREFERENCE)|g" \ 93 | -e "s|\@VERSION\@|$(VERSION)|g" \ 94 | $< > $@ 95 | 96 | # Need a time lag between .py and .py.in files to build .py files 97 | # because *_PYTHON valuables are installed in the tarball. 98 | dist-hook: 99 | @sleep 1; \ 100 | for in_file in $(setup_anthy_built_in_files) ; do \ 101 | if [ -f $(distdir)/$(srcdir)/$$in_file ] ; then \ 102 | touch $(distdir)/$(srcdir)/$$in_file; \ 103 | fi; \ 104 | done; 105 | 106 | test: 107 | $(ENV_IBUS_TEST) DBUS_DEBUG=true \ 108 | LANG=en_US \ 109 | PYTHONPATH=$(abs_top_srcdir):$(pyexecdir) \ 110 | IBUS_LOCALEDIR=@localedir@ \ 111 | $(PYTHON) $(srcdir)/main.py 112 | 113 | -------------------------------------------------------------------------------- /setup/python2/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2007-2008 Peng Huang 6 | # Copyright (c) 2009 Hideaki ABE 7 | # Copyright (c) 2010-2021 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | desktop_in_in_files = ibus-setup-anthy.desktop.in.in 25 | desktop_in_files = $(desktop_in_in_files:.in.in=.in) 26 | 27 | $(desktop_in_files): %.desktop.in: %.desktop.in.in Makefile 28 | $(AM_V_GEN) sed \ 29 | -e "s|\@libexecdir\@|$(libexecdir)|" \ 30 | -e "s|\@pkgdatadir\@|$(pkgdatadir)|" \ 31 | $< > $@.tmp && mv $@.tmp $@ 32 | 33 | desktopdir=$(datadir)/applications 34 | desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) 35 | 36 | $(desktop_DATA): $(desktop_in_files) Makefile 37 | $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@ 38 | 39 | BUILT_SOURCES = \ 40 | _config.py \ 41 | $(NULL) 42 | 43 | libexec_SCRIPTS = ibus-setup-anthy 44 | 45 | setup_anthy_PYTHON = \ 46 | _config.py \ 47 | anthyprefs.py \ 48 | main.py \ 49 | prefs.py \ 50 | setup.ui \ 51 | $(NULL) 52 | 53 | setup_anthy_built_files = \ 54 | $(BUILT_SOURCES) \ 55 | $(libexec_SCRIPTS) \ 56 | $(NULL) 57 | 58 | setup_anthy_built_in_files = $(addsuffix .in, $(setup_anthy_built_files)) 59 | 60 | setup_anthydir = $(datadir)/ibus-anthy/setup 61 | 62 | CONFIG_CLEAN_FILES = \ 63 | $(BUILT_SOURCES) \ 64 | $(NULL) 65 | 66 | CLEANFILES = \ 67 | $(BUILT_SOURCES) \ 68 | $(desktop_DATA) \ 69 | $(desktop_in_files) \ 70 | $(libexec_SCRIPTS) \ 71 | *.pyc \ 72 | $(NULL) 73 | 74 | EXTRA_DIST = \ 75 | $(desktop_in_in_files) \ 76 | $(setup_anthy_built_in_files) \ 77 | $(NULL) 78 | 79 | ibus-setup-anthy: ibus-setup-anthy.in 80 | sed -e "s|\@prefix\@|$(prefix)|g" \ 81 | -e "s|\@localedir\@|$(localedir)|g" \ 82 | -e "s|\@PYTHON\@|$(PYTHON)|g" \ 83 | $< > $@ 84 | 85 | _config.py: _config.py.in 86 | sed -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ 87 | -e "s|\@libexecdir\@|$(libexecdir)|g" \ 88 | -e "s|\@datadir\@|$(datadir)|g" \ 89 | -e "s|\@ANTHY_PC\@|$(ANTHY_PC)|g" \ 90 | -e "s|\@LAYOUT\@|$(LAYOUT)|g" \ 91 | -e "s|\@SYMBOL_CHAR_INT\@|$(SYMBOL_CHAR_INT)|g" \ 92 | -e "s|\@ICON_PREFERENCE\@|$(ICON_PREFERENCE)|g" \ 93 | -e "s|\@VERSION\@|$(VERSION)|g" \ 94 | $< > $@ 95 | 96 | # Need a time lag between .py and .py.in files to build .py files 97 | # because *_PYTHON valuables are installed in the tarball. 98 | dist-hook: 99 | @sleep 1; \ 100 | for in_file in $(setup_anthy_built_in_files) ; do \ 101 | if [ -f $(distdir)/$(srcdir)/$$in_file ] ; then \ 102 | touch $(distdir)/$(srcdir)/$$in_file; \ 103 | fi; \ 104 | done; 105 | 106 | test: 107 | $(ENV_IBUS_TEST) DBUS_DEBUG=true \ 108 | LANG=en_US \ 109 | PYTHONPATH=$(abs_top_srcdir):$(pyexecdir) \ 110 | IBUS_LOCALEDIR=@localedir@ \ 111 | $(PYTHON) $(srcdir)/main.py 112 | 113 | -------------------------------------------------------------------------------- /engine/python2/anthy.i: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4: */ 2 | /* 3 | * ibus-anthy - The Anthy engine for IBus 4 | * 5 | * Copyright (c) 2007-2008 Peng Huang 6 | * Copyright (c) 2010-2013 Takao Fujiwara 7 | * Copyright (c) 2007-2013 Red Hat, Inc. 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | %module anthy 25 | %{ 26 | /* Put header files here or function declarations like below */ 27 | #include 28 | %} 29 | 30 | %init %{ 31 | anthy_init (); 32 | %} 33 | 34 | /* anthy_context_t */ 35 | %include anthy/anthy.h 36 | struct anthy_context {}; 37 | %extend anthy_context { 38 | anthy_context () { 39 | return anthy_create_context (); 40 | } 41 | 42 | void reset () { 43 | anthy_reset_context (self); 44 | } 45 | 46 | int set_string (char *str) { 47 | return anthy_set_string (self, str); 48 | } 49 | 50 | void resize_segment (int a1, int a2) { 51 | anthy_resize_segment (self, a1, a2); 52 | } 53 | 54 | int get_stat (struct anthy_conv_stat *a1) { 55 | return anthy_get_stat (self, a1); 56 | } 57 | 58 | int get_segment_stat (int a1, struct anthy_segment_stat *a2) { 59 | return anthy_get_segment_stat (self, a1, a2); 60 | } 61 | 62 | char *get_segment (int a1, int a2) { 63 | int len; 64 | static char temp[512]; 65 | 66 | len = anthy_get_segment (self, a1, a2, temp, sizeof (temp)); 67 | if (len >= 0) 68 | return temp; 69 | else 70 | return NULL; 71 | } 72 | 73 | int commit_segment (int a1, int a2) { 74 | return anthy_commit_segment (self, a1, a2); 75 | } 76 | 77 | int set_prediction_string (const char *a1) { 78 | return anthy_set_prediction_string (self, a1); 79 | } 80 | 81 | int get_prediction_stat (struct anthy_prediction_stat *a1) { 82 | return anthy_get_prediction_stat (self, a1); 83 | } 84 | 85 | char *get_prediction (int a1) { 86 | int len; 87 | static char temp[512]; 88 | 89 | len = anthy_get_prediction (self, a1, temp, sizeof (temp)); 90 | 91 | if (len >= 0) 92 | return temp; 93 | else 94 | return NULL; 95 | } 96 | 97 | int commit_prediction (int a1) { 98 | return anthy_commit_prediction(self, a1); 99 | } 100 | 101 | void _print () { 102 | anthy_print_context (self); 103 | } 104 | 105 | int _set_encoding (int encoding) { 106 | return anthy_context_set_encoding (self, encoding); 107 | } 108 | 109 | int set_reconversion_mode (int mode) { 110 | return anthy_set_reconversion_mode (self, mode); 111 | } 112 | 113 | int init_personality (void) { 114 | return anthy_init_personality (); 115 | } 116 | 117 | int do_set_personality (const char *id) { 118 | return anthy_do_set_personality (id); 119 | } 120 | 121 | ~anthy_context () { 122 | anthy_release_context (self); 123 | } 124 | }; 125 | 126 | -------------------------------------------------------------------------------- /engine/python3/anthy.i: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4: */ 2 | /* 3 | * ibus-anthy - The Anthy engine for IBus 4 | * 5 | * Copyright (c) 2007-2008 Peng Huang 6 | * Copyright (c) 2010-2013 Takao Fujiwara 7 | * Copyright (c) 2007-2013 Red Hat, Inc. 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | %module anthy 25 | %{ 26 | /* Put header files here or function declarations like below */ 27 | #include 28 | %} 29 | 30 | %init %{ 31 | anthy_init (); 32 | %} 33 | 34 | /* anthy_context_t */ 35 | %include anthy/anthy.h 36 | struct anthy_context {}; 37 | %extend anthy_context { 38 | anthy_context () { 39 | return anthy_create_context (); 40 | } 41 | 42 | void reset () { 43 | anthy_reset_context (self); 44 | } 45 | 46 | int set_string (char *str) { 47 | return anthy_set_string (self, str); 48 | } 49 | 50 | void resize_segment (int a1, int a2) { 51 | anthy_resize_segment (self, a1, a2); 52 | } 53 | 54 | int get_stat (struct anthy_conv_stat *a1) { 55 | return anthy_get_stat (self, a1); 56 | } 57 | 58 | int get_segment_stat (int a1, struct anthy_segment_stat *a2) { 59 | return anthy_get_segment_stat (self, a1, a2); 60 | } 61 | 62 | char *get_segment (int a1, int a2) { 63 | int len; 64 | static char temp[512]; 65 | 66 | len = anthy_get_segment (self, a1, a2, temp, sizeof (temp)); 67 | if (len >= 0) 68 | return temp; 69 | else 70 | return NULL; 71 | } 72 | 73 | int commit_segment (int a1, int a2) { 74 | return anthy_commit_segment (self, a1, a2); 75 | } 76 | 77 | int set_prediction_string (const char *a1) { 78 | return anthy_set_prediction_string (self, a1); 79 | } 80 | 81 | int get_prediction_stat (struct anthy_prediction_stat *a1) { 82 | return anthy_get_prediction_stat (self, a1); 83 | } 84 | 85 | char *get_prediction (int a1) { 86 | int len; 87 | static char temp[512]; 88 | 89 | len = anthy_get_prediction (self, a1, temp, sizeof (temp)); 90 | 91 | if (len >= 0) 92 | return temp; 93 | else 94 | return NULL; 95 | } 96 | 97 | int commit_prediction (int a1) { 98 | return anthy_commit_prediction(self, a1); 99 | } 100 | 101 | void _print () { 102 | anthy_print_context (self); 103 | } 104 | 105 | int _set_encoding (int encoding) { 106 | return anthy_context_set_encoding (self, encoding); 107 | } 108 | 109 | int set_reconversion_mode (int mode) { 110 | return anthy_set_reconversion_mode (self, mode); 111 | } 112 | 113 | int init_personality (void) { 114 | return anthy_init_personality (); 115 | } 116 | 117 | int do_set_personality (const char *id) { 118 | return anthy_do_set_personality (id); 119 | } 120 | 121 | ~anthy_context () { 122 | anthy_release_context (self); 123 | } 124 | }; 125 | 126 | -------------------------------------------------------------------------------- /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 --keyword=Name --keyword=Comment --keyword 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 = Peng Huang \ 22 | Takao Fujiwara 23 | 24 | # This tells whether or not to prepend "GNU " prefix to the package 25 | # name that gets inserted into the header of the $(DOMAIN).pot file. 26 | # Possible values are "yes", "no", or empty. If it is empty, try to 27 | # detect it automatically by scanning the files in $(top_srcdir) for 28 | # "GNU packagename" string. 29 | PACKAGE_GNU = no 30 | 31 | # This is the email address or URL to which the translators shall report 32 | # bugs in the untranslated strings: 33 | # - Strings which are not entire sentences, see the maintainer guidelines 34 | # in the GNU gettext documentation, section 'Preparing Strings'. 35 | # - Strings which use unclear terms or require additional context to be 36 | # understood. 37 | # - Strings which make invalid assumptions about notation of date, time or 38 | # money. 39 | # - Pluralisation problems. 40 | # - Incorrect English spelling. 41 | # - Incorrect formatting. 42 | # It can be your email address, or a mailing list address where translators 43 | # can write to without being subscribed, or the URL of a web page through 44 | # which the translators can contact you. 45 | MSGID_BUGS_ADDRESS = https://github.com/ibus/ibus-anthy/issues 46 | 47 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 48 | # message catalogs shall be used. It is usually empty. 49 | EXTRA_LOCALE_CATEGORIES = 50 | 51 | # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' 52 | # context. Possible values are "yes" and "no". Set this to yes if the 53 | # package uses functions taking also a message context, like pgettext(), or 54 | # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. 55 | USE_MSGCTXT = yes 56 | 57 | # These options get passed to msgmerge. 58 | # Useful options are in particular: 59 | # --previous to keep previous msgids of translated messages, 60 | # --quiet to reduce the verbosity. 61 | MSGMERGE_OPTIONS = 62 | 63 | # These options get passed to msginit. 64 | # If you want to disable line wrapping when writing PO files, add 65 | # --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and 66 | # MSGINIT_OPTIONS. 67 | MSGINIT_OPTIONS = 68 | 69 | # This tells whether or not to regenerate a PO file when $(DOMAIN).pot 70 | # has changed. Possible values are "yes" and "no". Set this to no if 71 | # the POT file is checked in the repository and the version control 72 | # program ignores timestamps. 73 | PO_DEPENDS_ON_POT = no 74 | 75 | # This tells whether or not to forcibly update $(DOMAIN).pot and 76 | # regenerate PO files on "make dist". Possible values are "yes" and 77 | # "no". Set this to no if the POT file and PO files are maintained 78 | # externally. 79 | DIST_DEPENDS_ON_UPDATE_PO = no 80 | -------------------------------------------------------------------------------- /data/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2010-2021 Takao Fujiwara 6 | # Copyright (c) 2010-2018 Red Hat, Inc. 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 of the License, or 11 | # (at your option) 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 along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | dicts_DATA = \ 23 | emoji.t \ 24 | era.t \ 25 | oldchar.t \ 26 | symbol.t \ 27 | $(NULL) 28 | 29 | dictsdir = $(pkgdatadir)/dicts 30 | 31 | # rf. i18n metainfo.xml 32 | # http://www.freedesktop.org/software/appstream/docs/sect-Quickstart-Translation.html 33 | # https://blogs.gnome.org/hughsie/2016/01/25/appdata-and-the-gettext-domain/ 34 | metainfo_in_files = ibus-anthy.appdata.xml.in 35 | metainfo_DATA = org.freedesktop.ibus.engine.anthy.metainfo.xml 36 | metainfodir=$(datadir)/metainfo 37 | 38 | schemas_in_files = org.freedesktop.ibus.engine.anthy.gschema.xml.in 39 | schemas_DATA = $(schemas_in_files:.xml.in=.xml) 40 | schemasdir = $(datadir)/glib-2.0/schemas 41 | 42 | CLEANFILES = \ 43 | $(metainfo_DATA) \ 44 | $(schemas_DATA) \ 45 | emoji.t \ 46 | $(NULL) 47 | 48 | $(metainfo_DATA): $(metainfo_in_files) Makefile 49 | $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@ 50 | 51 | $(schemas_DATA): $(schemas_in_files) 52 | KASUMI_EXEC_BASENAME=`basename $(KASUMI_EXEC_FILE)`; \ 53 | $(SED) -e "s|\@ANTHY_ZIPCODE_FILE\@|$(ANTHY_ZIPCODE_FILE)|g" \ 54 | -e "s|\@KASUMI_EXEC_FILE\@|$(KASUMI_EXEC_FILE)|g" \ 55 | -e "s|\@KASUMI_EXEC_BASENAME\@|$$KASUMI_EXEC_BASENAME|g" \ 56 | -e "s|\@KASUMI_ICON_FILE\@|$(KASUMI_ICON_FILE)|g" \ 57 | -e "s|\@ON_OFF_KEYS\@|$(ON_OFF_KEYS)|g" \ 58 | -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ 59 | $< > $@ 60 | 61 | 62 | emoji.t: emoji-each.t emoji-emoji.t 63 | @echo "Generate $@"; \ 64 | $(SED) -e '/^#/d' $(srcdir)/emoji-emoji.t > emoji-emoji.t.$$$$; \ 65 | $(SED) -e "/^#@EMOJI_EMOJI@/r emoji-emoji.t.$$$$" \ 66 | $(srcdir)/emoji-each.t > emoji-each.t.$$$$; \ 67 | $(SED) -e '/^#@EMOJI_EMOJI@/d' emoji-each.t.$$$$ > emoji.t; \ 68 | rm emoji-emoji.t.$$$$ emoji-each.t.$$$$; \ 69 | $(NULL) 70 | 71 | if ENABLE_ZIPCODE 72 | dicts_DATA += zipcode.t 73 | 74 | zipcode.t: $(ANTHY_ZIPCODE_FILE) 75 | @echo "Generate $@"; \ 76 | $(PYTHON) zipcode-textdic.py $<; \ 77 | $(NULL) 78 | 79 | CLEANFILES += zipcode.t 80 | endif 81 | 82 | check: 83 | S_YEAR=`date '+%Y'`; \ 84 | M_YEAR=`echo $$S_YEAR | sed 'y/0123456789/0123456789/'`; \ 85 | grep -q $$M_YEAR $(srcdir)/era.t; \ 86 | if test $$? -ne 0 ; then \ 87 | echo "This year $$M_YEAR is not included in era.y"; \ 88 | exit 1; \ 89 | fi; 90 | 91 | install-data-hook: 92 | if test -z "$(DESTDIR)"; then \ 93 | glib-compile-schemas $(schemasdir); \ 94 | fi 95 | 96 | uninstall-hook: 97 | SCHEMAS_FILES=`ls $(schemasdir)/*.gschema.xml` || true; \ 98 | if test -z "$$SCHEMAS_FILES" && \ 99 | test -f $(schemasdir)/gschemas.compiled; then \ 100 | rm $(schemasdir)/gschemas.compiled; \ 101 | fi 102 | 103 | EXTRA_DIST = \ 104 | $(metainfo_in_files) \ 105 | $(schemas_in_files) \ 106 | emoji-each.t \ 107 | emoji-emoji.t \ 108 | era.t \ 109 | oldchar.t \ 110 | symbol.t \ 111 | zipcode-textdic.py \ 112 | $(NULL) 113 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bus Report Template 2 | description: | 3 | Please fill in the following items if you don't know the root cause. 4 | assignees: 5 | - fujiwarat 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: "Please describe the issue title to be able to identify your issue 10 | against others." 11 | - type: markdown 12 | attributes: 13 | value: "Wrong title - \"ibus typing not work with any applications\". 14 | Good title - \"Cannot output multi-byte strings with gedit\" or 15 | \"Cannot switch keyboard layouts with Super-space in Wayland\" or 16 | \"String output is slow with firefox in Cinnamon\"" 17 | - type: input 18 | id: distro 19 | attributes: 20 | label: Distribution and Version 21 | description: Which distribusion and version? Check /etc/fedora-release 22 | placeholder: Fedora 41 23 | validations: 24 | required: true 25 | - type: input 26 | id: desktop 27 | attributes: 28 | label: Desktop Environment and Version 29 | description: | 30 | Which desktop environment and version? 31 | Check $XDG_CURRENT_DESKTOP and your ISO image. 32 | placeholder: GNOME 3.24 33 | validations: 34 | required: true 35 | - type: dropdown 36 | id: session 37 | attributes: 38 | label: Session Type 39 | description: Which session type? Check $XDG_SESSION_TYPE 40 | options: 41 | - Wayland 42 | - X11 43 | default: 0 44 | validations: 45 | required: true 46 | - type: input 47 | id: application 48 | attributes: 49 | label: Application and Version 50 | description: Which application and version? 51 | placeholder: gedit 3.24, leafpad, kate, xterm 52 | validations: 53 | required: true 54 | - type: input 55 | id: version-core 56 | attributes: 57 | label: IBus version 58 | description: Run `ibus version` 59 | placeholder: 1.5.31 60 | validations: 61 | required: true 62 | - type: input 63 | id: version 64 | attributes: 65 | label: ibus-anthy Version 66 | description: | 67 | Open "IBus Anthy preferences" dialog (`ibus-setup-anthy`) from IBus 68 | panel menu or ibus-setup, and select "About" tab. 69 | placeholder: 1.5.16 70 | validations: 71 | required: true 72 | - type: textarea 73 | id: description 74 | attributes: 75 | label: Issue Description 76 | description: Please describe the issue summary. 77 | validations: 78 | required: false 79 | - type: textarea 80 | id: reproducing 81 | attributes: 82 | label: Steps to Reproduce 83 | description: | 84 | How do you trigger this bug? Please walk us through it step by step. 85 | value: | 86 | 1. 87 | 2. 88 | 3. 89 | render: bash 90 | validations: 91 | required: true 92 | - type: textarea 93 | id: inevitability 94 | attributes: 95 | label: | 96 | Can you reproduce your problem when you restart ibus-daemon? (yes / no) 97 | description: | 98 | Please answer "yes" or "no" and also complement your issue as needed. 99 | Run `ibus exit` and `ibus-daemon --xim &` 100 | validations: 101 | required: true 102 | - type: textarea 103 | id: error_messages 104 | attributes: 105 | label: | 106 | Do you see any errors when you run ibus-daemon with the verbose option? 107 | description: | 108 | Run `ibus-daemon --xim --verbose &` and look at the output when you 109 | encounter your problem. 110 | You might need to run `journalctl` for GNOME sessions. 111 | validations: 112 | required: false 113 | - type: textarea 114 | id: error_config 115 | attributes: 116 | label: | 117 | Can you reproduce your problem with a new user account instead of the 118 | current your account? (yes / no) 119 | description: | 120 | Please answer "yes" or "no" and also complement your issue as needed. 121 | validations: 122 | required: true 123 | - type: textarea 124 | id: note 125 | attributes: 126 | label: | 127 | Add any other context about the problem here. 128 | validations: 129 | required: false 130 | -------------------------------------------------------------------------------- /engine/python2/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2007-2008 Peng Huang 6 | # Copyright (c) 2010-2019 Takao Fujiwara 7 | # Copyright (c) 2007-2017 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | BUILT_SOURCES = _config.py 24 | 25 | engine_anthy_PYTHON = \ 26 | _config.py \ 27 | engine.py \ 28 | factory.py \ 29 | jastring.py \ 30 | kana.py \ 31 | main.py \ 32 | romaji.py \ 33 | segment.py \ 34 | tables.py \ 35 | thumb.py \ 36 | $(NULL) 37 | engine_anthydir = $(pkgdatadir)/engine 38 | engine_anthy_built_files = $(BUILT_SOURCES) 39 | engine_anthy_built_in_files = $(addsuffix .in, $(engine_anthy_built_files)) 40 | 41 | PYGTK2_ANTHY_RAW = anthy.i 42 | PYGTK2_ANTHY_GEN = anthy.py anthy_wrap.c 43 | 44 | if HAVE_PYGTK2_ANTHY 45 | anthy_DATA = \ 46 | anthy.py \ 47 | $(NULL) 48 | anthy_LTLIBRARIES = _anthy.la 49 | anthydir = @pyexecdir@ 50 | 51 | _anthy_la_SOURCES = \ 52 | $(NULL) 53 | 54 | nodist__anthy_la_SOURCES = \ 55 | anthy_wrap.c \ 56 | $(NULL) 57 | 58 | _anthy_la_CFLAGS = \ 59 | @ANTHY_CFLAGS@ \ 60 | @PYTHON_CFLAGS@ \ 61 | $(NULL) 62 | 63 | _anthy_la_LDFLAGS = \ 64 | @ANTHY_LIBS@ \ 65 | @PYTHON_LIBS@ \ 66 | -avoid-version \ 67 | -module \ 68 | $(NULL) 69 | 70 | anthy.py anthy_wrap.c: anthy.i 71 | $(SWIG) -python $(ANTHY_CFLAGS) -I/usr/include -o anthy_wrap.c $(srcdir)/anthy.i 72 | endif 73 | 74 | libexec_SCRIPTS = ibus-engine-anthy 75 | component_DATA = anthy.xml 76 | componentdir = $(datadir)/ibus/component 77 | engine_DATA = default.xml 78 | enginedir = $(pkgdatadir)/engine 79 | 80 | # $(SYMBOL_XML) cannot be extracted in Makefile but $(libexecdir) can be 81 | # extracted to ${exec_prefix}/libexec so use capital @LIBEXECDIR@ here. 82 | %.xml: %.inputMethod.xml.in 83 | sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|g" \ 84 | -e "s|\@PKGDATADIR\@|$(pkgdatadir)|g" \ 85 | $< > $@ 86 | 87 | ibus-engine-anthy: ibus-engine-anthy.in 88 | sed -e "s|\@prefix\@|$(prefix)|g" \ 89 | -e "s|\@exec_prefix\@|$(exec_prefix)|g" \ 90 | -e "s|\@libexecdir\@|$(libexecdir)|g" \ 91 | -e "s|\@datarootdir\@|$(datarootdir)|g" \ 92 | -e "s|\@PACKAGE\@|$(PACKAGE)|g" \ 93 | -e "s|\@PYTHON\@|$(PYTHON)|g" \ 94 | -e "s|\@ENV_IBUS_ENGINE\@|$(ENV_IBUS_ENGINE)|g" \ 95 | $< > $@ 96 | 97 | _config.py: _config.py.in 98 | sed -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ 99 | -e "s|\@libexecdir\@|$(libexecdir)|g" \ 100 | -e "s|\@datadir\@|$(datadir)|g" \ 101 | -e "s|\@ANTHY_PC\@|$(ANTHY_PC)|g" \ 102 | -e "s|\@LAYOUT\@|$(LAYOUT)|g" \ 103 | -e "s|\@SYMBOL_CHAR_INT\@|$(SYMBOL_CHAR_INT)|g" \ 104 | -e "s|\@ICON_PREFERENCE\@|$(ICON_PREFERENCE)|g" \ 105 | -e "s|\@VERSION\@|$(VERSION)|g" \ 106 | $< > $@ 107 | 108 | test: 109 | $(ENV_IBUS_TEST) \ 110 | DBUS_DEBUG=true \ 111 | IBUS_ANTHY_PKGDATADIR=$(abs_top_srcdir) \ 112 | PYTHONPATH=$(builddir)/.libs:@pyexecdir@ \ 113 | $(PYTHON) \ 114 | $(srcdir)/main.py 115 | 116 | EXTRA_DIST = \ 117 | $(engine_anthy_built_in_files) \ 118 | $(PYGTK2_ANTHY_RAW) \ 119 | anthy.inputMethod.xml.in.in \ 120 | default.inputMethod.xml.in.in \ 121 | ibus-engine-anthy.in \ 122 | $(NULL) 123 | 124 | CLEANFILES = \ 125 | $(BUILT_SOURCES) \ 126 | $(PYGTK2_ANTHY_GEN) \ 127 | anthy.xml \ 128 | default.xml \ 129 | ibus-engine-anthy \ 130 | *.pyc \ 131 | $(NULL) 132 | 133 | DISTCLEANFILES = \ 134 | anthy.inputMethod.xml.in \ 135 | default.inputMethod.xml.in \ 136 | $(NULL) 137 | 138 | # Need a time lag between .py and .py.in files to build .py files 139 | # because *_PYTHON valuables are installed in the tarball. 140 | dist-hook: 141 | @sleep 1; \ 142 | for in_file in $(engine_anthy_built_in_files) ; do \ 143 | if [ -f $(distdir)/$(srcdir)/$$in_file ] ; then \ 144 | touch $(distdir)/$(srcdir)/$$in_file; \ 145 | fi; \ 146 | done; 147 | 148 | -------------------------------------------------------------------------------- /engine/python3/Makefile.am: -------------------------------------------------------------------------------- 1 | # vim:set noet ts=4: 2 | # 3 | # ibus-anthy - The Anthy engine for IBus 4 | # 5 | # Copyright (c) 2007-2008 Peng Huang 6 | # Copyright (c) 2010-2019 Takao Fujiwara 7 | # Copyright (c) 2007-2017 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | BUILT_SOURCES = _config.py 24 | 25 | engine_anthy_PYTHON = \ 26 | _config.py \ 27 | engine.py \ 28 | factory.py \ 29 | jastring.py \ 30 | kana.py \ 31 | main.py \ 32 | romaji.py \ 33 | segment.py \ 34 | tables.py \ 35 | thumb.py \ 36 | $(NULL) 37 | engine_anthydir = $(pkgdatadir)/engine 38 | engine_anthy_built_files = $(BUILT_SOURCES) 39 | engine_anthy_built_in_files = $(addsuffix .in, $(engine_anthy_built_files)) 40 | 41 | PYGTK2_ANTHY_RAW = anthy.i 42 | PYGTK2_ANTHY_GEN = anthy.py anthy_wrap.c 43 | 44 | if HAVE_PYGTK2_ANTHY 45 | anthy_DATA = \ 46 | anthy.py \ 47 | $(NULL) 48 | anthy_LTLIBRARIES = _anthy.la 49 | anthydir = @pyexecdir@ 50 | 51 | _anthy_la_SOURCES = \ 52 | $(NULL) 53 | 54 | nodist__anthy_la_SOURCES = \ 55 | anthy_wrap.c \ 56 | $(NULL) 57 | 58 | _anthy_la_CFLAGS = \ 59 | @ANTHY_CFLAGS@ \ 60 | @PYTHON_CFLAGS@ \ 61 | $(NULL) 62 | 63 | _anthy_la_LDFLAGS = \ 64 | @ANTHY_LIBS@ \ 65 | @PYTHON_LIBS@ \ 66 | -avoid-version \ 67 | -module \ 68 | $(NULL) 69 | 70 | anthy.py anthy_wrap.c: anthy.i 71 | $(SWIG) -python $(ANTHY_CFLAGS) -I/usr/include -o anthy_wrap.c $(srcdir)/anthy.i 72 | endif 73 | 74 | libexec_SCRIPTS = ibus-engine-anthy 75 | component_DATA = anthy.xml 76 | componentdir = $(datadir)/ibus/component 77 | engine_DATA = default.xml 78 | enginedir = $(pkgdatadir)/engine 79 | 80 | # $(SYMBOL_XML) cannot be extracted in Makefile but $(libexecdir) can be 81 | # extracted to ${exec_prefix}/libexec so use capital @LIBEXECDIR@ here. 82 | %.xml: %.inputMethod.xml.in 83 | sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|g" \ 84 | -e "s|\@PKGDATADIR\@|$(pkgdatadir)|g" \ 85 | $< > $@ 86 | 87 | ibus-engine-anthy: ibus-engine-anthy.in 88 | sed -e "s|\@prefix\@|$(prefix)|g" \ 89 | -e "s|\@exec_prefix\@|$(exec_prefix)|g" \ 90 | -e "s|\@libexecdir\@|$(libexecdir)|g" \ 91 | -e "s|\@datarootdir\@|$(datarootdir)|g" \ 92 | -e "s|\@PACKAGE\@|$(PACKAGE)|g" \ 93 | -e "s|\@PYTHON\@|$(PYTHON)|g" \ 94 | -e "s|\@ENV_IBUS_ENGINE\@|$(ENV_IBUS_ENGINE)|g" \ 95 | $< > $@ 96 | 97 | _config.py: _config.py.in 98 | sed -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ 99 | -e "s|\@libexecdir\@|$(libexecdir)|g" \ 100 | -e "s|\@datadir\@|$(datadir)|g" \ 101 | -e "s|\@ANTHY_PC\@|$(ANTHY_PC)|g" \ 102 | -e "s|\@LAYOUT\@|$(LAYOUT)|g" \ 103 | -e "s|\@SYMBOL_CHAR_INT\@|$(SYMBOL_CHAR_INT)|g" \ 104 | -e "s|\@ICON_PREFERENCE\@|$(ICON_PREFERENCE)|g" \ 105 | -e "s|\@VERSION\@|$(VERSION)|g" \ 106 | $< > $@ 107 | 108 | test: 109 | $(ENV_IBUS_TEST) \ 110 | DBUS_DEBUG=true \ 111 | IBUS_ANTHY_PKGDATADIR=$(abs_top_srcdir) \ 112 | PYTHONPATH=$(builddir)/.libs:@pyexecdir@ \ 113 | $(PYTHON) \ 114 | $(srcdir)/main.py 115 | 116 | EXTRA_DIST = \ 117 | $(engine_anthy_built_in_files) \ 118 | $(PYGTK2_ANTHY_RAW) \ 119 | anthy.inputMethod.xml.in.in \ 120 | default.inputMethod.xml.in.in \ 121 | ibus-engine-anthy.in \ 122 | $(NULL) 123 | 124 | CLEANFILES = \ 125 | $(BUILT_SOURCES) \ 126 | $(PYGTK2_ANTHY_GEN) \ 127 | anthy.xml \ 128 | default.xml \ 129 | ibus-engine-anthy \ 130 | *.pyc \ 131 | $(NULL) 132 | 133 | DISTCLEANFILES = \ 134 | anthy.inputMethod.xml.in \ 135 | default.inputMethod.xml.in \ 136 | $(NULL) 137 | 138 | # Need a time lag between .py and .py.in files to build .py files 139 | # because *_PYTHON valuables are installed in the tarball. 140 | dist-hook: 141 | @sleep 1; \ 142 | for in_file in $(engine_anthy_built_in_files) ; do \ 143 | if [ -f $(distdir)/$(srcdir)/$$in_file ] ; then \ 144 | touch $(distdir)/$(srcdir)/$$in_file; \ 145 | fi; \ 146 | done; 147 | 148 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | ibus-anthy (1.2.5-1ppa1~maverick2) maverick; urgency=low 2 | 3 | * New upstream release. 4 | * debian/control: 5 | - bump standards version to 3.9.1. 6 | - add kasumi dependency. 7 | * debian/rules: 8 | - add --with-anthy-zipcode. 9 | 10 | -- Takao Fujiwara Thu, 16 Dec 2010 21:50:16 +0900 11 | 12 | ibus-anthy (1.2.1-1) unstable; urgency=low 13 | 14 | * New upstream release. 15 | - debian/patches/broken-link: removed. 16 | - debian/patches/zipcode-t-dir: removed. 17 | * debian/control: 18 | - set maintainer to IME team, add me to uploaders. 19 | - update Vcs-* fields. 20 | 21 | -- LI Daobing Thu, 29 Apr 2010 20:21:17 +0800 22 | 23 | ibus-anthy (1.2.0.20100313-2) unstable; urgency=low 24 | 25 | * debian/source/format: 3.0. 26 | * Fix "ibus-anthy fails to start with "File exist" error" (Closes: #575540) 27 | - debian/patches/broken-link: also remove broken link in ~/.anthy 28 | - debian/patches/zipcode-t-dir: change the dir of zipcode.t 29 | 30 | -- LI Daobing Sat, 10 Apr 2010 18:39:23 +0800 31 | 32 | ibus-anthy (1.2.0.20100313-1) unstable; urgency=low 33 | 34 | * New upstream release. 35 | * debian/control: bump standards version to 3.8.4. 36 | 37 | -- LI Daobing Sun, 21 Mar 2010 18:36:23 +0800 38 | 39 | ibus-anthy (1.2.0.20100115-1) unstable; urgency=low 40 | 41 | * New upstream release. 42 | - fix convert_to_half do same as convert_to_half_katakana (LP: #475031) 43 | 44 | -- LI Daobing Sun, 24 Jan 2010 16:17:50 +0800 45 | 46 | ibus-anthy (1.2.0.20091127-1) unstable; urgency=low 47 | 48 | * New upstream release. 49 | 50 | -- LI Daobing Sat, 28 Nov 2009 14:15:30 +0800 51 | 52 | ibus-anthy (1.2.0.20090917-1) unstable; urgency=low 53 | 54 | * new upstream release. 55 | 56 | -- LI Daobing Thu, 17 Sep 2009 19:37:06 +0800 57 | 58 | ibus-anthy (1.2.0.20090907-1) unstable; urgency=low 59 | 60 | * new upstream release. 61 | * debian/rules: update clean rule. 62 | 63 | -- LI Daobing Mon, 14 Sep 2009 21:23:56 +0800 64 | 65 | ibus-anthy (1.2.0.20090813-2) unstable; urgency=low 66 | 67 | [ Loïc Minier ] 68 | * Drop useless CROSS logic in rules; build uses dh_auto_configure. 69 | * Drop /usr/share/misc/config.{sub,.guess} conditionals since these are 70 | always present (thanks to autotools-dev bdep). 71 | * Drop bogus ibus-anthy.lintian-overrides since the binary truly lacks a 72 | manpage. 73 | * Pass -s to dh_* in binary-arch. 74 | * Drop non-existent clean0 from .PHONY. 75 | * Cleanup rules droppping boilerplate comments and superfluous whitespace. 76 | * Add XS-Python-Version/XB-Python-Version: fields. 77 | * Version the python-dev bdep to >= 2.5. 78 | * Drop useless autoconf, automake, and libtool bdeps. 79 | * Update pot file during build; bdep on intltool. 80 | 81 | [ LI Daobing ] 82 | * debian/control: bump standards version to 3.8.3. 83 | 84 | -- LI Daobing Tue, 25 Aug 2009 19:19:26 +0800 85 | 86 | ibus-anthy (1.2.0.20090813-1) unstable; urgency=low 87 | 88 | * new upstream release. 89 | * debian/control: change vcs url. 90 | 91 | -- LI Daobing Thu, 13 Aug 2009 21:48:20 +0800 92 | 93 | ibus-anthy (1.2.0.20090804-1) unstable; urgency=low 94 | 95 | * new upstream release. 96 | 97 | -- LI Daobing Wed, 05 Aug 2009 20:31:23 +0800 98 | 99 | ibus-anthy (1.2.0.20090617-1) unstable; urgency=low 100 | 101 | * new upstream release. 102 | * debian/control: 103 | - depends on ibus >= 1.2 104 | - bump standards version to 3.8.2 105 | 106 | -- LI Daobing Sat, 20 Jun 2009 23:15:11 +0800 107 | 108 | ibus-anthy (1.1.0.20090603-1) unstable; urgency=low 109 | 110 | * new upstream release. 111 | 112 | -- LI Daobing Sat, 06 Jun 2009 16:58:31 +0800 113 | 114 | ibus-anthy (1.1.0.20090402-1) unstable; urgency=low 115 | 116 | * initial release to Debian (closes: #521627) 117 | * new upstream release. 118 | * debian/debian/patches/01_rpath.dpatch: merged by upstream, removed. 119 | * no patch is needed. remove dpatch from debian/* 120 | * debian/control: 121 | - bump standards version to 3.8.1. 122 | - change maintainer's email. 123 | - add ${python:Depends} to depends. 124 | 125 | -- LI Daobing Thu, 23 Apr 2009 19:47:11 +0800 126 | 127 | ibus-anthy (0.1.1.20080912-0ubuntu1) jaunty; urgency=low 128 | 129 | * Initial release (LP: #312715) 130 | * debian/patches/01_rpath.dpatch: remove rpath in Makefile.am 131 | 132 | -- LI Daobing Fri, 13 Feb 2009 20:41:26 +0800 133 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | 8 | jobs: 9 | version: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | container: ["fedora:41", "fedora:42", "ubuntu:jammy"] 15 | steps: 16 | - name: Check container sha tags 17 | run: | 18 | docker pull "${{ matrix.container }}" 19 | docker inspect "${{ matrix.container }}" --format=${{ '{{.RepoDigests}}{{.Created}}' }} 20 | 21 | 22 | build: 23 | runs-on: ubuntu-latest 24 | 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | container: ["fedora:41", "fedora:42", "ubuntu:jammy"] 29 | 30 | container: 31 | image: ${{ matrix.container }} 32 | 33 | steps: 34 | - name: Install distro packages 35 | env: 36 | # For autogen.sh 37 | UBUNTU_PACKAGES_AUTOGEN: > 38 | autopoint 39 | strace 40 | # For make from 41 | # https://packages.ubuntu.com/search?searchon=sourcenames&keywords=ibus-anthy 42 | UBUNTU_PACKAGES_MAKE: > 43 | desktop-file-utils 44 | gettext 45 | gir1.2-ibus-1.0 46 | libanthy-dev 47 | libdconf-dev 48 | libgirepository1.0-dev 49 | libglib2.0-dev 50 | libgtk-3-bin 51 | libgtk-3-dev 52 | libtool 53 | pkg-config 54 | python3-all 55 | # for make check 56 | UBUNTU_PACKAGES_CI_KEY: > 57 | ibus 58 | python3-pip 59 | FEDORA_PACKAGES_MAKE: > 60 | anthy-unicode-devel 61 | desktop-file-utils 62 | dconf-devel 63 | gettext-devel 64 | git 65 | gtk3-devel 66 | gobject-introspection-devel 67 | ibus-devel 68 | libtool 69 | python3-devel 70 | python3-gobject 71 | # for ibus-keypress 72 | FEDORA_PACKAGES_CI_KEY: > 73 | gnome-shell 74 | gnome-shell-extension-no-overview 75 | libXtst-devel 76 | python3-pycotap 77 | FEDORA_PACKAGES_DISTRO: > 78 | patch 79 | procps-ng 80 | strace 81 | 82 | run: | 83 | case "${{ matrix.container }}" in 84 | ubuntu*) 85 | cat /etc/lsb-release 86 | echo "apt-get update -qq -y" 87 | apt-get update -qq -y 88 | echo "apt-get install -q -y git" 89 | apt-get install -q -y git 90 | PACKAGES=$(echo "$UBUNTU_PACKAGES_AUTOGEN" | tr -d '\n') 91 | PACKAGES=$(echo "$PACKAGES $UBUNTU_PACKAGES_MAKE" | tr -d '\n') 92 | PACKAGES=$(echo "$PACKAGES $UBUNTU_PACKAGES_CI_KEY" | tr -d '\n') 93 | echo "apt-get install -y $PACKAGES" 94 | apt-get install -y $PACKAGES 95 | dpkg -l | grep anthy 96 | ;; 97 | fedora*) 98 | cat /etc/fedora-release 99 | DNF=dnf 100 | echo "$DNF -y update" 101 | $DNF -y update 102 | echo "$DNF -y install git which" 103 | $DNF -y install git which 104 | PACKAGES=$(echo "$FEDORA_PACKAGES_MAKE" | tr -d '\n') 105 | PACKAGES=$(echo "$PACKAGES $FEDORA_PACKAGES_CI_KEY" | tr -d '\n') 106 | PACKAGES=$(echo "$PACKAGES $FEDORA_PACKAGES_DISTRO" | tr -d '\n') 107 | echo "$DNF -y install $PACKAGES" 108 | $DNF -y install $PACKAGES 109 | ;; 110 | *) 111 | echo "Not supported ${{ matrix.container }}" 112 | ls /etc/*release 113 | cat /etc/*release 114 | exit 1 115 | ;; 116 | esac 117 | pwd 118 | echo $GITHUB_WORKSPACE 119 | ls -a 120 | 121 | - uses: actions/checkout@v2 122 | with: 123 | #repository: ibus/ibus-anthy 124 | fetch-depth: 200 125 | 126 | - name: Fetch git tags 127 | run: | 128 | pwd 129 | id 130 | ls -al 131 | git config --global --add safe.directory $GITHUB_WORKSPACE 132 | git branch 133 | git fetch --prune --unshallow --tags 134 | echo $PATH 135 | 136 | - name: Run autogen 137 | # configure options from 138 | # https://salsa.debian.org/debian/ibus/-/blob/master/debian/rules 139 | run: > 140 | ./autogen.sh 141 | --libexecdir=/usr/lib/ibus 142 | --with-layout='default' 143 | --with-python=python3 144 | --with-hotkeys 145 | --with-on-off-keys="'Zenkaku_Hankaku', 'Ctrl+space', 'Ctrl+J'" 146 | --enable-installed-tests 147 | --disable-static 148 | 149 | - name: Run make 150 | # UTF-8 locale is required for sed 'y/0123456789/0123456789/' 151 | # 152 | # Set the cutom DESTDIR because the default DESTDIR 153 | # /home/travis/bulid/fujiwarat/$PKG/ibus/ibus-$VERSION/_inst seems to 154 | # be too long and failed to set DESTDIR to install 155 | # bindings/pygobject/IBus.py 156 | run: > 157 | env LANG=C.UTF-8 158 | make distcheck 159 | VERBOSE=1 160 | DESTDIR="$HOME/build/$USER/dest" 161 | 162 | - name: Desktop file validation 163 | run: | 164 | make -C setup/python3 ibus-setup-anthy.desktop 165 | echo "desktop-file-validate ./setup/python3/ibus-setup-anthy.desktop" 166 | desktop-file-validate ./setup/python3/ibus-setup-anthy.desktop 167 | 168 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ibus-anthy 2 | It is a Japanese input engine for IBus. 3 | 4 | 5 | Installation 6 | ============ 7 | 8 | The following is the online document: 9 | https://github.com/ibus/ibus/wiki/Install 10 | 11 | #1. Build & Install IBus 12 | * Obtain source code 13 | 14 | IBus source code can either be download from IBus download page 15 | (https://github.com/ibus/ibus/releases) 16 | (If you use ibus for the first time, the download page is more stable than 17 | git.) 18 | 19 | $ zcat ibus-xx.tar.gz | tar xfv - 20 | $ cd ibus-xx 21 | 22 | * The 'xx' is a version number. 23 | 24 | or obtained from git with following commands: 25 | 26 | $ git clone git://github.com/ibus/ibus.git ibus 27 | $ cd ibus 28 | 29 | * 'git clone --help' shows the usage. 30 | 31 | * Build and Install 32 | After source code is extracted from tarball or git, use following command 33 | to build and install: 34 | 35 | $ ./autogen.sh --prefix='/usr' --sysconfdir='/etc' --libdir='/usr/lib' \ 36 | --enable-gtk-doc 37 | $ make 38 | $ sudo make install 39 | 40 | (Change the paths '/usr', '/etc', '/usr/lib' according to your system 41 | configuration.) 42 | 43 | or if you use Linux system, probably rpmbuild is easier to build applications. 44 | 45 | # cp ibus-xx.tar.gz /usr/src/$distributer/SOURCE 46 | # rpmbuild -bp ibus/ibus.spec.in 47 | # rpmbuild -bb ibus/ibus.spec.in 48 | 49 | * Register IBus as a Gtk immodule 50 | For i386 51 | 52 | $ sudo update-gtk-immodules i386-redhat-linux-gnu 53 | 54 | or 55 | 56 | $ sudo gtk-query-immodules-2.0-32 \ 57 | /usr/lib/gtk-2.0/2.10.0/immodules/im-ibus.so >> \ 58 | /etc/gtk-2.0/i386-redhat-linux-gnu/gtk.immodules 59 | 60 | For x86_64 61 | 62 | $ sudo update-gtk-immodules x86_64-redhat-linux-gnu 63 | 64 | or 65 | 66 | $ sudo gtk-query-immodules-2.0-64 \ 67 | /usr/lib/gtk-2.0/2.10.0/immodules/im-ibus.so >> \ 68 | /etc/gtk-2.0/x86_64-redhat-linux-gnu/gtk.immodules 69 | 70 | (Replace the string i386-redhat-linux-gnu or path 71 | /usr/lib/gtk-2.0/2.10.0/immodules/im-ibus.so with the setting that matches 72 | your system.) 73 | 74 | * Update icon caches 75 | 76 | $ ls /usr/share/icons/*/*/*/ibus* 77 | /usr/share/icons/hicolor/16x16/apps/ibus-keyboard.png 78 | /usr/share/icons/hicolor/22x22/apps/ibus-keyboard.png 79 | /usr/share/icons/hicolor/24x24/apps/ibus-keyboard.png 80 | /usr/share/icons/hicolor/32x32/apps/ibus-keyboard.png 81 | /usr/share/icons/hicolor/48x48/apps/ibus-keyboard.png 82 | /usr/share/icons/hicolor/scalable/apps/ibus-keyboard.svg 83 | $ sudo gtk-update-icon-cache /usr/share/icons/hicolor 84 | 85 | 86 | #2. Build & Install Anthy 87 | 88 | Download anthy source from Anthy Web 89 | (http://en.sourceforge.jp/projects/anthy/) 90 | 91 | $ zcat anthy-xx.tar.gz | tar xfv - 92 | $ cd anthy 93 | $ ./configure --prefix=/usr 94 | $ make 95 | $ sudo make install 96 | 97 | * The 'xx' is a version number. 98 | 99 | 100 | #3. Build & Install Kasumi 101 | 102 | Kasumi is not required but probably useful for you. 103 | Download kasumi source from Kasumi Web 104 | (http://en.sourceforge.jp/projects/kasumi/) 105 | 106 | $ zcat kasumi-xx.tar.gz | tar xfv - 107 | $ cd kasumi 108 | $ ./configure --prefix=/usr 109 | $ make 110 | $ sudo make install 111 | 112 | * The 'xx' is a version number. 113 | 114 | 115 | #4. Build & Install IBus Anthy 116 | Download ibus-anthy source from IBus download page 117 | (https://github.com/ibus/ibus-anthy/releases) 118 | or 119 | Use git clone git://github.com/ibus/ibus-anthy.git ibus-anthy 120 | 121 | $ zcat ibus-anthy-xx.tar.gz | tar xfv - 122 | $ cd ibus-anthy 123 | $ ./autogen.sh --prefix=/usr 124 | $ make 125 | $ sudo make install 126 | 127 | * The 'xx' is a version number. 128 | 129 | or if you use Linux system, probably rpmbuild is easier to build applications. 130 | 131 | # cp ibus-anthy-xx.tar.gz /usr/src/$distributer/SOURCE 132 | # rpmbuild -bp ibus-anthy/ibus-anthy.spec.in 133 | # rpmbuild -bb ibus-anthy/ibus-anthy.spec.in 134 | 135 | or if you use Linux system, probably you can install rpm with yum. 136 | 137 | # yum install --enablerepo=rawhide ibus-anthy 138 | 139 | 140 | #5. Run iBus 141 | * Run ibus-daemon to start ibus daemon with either way: 142 | 143 | * Distribution tool likes im-chooser, im-switch 144 | * Add a new /etc/xdg/autostart/ibus.desktop to invoke 'ibus-daemon --xim' 145 | * Manual 146 | 147 | $ pkill -9 ibus 148 | $ ps -ef | grep ibus 149 | $ /usr/bin/ibus-daemon --xim & 150 | 151 | After ibus-daemin is invoked, Run ibus-setup to set the preference, 152 | enable input methods, also start ibus daemon. 153 | 154 | e.g. 155 | 156 | $ ps -ef | grep ibus 157 | foo 15735 15518 0 11:30 pts/3 00:00:17 /usr/bin/ibus-daemon --xim 158 | foo 20037 15735 0 12:58 pts/3 00:00:00 /usr/libexec/ibus-gconf 159 | foo 20039 15735 0 12:58 pts/3 00:00:06 python /usr/share/ibus/ui/gtk/main.py 160 | foo 20041 1 0 12:58 pts/3 00:00:00 /usr/libexec/ibus-x11 --kill-daemon 161 | foo 20042 15735 0 12:58 pts/3 00:00:01 python /usr/share/ibus-anthy/engine/main.py --ibus 162 | 163 | 164 | #6. Run gnome, kde or old X applications 165 | * Set following environment varible for Gtk: 166 | 167 | $ GTK_IM_MODULE=ibus 168 | 169 | For KDE: 170 | 171 | $ QT_IM_MODULE=ibus 172 | 173 | and other X applications 174 | 175 | $ XMODIFIERS="@im=ibus" 176 | 177 | e.g. 178 | 179 | $ env GTK_IM_MODULE=ibus gedit 180 | 181 | To enable input method, Type Ctrl + Space. 182 | 183 | 184 | Bug Reports 185 | =========== 186 | https://github.com/ibus/ibus/wiki/BugReport 187 | 188 | 189 | Questions 190 | ========= 191 | http://groups.google.com/group/ibus-user 192 | http://groups.google.com/group/ibus-devel 193 | Also refer AUTHORS file 194 | 195 | -------------------------------------------------------------------------------- /tests/test-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:set noet ts=4: 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2018-2021 Takao Fujiwara 7 | # Copyright (c) 2018 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | # This test runs $(top_builddir)/engine/python*/engine.py before install anthy 24 | 25 | BUILDDIR="."; 26 | SRCDIR="."; 27 | ANTHY_SCHEMA_FILE=org.freedesktop.ibus.engine.anthy.gschema.xml; 28 | SCHEMA_TMPDIR=""; 29 | FORCE_TEST=""; 30 | RUN_ARGS=""; 31 | # Fedora 39 Docker does not provide USER 32 | USER=${USER:-`id | sed -e "s/uid=[0-9]*(\([^)]*\)).*/\1/"`}; 33 | 34 | usage() 35 | { 36 | echo -e \ 37 | "This test runs top_builddir/engine/python*/engine.py before install anthy\n" \ 38 | "$PROGNAME [OPTIONS…]\n" \ 39 | "\n" \ 40 | "OPTIONS:\n" \ 41 | "-h, --help This help\n" \ 42 | "-v, --version Show version\n" \ 43 | "-b, --builddir=BUILDDIR Set the BUILDDIR\n" \ 44 | "-s, --srcdir=SOURCEDIR Set the SOURCEDIR\n" \ 45 | "-f, --force Run test suite forcibly\n" \ 46 | "" 47 | } 48 | 49 | parse_args() 50 | { 51 | # This is GNU getopt. "sudo port getopt" in BSD? 52 | ARGS=`getopt -o hvb:s: --long help,version,builddir:,srcdir: \ 53 | -- "$@"`; 54 | eval set -- "$ARGS" 55 | while [ 1 ] ; do 56 | case "$1" in 57 | -h | --help ) usage; exit 0;; 58 | -v | --version ) echo -e "$VERSION"; exit 0;; 59 | -b | --builddir ) BUILDDIR="$2"; shift 2;; 60 | -s | --srcdir ) SRCDIR="$2"; shift 2;; 61 | -f | --force ) FORCE_TEST="1"; shift;; 62 | -- ) shift; break;; 63 | * ) usage; exit 1;; 64 | esac; 65 | done; 66 | } 67 | 68 | maybe_install_pycotap() { 69 | # Red Hat specific hint. 70 | if test -f /etc/redhat-release ; then 71 | if ! rpm -q --quiet python3-pycotap; then 72 | echo "Please install python3-pycotap" 73 | exit -1 74 | fi 75 | fi; 76 | 77 | # Check if pycotap is already available. 78 | # No pycotap.__main__ and cannot be directly executed with `-m` option 79 | if ! python3 -c "import pycotap"; then 80 | PIP=pip3 81 | if ! command -v $PIP &> /dev/null ; then 82 | PIP=pip 83 | fi 84 | echo "pycotap not found; installing via $PIP" 85 | if ! $PIP install pycotap --user; then 86 | echo "failed to install pycotap" 87 | exit -1 88 | fi 89 | fi 90 | } 91 | 92 | init_environment() 93 | { 94 | if test x$FORCE_TEST != x ; then 95 | RUN_ARGS="$RUN_ARGS --force"; 96 | fi; 97 | 98 | maybe_install_pycotap 99 | 100 | if test ! -f $BUILDDIR/../data/$ANTHY_SCHEMA_FILE ; then 101 | echo "Not found $BUILDDIR/../data/$ANTHY_SCHEMA_FILE"; 102 | exit -1; 103 | fi; 104 | SCHEMA_TMPDIR=`mktemp -d`; 105 | if test $? -ne 0 ; then 106 | echo "FAILED mktemp"; 107 | exit -1; 108 | fi; 109 | cp $BUILDDIR/../data/$ANTHY_SCHEMA_FILE $SCHEMA_TMPDIR; 110 | glib-compile-schemas $SCHEMA_TMPDIR; 111 | if test $? -ne 0 ; then 112 | echo "FAILED glib-compile-schemas $SCHEMA_TMPDIR"; 113 | exit -1; 114 | fi; 115 | if test ! -f $SCHEMA_TMPDIR/gschemas.compiled ; then 116 | echo "Not found $SCHEMA_TMPDIR/gschemas.compiled"; 117 | exit -1; 118 | fi; 119 | ls $BUILDDIR/../gir/Anthy*.typelib > /dev/null; 120 | if test $? -ne 0 ; then 121 | echo "Not found $BUILDDIR/../gir/Anthy*.typelib"; 122 | exit -1; 123 | fi; 124 | } 125 | 126 | run_ibus_daemon() 127 | { 128 | # this script can run without Display 129 | ibus-daemon --daemonize --verbose --panel disable --emoji-extension disable; 130 | sleep 1; 131 | SUSER=`echo "$USER" | cut -c 1-7`; 132 | ps -ef | grep "$SUSER" | grep ibus | grep -v grep; 133 | } 134 | 135 | run_test_suite() 136 | { 137 | export GSETTINGS_SCHEMA_DIR=$SCHEMA_TMPDIR; 138 | export GI_TYPELIB_PATH=$BUILDDIR/../gir; 139 | LD_LIBRARY_PATH=$BUILDDIR/../gir/.libs; 140 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$BUILDDIR/../gir; 141 | export GTK_IM_MODULE=ibus; 142 | 143 | for i in 3; do 144 | echo "#### Starting Python$i API test $RUN_ARGS"; 145 | env IBUS_ANTHY_ENGINE_PATH=$SRCDIR/../engine/python$i \ 146 | IBUS_ANTHY_SETUP_PATH=$SRCDIR/../setup/python$i \ 147 | python$i -u $SRCDIR/anthytest.py $RUN_ARGS; 148 | RETVAL=$? 149 | # Return 5 with "NO TESTS RAN" in unittest/runner.py since python 3.12.1 150 | if test $RETVAL -ne 0 && test $RETVAL -ne 5; then 151 | exit 1; 152 | fi; 153 | if test x$FORCE_TEST = x ; then 154 | rm -r $HOME/.anthy; 155 | rm -r $HOME/.config/anthy; 156 | fi; 157 | done; 158 | } 159 | 160 | finit() 161 | { 162 | rm -rf $SCHEMA_TMPDIR; 163 | ibus exit; 164 | } 165 | 166 | main() 167 | { 168 | parse_args $@; 169 | init_environment; 170 | run_ibus_daemon; 171 | run_test_suite; 172 | finit; 173 | } 174 | 175 | main $@; 176 | -------------------------------------------------------------------------------- /engine/python3/kana.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2017 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import sys 25 | 26 | from tables import * 27 | import segment 28 | 29 | _UNFINISHED_HIRAGANA = set('かきくけこさしすせそたちつてとはひふへほ') 30 | 31 | class KanaSegment(segment.Segment): 32 | _prefs = None 33 | _kana_typing_rule_method = None 34 | _kana_voiced_consonant_rule = None 35 | _kana_voiced_consonant_dict = None 36 | 37 | def __init__(self, enchars='', jachars=''): 38 | if not jachars: 39 | jachars = self.__get_kana_typing_rule(enchars, '') 40 | super(KanaSegment, self).__init__(enchars, jachars) 41 | 42 | @classmethod 43 | def INIT_KANA_TYPING_RULE(cls, prefs): 44 | cls._prefs = prefs 45 | if prefs == None: 46 | cls._kana_typing_rule_method = None 47 | return 48 | if cls._kana_typing_rule_method == None: 49 | cls._init_kana_typing_method() 50 | if cls._kana_voiced_consonant_rule == None and \ 51 | cls._kana_typing_rule_method != None: 52 | cls._init_kana_voiced_consonant_rule() 53 | 54 | @classmethod 55 | def _init_kana_typing_method(cls, method=None): 56 | prefs = cls._prefs 57 | if method == None: 58 | method = prefs.get_value('kana-typing-rule', 'method') 59 | if method == None: 60 | method = 'jp' 61 | cls._kana_typing_rule_method = method 62 | keymap = prefs.get_value('kana-typing-rule', 'list') 63 | if cls._kana_typing_rule_method not in keymap.keys(): 64 | cls._kana_typing_rule_method = None 65 | 66 | @classmethod 67 | def _init_kana_voiced_consonant_rule(cls): 68 | prefs = cls._prefs 69 | # Create kana_voiced_consonant_rule dynamically. 70 | # E.g. 't' + '@' on jp kbd becomes Hiragana GA 71 | # 't' + '[' on us kbd becomes Hiragana GA 72 | # If the customized table provides U+309b with other chars, 73 | # it needs to be detected dynamically. 74 | cls._kana_voiced_consonant_rule = {} 75 | method = cls._kana_typing_rule_method 76 | keymap = prefs.get_value('kana-typing-rule', 'list')[method] 77 | for gkey in keymap.keys(): 78 | value = keymap[gkey] 79 | key = prefs.typing_from_config_key(gkey) 80 | if key == '': 81 | continue 82 | if value == chr(0x309b): 83 | for no_voiced, voiced in \ 84 | list(kana_voiced_consonant_no_rule.items()): 85 | rule = no_voiced + key 86 | cls._kana_voiced_consonant_rule[rule] = voiced 87 | if value == chr(0x309c): 88 | for no_voiced, voiced in \ 89 | list(kana_semi_voiced_consonant_no_rule.items()): 90 | rule = no_voiced + key 91 | cls._kana_voiced_consonant_rule[rule] = voiced 92 | 93 | @classmethod 94 | def RESET(cls, prefs, section, key, value): 95 | cls._prefs = prefs 96 | if section == 'kana-typing-rule' and value != None: 97 | cls._kana_typing_rule_method = None 98 | cls._kana_voiced_consonant_rule = None 99 | cls.INIT_KANA_TYPING_RULE(prefs) 100 | 101 | def __get_kana_typing_rule(self, enchars, retval=None): 102 | prefs = self._prefs 103 | value = None 104 | method = self._kana_typing_rule_method 105 | if method != None: 106 | # Need to send Unicode to typing_to_config_key instead of UTF-8 107 | # not to separate U+A5 108 | gkey = prefs.typing_to_config_key(enchars) 109 | if gkey == '': 110 | return None 111 | enchars = gkey 112 | keymap = prefs.get_value('kana-typing-rule', 'list')[method] 113 | value = keymap.get(enchars) 114 | if value == '': 115 | value = None 116 | if value == None: 117 | value = retval 118 | else: 119 | value = kana_typing_rule_static.get(enchars, retval) 120 | return value 121 | 122 | def is_finished(self): 123 | return not (self._jachars in _UNFINISHED_HIRAGANA) 124 | 125 | def append(self, enchar): 126 | if enchar == '\0' or enchar == '': 127 | return [] 128 | if self._jachars: 129 | text = self._jachars + enchar 130 | if self._kana_voiced_consonant_rule != None: 131 | jachars = self._kana_voiced_consonant_rule.get(text, None) 132 | if jachars: 133 | self._enchars = self._enchars + enchar 134 | self._jachars = jachars 135 | return [] 136 | return [KanaSegment(enchar)] 137 | self._enchars = self._enchars + enchar 138 | self._jachars = self.__get_kana_typing_rule(self._enchars, '') 139 | return [] 140 | 141 | def prepend(self, enchar): 142 | if enchar == '\0' or enchar == '': 143 | return [] 144 | if self._enchars == '': 145 | self._enchars = enchar 146 | self._jachars = self.__get_kana_typing_rule(self._enchars, '') 147 | return [] 148 | return [KanaSegment(enchar)] 149 | 150 | def pop(self, index=-1): 151 | if index == -1: 152 | index = len(self._enchars) - 1 153 | if index < 0 or index >= len(self._enchars): 154 | raise IndexError('Out of bound') 155 | if self.is_finished(): 156 | self._enchars = '' 157 | self._jachars = '' 158 | else: 159 | enchars = list(self._enchars) 160 | del enchars[index] 161 | self._enchars = ''.join(enchars) 162 | self._jachars = self.__get_kana_typing_rule(self._enchars, '') 163 | -------------------------------------------------------------------------------- /engine/python2/kana.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2017 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import sys 25 | 26 | from tables import * 27 | import segment 28 | 29 | _UNFINISHED_HIRAGANA = set(u'かきくけこさしすせそたちつてとはひふへほ') 30 | 31 | class KanaSegment(segment.Segment): 32 | _prefs = None 33 | _kana_typing_rule_method = None 34 | _kana_voiced_consonant_rule = None 35 | _kana_voiced_consonant_dict = None 36 | 37 | def __init__(self, enchars=u'', jachars=u''): 38 | if not jachars: 39 | jachars = self.__get_kana_typing_rule(enchars, u'') 40 | super(KanaSegment, self).__init__(enchars, jachars) 41 | 42 | @classmethod 43 | def INIT_KANA_TYPING_RULE(cls, prefs): 44 | cls._prefs = prefs 45 | if prefs == None: 46 | cls._kana_typing_rule_method = None 47 | return 48 | if cls._kana_typing_rule_method == None: 49 | cls._init_kana_typing_method() 50 | if cls._kana_voiced_consonant_rule == None and \ 51 | cls._kana_typing_rule_method != None: 52 | cls._init_kana_voiced_consonant_rule() 53 | 54 | @classmethod 55 | def _init_kana_typing_method(cls, method=None): 56 | prefs = cls._prefs 57 | if method == None: 58 | method = prefs.get_value('kana-typing-rule', 'method') 59 | if method == None: 60 | method = 'jp' 61 | cls._kana_typing_rule_method = method 62 | keymap = prefs.get_value('kana-typing-rule', 'list') 63 | if cls._kana_typing_rule_method not in keymap.keys(): 64 | cls._kana_typing_rule_method = None 65 | 66 | @classmethod 67 | def _init_kana_voiced_consonant_rule(cls): 68 | prefs = cls._prefs 69 | # Create kana_voiced_consonant_rule dynamically. 70 | # E.g. 't' + '@' on jp kbd becomes Hiragana GA 71 | # 't' + '[' on us kbd becomes Hiragana GA 72 | # If the customized table provides U+309b with other chars, 73 | # it needs to be detected dynamically. 74 | cls._kana_voiced_consonant_rule = {} 75 | method = cls._kana_typing_rule_method 76 | keymap = prefs.get_value('kana-typing-rule', 'list')[method] 77 | for gkey in keymap.keys(): 78 | value = keymap[gkey] 79 | key = prefs.typing_from_config_key(gkey) 80 | if key == '': 81 | continue 82 | if value == unichr(0x309b).encode('utf-8'): 83 | for no_voiced, voiced in \ 84 | kana_voiced_consonant_no_rule.items(): 85 | rule = no_voiced + key.decode('utf-8') 86 | cls._kana_voiced_consonant_rule[rule] = voiced 87 | if value == unichr(0x309c).encode('utf-8'): 88 | for no_voiced, voiced in \ 89 | kana_semi_voiced_consonant_no_rule.items(): 90 | rule = no_voiced + key.decode('utf-8') 91 | cls._kana_voiced_consonant_rule[rule] = voiced 92 | 93 | @classmethod 94 | def RESET(cls, prefs, section, key, value): 95 | cls._prefs = prefs 96 | if section == 'kana-typing-rule' and value != None: 97 | cls._kana_typing_rule_method = None 98 | cls._kana_voiced_consonant_rule = None 99 | cls.INIT_KANA_TYPING_RULE(prefs) 100 | 101 | def __get_kana_typing_rule(self, enchars, retval=None): 102 | prefs = self._prefs 103 | value = None 104 | method = self._kana_typing_rule_method 105 | if method != None: 106 | # Need to send Unicode to typing_to_config_key instead of UTF-8 107 | # not to separate U+A5 108 | gkey = prefs.typing_to_config_key(enchars) 109 | if gkey == '': 110 | return None 111 | enchars = gkey 112 | keymap = prefs.get_value('kana-typing-rule', 'list')[method] 113 | value = prefs.unicode(keymap.get(enchars)) 114 | if value == '': 115 | value = None 116 | if value == None: 117 | value = retval 118 | else: 119 | value = kana_typing_rule_static.get(enchars, retval) 120 | return value 121 | 122 | def is_finished(self): 123 | return not (self._jachars in _UNFINISHED_HIRAGANA) 124 | 125 | def append(self, enchar): 126 | if enchar == u'\0' or enchar == u'': 127 | return [] 128 | if self._jachars: 129 | text = self._jachars + enchar 130 | if self._kana_voiced_consonant_rule != None: 131 | jachars = self._kana_voiced_consonant_rule.get(text, None) 132 | if jachars: 133 | self._enchars = self._enchars + enchar 134 | self._jachars = jachars 135 | return [] 136 | return [KanaSegment(enchar)] 137 | self._enchars = self._enchars + enchar 138 | self._jachars = self.__get_kana_typing_rule(self._enchars, u'') 139 | return [] 140 | 141 | def prepend(self, enchar): 142 | if enchar == u'\0' or enchar == u'': 143 | return [] 144 | if self._enchars == u'': 145 | self._enchars = enchar 146 | self._jachars = self.__get_kana_typing_rule(self._enchars, u'') 147 | return [] 148 | return [KanaSegment(enchar)] 149 | 150 | def pop(self, index=-1): 151 | if index == -1: 152 | index = len(self._enchars) - 1 153 | if index < 0 or index >= len(self._enchars): 154 | raise IndexError('Out of bound') 155 | if self.is_finished(): 156 | self._enchars = u'' 157 | self._jachars = u'' 158 | else: 159 | enchars = list(self._enchars) 160 | del enchars[index] 161 | self._enchars = u''.join(enchars) 162 | self._jachars = self.__get_kana_typing_rule(self._enchars, u'') 163 | -------------------------------------------------------------------------------- /tests/test-console.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # vim:set noet ts=4: 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2018 Takao Fujiwara 7 | # Copyright (c) 2018 Red Hat, Inc. 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License along 20 | # with this program; if not, write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | 23 | # This test runs /usr/share/ibus-anthy/engine/engine.py after install anthy 24 | 25 | PROGNAME=`basename $0`; 26 | VERSION=0.1; 27 | DISPLAY=:99.0; 28 | BUILDDIR="."; 29 | SRCDIR="."; 30 | HAVE_GRAPHICS=1; 31 | DESKTOP_COMMAND="gnome-session"; 32 | PYTHON="python3"; 33 | PID_XORG=0; 34 | PID_GNOME_SESSION=0; 35 | FORCE_TEST=""; 36 | RUN_ARGS="--exit"; 37 | # Fedora 39 Docker does not provide USER 38 | USER=${USER:-`id | sed -e "s/uid=[0-9]*(\([^)]*\)).*/\1/"`}; 39 | 40 | usage() 41 | { 42 | echo -e \ 43 | "This test runs /usr/share/ibus-anthy/engine/engine.py after install anthy\n" \ 44 | "$PROGNAME [OPTIONS…]\n" \ 45 | "\n" \ 46 | "OPTIONS:\n" \ 47 | "-h, --help This help\n" \ 48 | "-v, --version Show version\n" \ 49 | "-b, --builddir=BUILDDIR Set the BUILDDIR\n" \ 50 | "-s, --srcdir=SOURCEDIR Set the SOURCEDIR\n" \ 51 | "-c, --no-graphics Use Xvfb instead of Xorg\n" \ 52 | "-p, --python=PATH Use the PATH of python2 or python3\n" \ 53 | "-d, --desktop=DESKTOP Run DESTKTOP. The default is gnome-session\n"\ 54 | "-f, --force Run test suite forcibly\n" \ 55 | "" 56 | } 57 | 58 | parse_args() 59 | { 60 | # This is GNU getopt. "sudo port getopt" in BSD? 61 | ARGS=`getopt -o hvb:s:cp:d:f --long help,version,builddir:,srcdir:,no-graphics,python:,desktop:,force \ 62 | -- "$@"`; 63 | eval set -- "$ARGS" 64 | while [ 1 ] ; do 65 | case "$1" in 66 | -h | --help ) usage; exit 0;; 67 | -v | --version ) echo -e "$VERSION"; exit 0;; 68 | -b | --builddir ) BUILDDIR="$2"; shift 2;; 69 | -s | --srcdir ) SRCDIR="$2"; shift 2;; 70 | -c | --no-graphics ) HAVE_GRAPHICS=0; shift;; 71 | -p | --python ) PYTHON="$2"; shift 2;; 72 | -d | --desktop ) DESKTOP_COMMAND="$2"; shift 2;; 73 | -f | --force ) FORCE_TEST="1"; shift;; 74 | -- ) shift; break;; 75 | * ) usage; exit 1;; 76 | esac; 77 | done; 78 | } 79 | 80 | init_desktop() 81 | { 82 | if test x$FORCE_TEST != x ; then 83 | RUN_ARGS="$RUN_ARGS --force"; 84 | fi; 85 | 86 | if test ! -f $HOME/.config/gnome-initial-setup-done ; then 87 | if test ! -f /var/lib/AccountsService/users/$USER ; then 88 | mkdir -p /var/lib/AccountsService/users 89 | cat >> /var/lib/AccountsService/users/$USER << _EOF 90 | [User] 91 | Language=ja_JP.UTF-8 92 | XSession=gnome 93 | SystemAccount=false 94 | _EOF 95 | fi 96 | mkdir -p $HOME/.config 97 | touch $HOME/.config/gnome-initial-setup-done 98 | fi 99 | 100 | # Prevent from launching a XDG dialog 101 | XDG_LOCALE_FILE="$HOME/.config/user-dirs.locale" 102 | if test -f $XDG_LOCALE_FILE ; then 103 | XDG_LANG_ORIG=`cat $XDG_LOCALE_FILE` 104 | XDG_LANG_NEW=`echo $LANG | sed -e 's/\(.*\)\..*/\1/'` 105 | if [ "$XDG_LANG_ORIG" != "$XDG_LANG_NEW" ] ; then 106 | echo "Overriding XDG locale $XDG_LANG_ORIG with $XDG_LANG_NEW" 107 | echo "$XDG_LANG_NEW" > $XDG_LOCALE_FILE 108 | fi 109 | fi 110 | } 111 | 112 | run_dbus_daemon() 113 | { 114 | a=`ps -ef | grep dbus-daemon | grep "\-\-system" | grep -v session | grep -v grep` 115 | if test x"$a" = x ; then 116 | eval `dbus-launch --sh-syntax` 117 | fi 118 | SUSER=`echo "$USER" | cut -c 1-7`; 119 | a=`ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | grep session | grep -v grep` 120 | if test x"$a" = x ; then 121 | systemctl --user start dbus 122 | export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus 123 | fi 124 | systemctl --user status dbus | col -b 125 | ps -ef | grep dbus-daemon | grep "$SUSER" | grep -v gdm | egrep 'session|system' | grep -v grep 126 | systemctl --user show-environment | col -b 127 | } 128 | 129 | run_desktop() 130 | { 131 | if test $HAVE_GRAPHICS -eq 1 ; then 132 | /usr/libexec/Xorg.wrap -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xorg.log -config ./xorg.conf -configdir . $DISPLAY & 133 | else 134 | /usr/bin/Xvfb $DISPLAY -noreset +extension GLX +extension RANDR +extension RENDER -screen 0 1280x1024x24 & 135 | fi; 136 | PID_XORG=$!; 137 | sleep 1; 138 | export DISPLAY=$DISPLAY; 139 | $DESKTOP_COMMAND & 140 | PID_GNOME_SESSION=$!; 141 | sleep 30; 142 | if test "$DESKTOP_COMMAND" != "gnome-session" ; then 143 | ibus-daemon --daemonize --verbose; 144 | sleep 1; 145 | fi 146 | } 147 | 148 | run_test_suite() 149 | { 150 | rm -rf $HOME/.anthy; 151 | rm -rf $HOME/.config/anthy; 152 | cd `dirname $0`; 153 | 154 | echo "#### Starting $PYTHON API test $RUN_ARGS"; 155 | export GTK_IM_MODULE=ibus 156 | $PYTHON -u $SRCDIR/anthytest.py $RUN_ARGS; 157 | RETVAL=$? 158 | # Return 5 with "NO TESTS RAN" in unittest/runner.py since python 3.12.1 159 | if test $RETVAL -ne 0 && test $RETVAL -ne 5; then 160 | exit 1; 161 | fi; 162 | if test x$FORCE_TEST = x ; then 163 | for ANTHY_CONFIG in ".anthy" ".config/anthy" ; do 164 | if test -d $HOME/$ANTHY_CONFIG ; then 165 | rm -r $HOME/$ANTHY_CONFIG; 166 | fi; 167 | done; 168 | fi; 169 | } 170 | 171 | finit() 172 | { 173 | if "test $DESKTOP_COMMAND" != "gnome-session" ; then 174 | ibus exit; 175 | fi; 176 | kill $PID_GNOME_SESSION $PID_XORG; 177 | } 178 | 179 | main() 180 | { 181 | parse_args $@; 182 | init_desktop; 183 | run_dbus_daemon; 184 | run_desktop; 185 | run_test_suite; 186 | finit; 187 | } 188 | 189 | main $@; 190 | -------------------------------------------------------------------------------- /gir/anthygcontext.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 2 | /* vim:set et sts=4: */ 3 | /* ibus-anthy - The Anthy engine for IBus 4 | * Copyright (c) 2012-2019 Takao Fujiwara 5 | * Copyright (c) 2012 Peng Huang 6 | * Copyright (c) 2012-2013 Red Hat, Inc. 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 of the License, or 11 | * (at your option) 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 along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #ifndef __ANTHY_GCONTEXT_H_ 24 | #define __ANTHY_GCONTEXT_H_ 25 | 26 | #include 27 | #include 28 | 29 | /* 30 | * Type macros. 31 | */ 32 | #define ANTHY_TYPE_GCONTEXT \ 33 | (anthy_gcontext_get_type ()) 34 | #define ANTHY_GCONTEXT(obj) \ 35 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANTHY_TYPE_GCONTEXT, AnthyGContext)) 36 | #define ANTHY_GCONTEXT_CLASS(class) \ 37 | (G_TYPE_CHECK_CLASS_CAST ((class), ANTHY_TYPE_GCONTEXT, AnthyGContextClass)) 38 | #define ANTHY_IS_GCONTEXT(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANTHY_TYPE_GCONTEXT)) 40 | #define ANTHY_IS_GCONTEXT_CLASS(class) \ 41 | (G_TYPE_CHECK_CLASS_TYPE ((class), ANTHY_TYPE_GCONTEXT)) 42 | #define ANTHY_GCONTEXT_GET_CLASS(obj) \ 43 | (G_TYPE_INSTANCE_GET_CLASS ((obj), ANTHY_TYPE_GCONTEXT, AnthyGContextClass)) 44 | 45 | typedef struct _AnthyGContext AnthyGContext; 46 | typedef struct _AnthyGContextPrivate AnthyGContextPrivate; 47 | typedef struct _AnthyGContextClass AnthyGContextClass; 48 | 49 | G_BEGIN_DECLS 50 | 51 | /** 52 | * AnthyGContext: 53 | * 54 | * An #AnthyGContext is an object that handles conversion strings. 55 | */ 56 | struct _AnthyGContext { 57 | GInitiallyUnowned parent; 58 | 59 | AnthyGContextPrivate *priv; 60 | 61 | /*< private >*/ 62 | gpointer pdummy[8]; 63 | }; 64 | 65 | struct _AnthyGContextClass { 66 | GInitiallyUnownedClass parent; 67 | 68 | /*< private >*/ 69 | gpointer pdummy[8]; 70 | }; 71 | 72 | GType anthy_gcontext_get_type (void); 73 | 74 | /** 75 | * anthy_gcontext_new: 76 | * @returns: A newly allocated #AnthyGContext 77 | * 78 | * New an #AnthyGobject. 79 | */ 80 | AnthyGContext *anthy_gcontext_new (void); 81 | 82 | /** 83 | * anthy_gcontext_set_encoding: 84 | * @encoding: An encoding 85 | * 86 | * Set an encoding. 87 | */ 88 | int anthy_gcontext_set_encoding (AnthyGContext *obj, 89 | int encoding); 90 | 91 | /** 92 | * anthy_gcontext_init_personality: 93 | * 94 | * Initialize the personal dictionaries. 95 | */ 96 | void anthy_gcontext_init_personality (AnthyGContext *obj); 97 | 98 | /** 99 | * anthy_gcontext_do_set_personality: 100 | * @dict_name: a Dictionary name 101 | * 102 | * Set a personal dictionary. 103 | */ 104 | int anthy_gcontext_do_set_personality (AnthyGContext *obj, 105 | const gchar *dict_name); 106 | 107 | /** 108 | * anthy_gcontext_resize_segment: 109 | * @nth: nth segment 110 | * @resize: size 111 | * 112 | * Resize the nth segment. 113 | */ 114 | void anthy_gcontext_resize_segment (AnthyGContext *obj, 115 | int nth, 116 | int resize); 117 | /** 118 | * anthy_gcontext_set_string: 119 | * @string: A conversion string 120 | * 121 | * Set a conversion string. 122 | */ 123 | int anthy_gcontext_set_string (AnthyGContext *obj, 124 | const gchar * string); 125 | /** 126 | * anthy_gcontext_get_nr_segments: 127 | * @returns: The number of the converted segments 128 | * 129 | * The number of the converted segments 130 | */ 131 | int anthy_gcontext_get_nr_segments (AnthyGContext *obj); 132 | 133 | /** 134 | * anthy_gcontext_get_segment: 135 | * @nth_seg: Nth segment 136 | * @nth_lookup: Nth lookup 137 | * @returns: A newly assigned string. 138 | * 139 | * A newly assigned string with @ntg_seg and @nth_lookup . 140 | */ 141 | gchar * anthy_gcontext_get_segment (AnthyGContext *obj, 142 | int nth_seg, 143 | int nth_lookup); 144 | 145 | /** 146 | * anthy_gcontext_commit_segment: 147 | * @nth_seg: Nth segment 148 | * @nth_lookup: Nth lookup 149 | * 150 | * Commit a string with @ntg_seg and @nth_lookup. 151 | */ 152 | int anthy_gcontext_commit_segment (AnthyGContext *obj, 153 | int nth_seg, 154 | int nth_lookup); 155 | 156 | /** 157 | * anthy_gcontext_get_nr_candidates: 158 | * @returns: The number of the candidates 159 | * 160 | * The number of the candidates 161 | */ 162 | int anthy_gcontext_get_nr_candidates (AnthyGContext *obj, 163 | int nth_seg); 164 | 165 | /** 166 | * anthy_gcontext_set_prediction_string: 167 | * @string: A prediction string 168 | * 169 | * Set a prediction string. 170 | */ 171 | int anthy_gcontext_set_prediction_string 172 | (AnthyGContext *obj, 173 | const gchar * string); 174 | 175 | /** 176 | * anthy_gcontext_get_nr_predictions: 177 | * @returns: The number of the converted segments in the current 178 | * prediction string. 179 | * 180 | * The number of the converted segments in the current prediction string. 181 | */ 182 | int anthy_gcontext_get_nr_predictions 183 | (AnthyGContext *obj); 184 | 185 | /** 186 | * anthy_gcontext_get_prediction: 187 | * @nth_seg: Nth segment 188 | * @returns: A newly assigned string. 189 | * 190 | * A newly assigned string with @ntg_seg . 191 | */ 192 | gchar * anthy_gcontext_get_prediction (AnthyGContext *obj, 193 | int nth_seg); 194 | 195 | /** 196 | * anthy_gcontext_commit_prediction: 197 | * @nth_seg: Nth segment 198 | * 199 | * Commit a prediction string with @ntg_seg . 200 | */ 201 | int anthy_gcontext_commit_prediction (AnthyGContext *obj, 202 | int nth_seg); 203 | 204 | /** 205 | * anthy_gcontext_set_logger: 206 | * @level: Log level 207 | * 208 | * Set Anthy log level. 209 | */ 210 | void anthy_gcontext_set_logger (int level); 211 | G_END_DECLS 212 | #endif 213 | -------------------------------------------------------------------------------- /engine/python3/main.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2025 Takao Fujiwara 8 | # Copyright (c) 2007-2016 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import os 25 | from os import path 26 | import sys 27 | import getopt 28 | import locale 29 | import xml.dom.minidom 30 | 31 | from gi import require_version as gi_require_version 32 | gi_require_version('GLib', '2.0') 33 | gi_require_version('IBus', '1.0') 34 | 35 | from gi.repository import GLib 36 | 37 | # set_prgname before importing factory to show the name in warning 38 | # messages when import modules are failed. E.g. Gtk. 39 | GLib.set_prgname('ibus-engine-anthy') 40 | 41 | from gi.repository import IBus 42 | 43 | import _config as config 44 | 45 | # Need to call IBus.init() before IBus.EngineSimple() is loaded. 46 | # factory -> engine -> IBus.EngineSimple 47 | IBus.init() 48 | import factory 49 | 50 | class IMApp: 51 | def __init__(self, exec_by_ibus): 52 | command_line = config.LIBEXECDIR + '/ibus-engine-anthy --ibus' 53 | self.__component = IBus.Component(name='org.freedesktop.IBus.Anthy', 54 | description='Anthy Component', 55 | version='0.1.0', 56 | license='GPL', 57 | author='Peng Huang ', 58 | homepage='https://github.com/ibus/ibus/wiki', 59 | command_line=command_line, 60 | textdomain='ibus-anthy') 61 | engine = IBus.EngineDesc(name='anthy', 62 | longname='Anthy', 63 | description='Anthy Input Method', 64 | language='ja', 65 | license='GPL', 66 | author='Peng Huang ', 67 | icon='ibus-anthy', 68 | layout=config.LAYOUT, 69 | symbol=config.SYMBOL_CHAR, 70 | rank=99) 71 | self.__component.add_engine(engine) 72 | self.__mainloop = GLib.MainLoop() 73 | self.__bus = IBus.Bus() 74 | self.__bus.connect('disconnected', self.__bus_disconnected_cb) 75 | self.__factory = factory.EngineFactory(self.__bus) 76 | if exec_by_ibus: 77 | self.__bus.request_name('org.freedesktop.IBus.Anthy', 0) 78 | else: 79 | self.__bus.register_component(self.__component) 80 | 81 | def run(self): 82 | self.__mainloop.run() 83 | 84 | def __bus_disconnected_cb(self, bus): 85 | self.__mainloop.quit() 86 | 87 | 88 | def launch_engine(exec_by_ibus): 89 | IMApp(exec_by_ibus).run() 90 | 91 | def get_userhome(): 92 | if 'HOME' not in os.environ: 93 | import pwd 94 | userhome = pwd.getpwuid(os.getuid()).pw_dir 95 | else: 96 | userhome = os.environ['HOME'] 97 | userhome = userhome.rstrip('/') 98 | return userhome 99 | 100 | def resync_engine_file(): 101 | user_config = path.join(get_userhome(), '.config', 102 | 'ibus-anthy', 'engines.xml') 103 | system_config = path.join(config.PKGDATADIR, 'engine', 'default.xml') 104 | if not path.exists(user_config): 105 | return 106 | if not path.exists(system_config): 107 | os.unlink(user_config) 108 | return 109 | 110 | # path.getmtime depends on the build time rather than install time. 111 | def __get_engine_file_version(engine_file): 112 | version_str = '' 113 | dom = xml.dom.minidom.parse(engine_file) 114 | elements = dom.getElementsByTagName('version') 115 | nodes = [] 116 | if len(elements) > 0: 117 | nodes = elements[0].childNodes 118 | if len(nodes) > 0: 119 | version_str = nodes[0].data 120 | if version_str != '': 121 | version_str = version_str.strip() 122 | return version_str 123 | 124 | user_config_version = __get_engine_file_version(user_config) 125 | system_config_version = __get_engine_file_version(system_config) 126 | if system_config_version > user_config_version: 127 | import shutil 128 | shutil.copyfile(system_config, user_config) 129 | 130 | def print_xml(): 131 | user_config = os.path.join(get_userhome(), '.config', 132 | 'ibus-anthy', 'engines.xml') 133 | system_config = os.path.join(config.PKGDATADIR, 'engine', 'default.xml') 134 | xml = None 135 | for f in [user_config, system_config]: 136 | if os.path.exists(f): 137 | xml = f 138 | break 139 | if xml == None: 140 | print('Not exist: %s' % system_config, file=sys.stderr) 141 | return 142 | file = open(xml, 'r') 143 | print(file.read()) 144 | file.close() 145 | 146 | def print_help(out, v = 0): 147 | print('-i, --ibus executed by ibus.', file=out) 148 | print('-h, --help show this message.', file=out) 149 | print('-d, --daemonize daemonize ibus.', file=out) 150 | print('-x, --xml print engine xml.', file=out) 151 | sys.exit(v) 152 | 153 | def main(): 154 | try: 155 | locale.setlocale(locale.LC_ALL, '') 156 | except: 157 | pass 158 | 159 | exec_by_ibus = False 160 | daemonize = False 161 | xml = False 162 | 163 | shortopt = 'ihdx' 164 | longopt = ['ibus', 'help', 'daemonize', 'xml'] 165 | 166 | try: 167 | opts, args = getopt.getopt(sys.argv[1:], shortopt, longopt) 168 | except getopt.GetoptError as err: 169 | print_help(sys.stderr, 1) 170 | 171 | for o, a in opts: 172 | if o in ('-h', '--help'): 173 | print_help(sys.stdout) 174 | elif o in ('-d', '--daemonize'): 175 | daemonize = True 176 | elif o in ('-i', '--ibus'): 177 | exec_by_ibus = True 178 | elif o in ('-x', '--xml'): 179 | xml = True 180 | else: 181 | print('Unknown argument: %s' % o, file=sys.stderr) 182 | print_help(sys.stderr, 1) 183 | 184 | if daemonize: 185 | if os.fork(): 186 | sys.exit() 187 | 188 | if xml: 189 | resync_engine_file() 190 | print_xml() 191 | return 192 | 193 | launch_engine(exec_by_ibus) 194 | 195 | if __name__ == '__main__': 196 | main() 197 | -------------------------------------------------------------------------------- /engine/python2/main.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2025 Takao Fujiwara 8 | # Copyright (c) 2007-2016 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import os 25 | from os import path 26 | import sys 27 | import getopt 28 | import locale 29 | import xml.dom.minidom 30 | 31 | from gi import require_version as gi_require_version 32 | gi_require_version('GLib', '2.0') 33 | gi_require_version('IBus', '1.0') 34 | 35 | from gi.repository import GLib 36 | 37 | # set_prgname before importing factory to show the name in warning 38 | # messages when import modules are failed. E.g. Gtk. 39 | GLib.set_prgname('ibus-engine-anthy') 40 | 41 | from gi.repository import IBus 42 | 43 | import _config as config 44 | 45 | # Need to call IBus.init() before IBus.EngineSimple() is loaded. 46 | # factory -> engine -> IBus.EngineSimple 47 | IBus.init() 48 | import factory 49 | 50 | class IMApp: 51 | def __init__(self, exec_by_ibus): 52 | command_line = config.LIBEXECDIR + '/ibus-engine-anthy --ibus' 53 | self.__component = IBus.Component(name='org.freedesktop.IBus.Anthy', 54 | description='Anthy Component', 55 | version='0.1.0', 56 | license='GPL', 57 | author='Peng Huang ', 58 | homepage='https://github.com/ibus/ibus/wiki', 59 | command_line=command_line, 60 | textdomain='ibus-anthy') 61 | engine = IBus.EngineDesc(name='anthy', 62 | longname='Anthy', 63 | description='Anthy Input Method', 64 | language='ja', 65 | license='GPL', 66 | author='Peng Huang ', 67 | icon='ibus-anthy', 68 | layout=config.LAYOUT, 69 | symbol=config.SYMBOL_CHAR, 70 | rank=99) 71 | self.__component.add_engine(engine) 72 | self.__mainloop = GLib.MainLoop() 73 | self.__bus = IBus.Bus() 74 | self.__bus.connect('disconnected', self.__bus_disconnected_cb) 75 | self.__factory = factory.EngineFactory(self.__bus) 76 | if exec_by_ibus: 77 | self.__bus.request_name('org.freedesktop.IBus.Anthy', 0) 78 | else: 79 | self.__bus.register_component(self.__component) 80 | 81 | def run(self): 82 | self.__mainloop.run() 83 | 84 | def __bus_disconnected_cb(self, bus): 85 | self.__mainloop.quit() 86 | 87 | 88 | def launch_engine(exec_by_ibus): 89 | IMApp(exec_by_ibus).run() 90 | 91 | def get_userhome(): 92 | if 'HOME' not in os.environ: 93 | import pwd 94 | userhome = pwd.getpwuid(os.getuid()).pw_dir 95 | else: 96 | userhome = os.environ['HOME'] 97 | userhome = userhome.rstrip('/') 98 | return userhome 99 | 100 | def resync_engine_file(): 101 | user_config = path.join(get_userhome(), '.config', 102 | 'ibus-anthy', 'engines.xml') 103 | system_config = path.join(config.PKGDATADIR, 'engine', 'default.xml') 104 | if not path.exists(user_config): 105 | return 106 | if not path.exists(system_config): 107 | os.unlink(user_config) 108 | return 109 | 110 | # path.getmtime depends on the build time rather than install time. 111 | def __get_engine_file_version(engine_file): 112 | version_str = '' 113 | dom = xml.dom.minidom.parse(engine_file) 114 | elements = dom.getElementsByTagName('version') 115 | nodes = [] 116 | if len(elements) > 0: 117 | nodes = elements[0].childNodes 118 | if len(nodes) > 0: 119 | version_str = nodes[0].data 120 | if type(version_str) == unicode: 121 | version_str = str(version_str) 122 | if version_str != '': 123 | version_str = version_str.strip() 124 | return version_str 125 | 126 | user_config_version = __get_engine_file_version(user_config) 127 | system_config_version = __get_engine_file_version(system_config) 128 | if system_config_version > user_config_version: 129 | import shutil 130 | shutil.copyfile(system_config, user_config) 131 | 132 | def print_xml(): 133 | user_config = os.path.join(get_userhome(), '.config', 134 | 'ibus-anthy', 'engines.xml') 135 | system_config = os.path.join(config.PKGDATADIR, 'engine', 'default.xml') 136 | xml = None 137 | for f in [user_config, system_config]: 138 | if os.path.exists(f): 139 | xml = f 140 | break 141 | if xml == None: 142 | print >> sys.stderr, 'Not exist: %s' % system_config 143 | return 144 | file = open(xml, 'r') 145 | print file.read() 146 | file.close() 147 | 148 | def print_help(out, v = 0): 149 | print >> out, '-i, --ibus executed by ibus.' 150 | print >> out, '-h, --help show this message.' 151 | print >> out, '-d, --daemonize daemonize ibus.' 152 | print >> out, '-x, --xml print engine xml.' 153 | sys.exit(v) 154 | 155 | def main(): 156 | try: 157 | locale.setlocale(locale.LC_ALL, '') 158 | except: 159 | pass 160 | 161 | exec_by_ibus = False 162 | daemonize = False 163 | xml = False 164 | 165 | shortopt = 'ihdx' 166 | longopt = ['ibus', 'help', 'daemonize', 'xml'] 167 | 168 | try: 169 | opts, args = getopt.getopt(sys.argv[1:], shortopt, longopt) 170 | except getopt.GetoptError, err: 171 | print_help(sys.stderr, 1) 172 | 173 | for o, a in opts: 174 | if o in ('-h', '--help'): 175 | print_help(sys.stdout) 176 | elif o in ('-d', '--daemonize'): 177 | daemonize = True 178 | elif o in ('-i', '--ibus'): 179 | exec_by_ibus = True 180 | elif o in ('-x', '--xml'): 181 | xml = True 182 | else: 183 | print >> sys.stderr, 'Unknown argument: %s' % o 184 | print_help(sys.stderr, 1) 185 | 186 | if daemonize: 187 | if os.fork(): 188 | sys.exit() 189 | 190 | if xml: 191 | resync_engine_file() 192 | print_xml() 193 | return 194 | 195 | launch_engine(exec_by_ibus) 196 | 197 | if __name__ == '__main__': 198 | main() 199 | -------------------------------------------------------------------------------- /gir/anthygcontext.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 2 | /* vim:set et sts=4: */ 3 | /* ibus-anthy - The Anthy engine for IBus 4 | * Copyright (c) 2012-2021 Takao Fujiwara 5 | * Copyright (c) 2012 Peng Huang 6 | * Copyright (c) 2012-2013 Red Hat, Inc. 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 of the License, or 11 | * (at your option) 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 along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | extern void anthy_init_personality (void); 27 | extern int anthy_do_set_personality (const char *id); 28 | 29 | #include "anthygcontext.h" 30 | 31 | #define ANTHY_GCONTEXT_GET_PRIVATE(o) \ 32 | ((AnthyGContextPrivate *)anthy_gcontext_get_instance_private (o)) 33 | 34 | struct _AnthyGContextPrivate { 35 | anthy_context_t context; 36 | }; 37 | 38 | static GObject *anthy_gcontext_constructor (GType type, 39 | guint n, 40 | GObjectConstructParam *args); 41 | static void anthy_gcontext_dispose (GObject *gobject); 42 | static void anthy_gcontext_finalize (GObject *gobject); 43 | 44 | G_DEFINE_TYPE_WITH_PRIVATE (AnthyGContext, 45 | anthy_gcontext, 46 | G_TYPE_INITIALLY_UNOWNED) 47 | 48 | static void 49 | anthy_gcontext_class_init (AnthyGContextClass *class) 50 | { 51 | GObjectClass *gobject_class = G_OBJECT_CLASS (class); 52 | gobject_class->constructor = anthy_gcontext_constructor; 53 | gobject_class->dispose = anthy_gcontext_dispose; 54 | gobject_class->finalize = anthy_gcontext_finalize; 55 | } 56 | 57 | static void 58 | anthy_gcontext_init (AnthyGContext *obj) 59 | { 60 | obj->priv = ANTHY_GCONTEXT_GET_PRIVATE (obj); 61 | 62 | anthy_init (); 63 | obj->priv->context = anthy_create_context (); 64 | } 65 | 66 | static GObject * 67 | anthy_gcontext_constructor (GType type, 68 | guint n, 69 | GObjectConstructParam *args) 70 | { 71 | GObject *object; 72 | 73 | object = G_OBJECT_CLASS (anthy_gcontext_parent_class)->constructor (type, n ,args); 74 | return object; 75 | } 76 | 77 | static void 78 | anthy_gcontext_dispose (GObject *gobject) 79 | { 80 | G_OBJECT_CLASS (anthy_gcontext_parent_class)->dispose (gobject); 81 | } 82 | 83 | static void 84 | anthy_gcontext_finalize (GObject *gobject) 85 | { 86 | G_OBJECT_CLASS (anthy_gcontext_parent_class)->finalize (gobject); 87 | } 88 | 89 | AnthyGContext * 90 | anthy_gcontext_new (void) 91 | { 92 | GObject *gobject = g_object_new (ANTHY_TYPE_GCONTEXT, NULL); 93 | return ANTHY_GCONTEXT (gobject); 94 | } 95 | 96 | #define ANTHY_OBJECT_FUNCTION_ASSERTIONS() \ 97 | { \ 98 | g_assert (obj != NULL); \ 99 | g_assert (obj->priv != NULL); \ 100 | g_assert (obj->priv->context != NULL); \ 101 | } 102 | 103 | int 104 | anthy_gcontext_set_encoding (AnthyGContext *obj, int encoding) 105 | { 106 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 107 | 108 | return anthy_context_set_encoding (obj->priv->context, encoding); 109 | } 110 | 111 | void 112 | anthy_gcontext_init_personality (AnthyGContext *obj) 113 | { 114 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 115 | 116 | anthy_init_personality (); 117 | } 118 | 119 | int 120 | anthy_gcontext_do_set_personality (AnthyGContext *obj, const gchar *dict_name) 121 | { 122 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 123 | 124 | return anthy_do_set_personality (dict_name); 125 | } 126 | 127 | void 128 | anthy_gcontext_resize_segment (AnthyGContext *obj, 129 | int nth, 130 | int resize) 131 | { 132 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 133 | 134 | anthy_resize_segment (obj->priv->context, nth, resize); 135 | } 136 | 137 | int 138 | anthy_gcontext_set_string (AnthyGContext *obj, const gchar * string) 139 | { 140 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 141 | 142 | return anthy_set_string (obj->priv->context, string); 143 | } 144 | 145 | int 146 | anthy_gcontext_get_nr_segments (AnthyGContext *obj) 147 | { 148 | struct anthy_conv_stat conv_stat = { 0, }; 149 | 150 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 151 | 152 | anthy_get_stat(obj->priv->context, &conv_stat); 153 | return conv_stat.nr_segment; 154 | } 155 | 156 | gchar * 157 | anthy_gcontext_get_segment (AnthyGContext *obj, int nth_seg, int nth_lookup) 158 | { 159 | int length; 160 | static char temp[512]; 161 | 162 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 163 | 164 | length = anthy_get_segment (obj->priv->context, nth_seg, nth_lookup, 165 | temp, sizeof (temp)); 166 | if (length >= 0) { 167 | return g_strdup (temp); 168 | } else { 169 | return NULL; 170 | } 171 | } 172 | 173 | int 174 | anthy_gcontext_commit_segment(AnthyGContext *obj, int nth_seg, int nth_lookup) 175 | { 176 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 177 | 178 | return anthy_commit_segment (obj->priv->context, nth_seg, nth_lookup); 179 | } 180 | 181 | int 182 | anthy_gcontext_get_nr_candidates (AnthyGContext *obj, int nth_seg) 183 | { 184 | struct anthy_segment_stat seg_stat = { 0, }; 185 | 186 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 187 | 188 | anthy_get_segment_stat (obj->priv->context, nth_seg, &seg_stat); 189 | return seg_stat.nr_candidate; 190 | } 191 | 192 | int 193 | anthy_gcontext_set_prediction_string (AnthyGContext *obj, const gchar * string) 194 | { 195 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 196 | 197 | return anthy_set_prediction_string (obj->priv->context, string); 198 | } 199 | 200 | int 201 | anthy_gcontext_get_nr_predictions (AnthyGContext *obj) 202 | { 203 | struct anthy_prediction_stat seg_stat = { 0, }; 204 | 205 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 206 | 207 | anthy_get_prediction_stat (obj->priv->context, &seg_stat); 208 | return seg_stat.nr_prediction; 209 | } 210 | 211 | gchar * 212 | anthy_gcontext_get_prediction (AnthyGContext *obj, int nth_seg) 213 | { 214 | int length; 215 | static char temp[512]; 216 | 217 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 218 | 219 | length = anthy_get_prediction (obj->priv->context, nth_seg, 220 | temp, sizeof (temp)); 221 | if (length >= 0) { 222 | return g_strdup (temp); 223 | } else { 224 | return NULL; 225 | } 226 | } 227 | 228 | int 229 | anthy_gcontext_commit_prediction (AnthyGContext *obj, int nth_seg) 230 | { 231 | ANTHY_OBJECT_FUNCTION_ASSERTIONS (); 232 | 233 | return anthy_commit_prediction (obj->priv->context, nth_seg); 234 | } 235 | 236 | void 237 | anthy_gcontext_set_logger (int level) 238 | { 239 | anthy_set_logger (NULL, level); 240 | } 241 | 242 | #undef ANTHY_OBJECT_FUNCTION_ASSERTIONS 243 | -------------------------------------------------------------------------------- /icons/ibus-anthy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 22 | 24 | image/svg+xml 25 | 27 | 28 | 29 | 30 | 31 | 33 | 53 | 146 | 147 | -------------------------------------------------------------------------------- /engine/python3/romaji.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2017 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import sys 25 | 26 | from tables import * 27 | import segment 28 | 29 | def romaji_correction_rule_get(k, d): 30 | return ('ん', k[1:2]) if k[0:1] == 'n' and not k[1:2] in "aiueony'" else d 31 | 32 | class RomajiSegment(segment.Segment): 33 | _prefs = None 34 | _romaji_typing_rule_method = None 35 | _latin_with_shift = True 36 | _shift_mode = False 37 | 38 | def __init__(self, enchars='', jachars='', shift=False, unshift=False): 39 | if self._latin_with_shift: 40 | # If Shift key is pressed, Latin mode. 41 | # If Hiragana_Katakana key is pressed, Hiragana mode. 42 | if shift: 43 | self._shift_mode = True 44 | if unshift: 45 | self._shift_mode = False 46 | 47 | enchars_orig = enchars 48 | # Even if the chars are capital with CapsLock, Hiragana 49 | # should be converted. E.g. 'SA' 50 | enchars = enchars.lower() 51 | 52 | if not jachars and not shift: 53 | jachars = self.__get_romaji_typing_rule(enchars, None) 54 | if jachars == None: 55 | jachars = symbol_rule.get(enchars, '') 56 | super(RomajiSegment, self).__init__(enchars_orig, jachars) 57 | 58 | @classmethod 59 | def INIT_ROMAJI_TYPING_RULE(cls, prefs): 60 | cls._prefs = prefs 61 | if prefs == None: 62 | cls._romaji_typing_rule_method = None 63 | return 64 | method = prefs.get_value('romaji-typing-rule', 'method') 65 | if method == None: 66 | method = 'default' 67 | cls._romaji_typing_rule_method = method 68 | keymap = prefs.get_value('romaji-typing-rule', 'list') 69 | if cls._romaji_typing_rule_method not in keymap.keys(): 70 | cls._romaji_typing_rule_method = None 71 | 72 | @classmethod 73 | def SET_LATIN_WITH_SHIFT(cls, latin_with_shift): 74 | # Do not use IBus.Config in every conversion for the performance. 75 | cls._latin_with_shift = latin_with_shift 76 | 77 | def __get_romaji_typing_rule(self, enchars, retval=None): 78 | prefs = self._prefs 79 | value = None 80 | method = self._romaji_typing_rule_method 81 | if method != None: 82 | # Need to send Unicode to typing_to_config_key instead of UTF-8 83 | # not to separate U+A5 84 | gkey = prefs.typing_to_config_key(enchars) 85 | if gkey == '': 86 | return None 87 | keymap = prefs.get_value('romaji-typing-rule', 'list')[method] 88 | value = keymap.get(gkey) 89 | if value == '': 90 | value = None 91 | if value == None: 92 | value = retval 93 | else: 94 | value = romaji_typing_rule_static.get(enchars, retval) 95 | return value 96 | 97 | def is_finished(self): 98 | return self._jachars != '' 99 | 100 | def append(self, enchar, shift=False, unshift=False): 101 | if self.is_finished(): 102 | if enchar == '' and enchar == '\0': 103 | return [] 104 | return [RomajiSegment(enchar)] 105 | 106 | text_orig = self._enchars + enchar 107 | text = text_orig.lower() 108 | 109 | if self._latin_with_shift: 110 | # If Shift key is pressed, Latin mode. 111 | # If Hiragana_Katakana key is pressed, Hiragana mode. 112 | if shift: 113 | self._shift_mode = True 114 | if unshift: 115 | self._shift_mode = False 116 | if self._shift_mode: 117 | self._enchars = text_orig 118 | return [] 119 | 120 | if shift: 121 | self._enchars = text_orig 122 | return [] 123 | 124 | jachars = self.__get_romaji_typing_rule(text, None) 125 | if jachars == None: 126 | jachars = symbol_rule.get(text, None) 127 | if jachars: 128 | self._enchars = text_orig 129 | self._jachars = jachars 130 | return [] 131 | 132 | jachars, c = romaji_double_consonat_typing_rule.get(text, (None, None)) 133 | if jachars: 134 | self._enchars = text_orig[0] 135 | self._jachars = jachars 136 | return [RomajiSegment(c)] 137 | 138 | # jachars, c = romaji_correction_rule.get(text, (None, None)) 139 | jachars, c = romaji_correction_rule_get(text, (None, None)) 140 | if jachars: 141 | self._enchars = text_orig[0] 142 | self._jachars = jachars 143 | return [RomajiSegment(c)] 144 | 145 | for i in range(-min(4, len(text)), 0): 146 | enchars = text[i:] 147 | 148 | jachars = self.__get_romaji_typing_rule(enchars, None) 149 | if jachars == None: 150 | jachars = symbol_rule.get(enchars, None) 151 | if jachars: 152 | jasegment = RomajiSegment(enchars, jachars) 153 | self._enchars = text_orig[:i] 154 | return [jasegment] 155 | 156 | jachars, c = romaji_double_consonat_typing_rule.get(enchars, (None, None)) 157 | if jachars: 158 | jasegment = RomajiSegment(enchars[:-len(c)], jachars) 159 | self._enchars = text_orig[:i] 160 | if c: 161 | return [jasegment, RomajiSegment(c)] 162 | return [jasegment] 163 | 164 | # jachars, c = romaji_correction_rule.get(enchars, (None, None)) 165 | jachars, c = romaji_correction_rule_get(enchars, (None, None)) 166 | if jachars: 167 | jasegment = RomajiSegment(enchars[:-len(c)], jachars) 168 | self._enchars = text_orig[:i] 169 | if c: 170 | return [jasegment, RomajiSegment(c)] 171 | return [jasegment] 172 | 173 | self._enchars = text_orig 174 | return [] 175 | 176 | def prepend(self, enchar, shift=False, unshift=False): 177 | if enchar == '' or enchar == '\0': 178 | return [] 179 | 180 | if self.is_finished(): 181 | return [RomajiSegment(enchar)] 182 | 183 | text_orig = enchar + self._enchars 184 | text = text_orig.lower() 185 | 186 | if self._latin_with_shift: 187 | if shift: 188 | self._shift_mode = True 189 | if unshift: 190 | self._shift_mode = False 191 | if self._shift_mode: 192 | self._enchars = text_orig 193 | return [] 194 | 195 | if shift: 196 | self._enchars = text_orig 197 | return [] 198 | 199 | jachars = self.__get_romaji_typing_rule(text, None) 200 | if jachars == None: 201 | jachars = symbol_rule.get(text, None) 202 | if jachars: 203 | self._enchars = text_orig 204 | self._jachars = jachars 205 | return [] 206 | 207 | jachars, c = romaji_double_consonat_typing_rule.get(text, (None, None)) 208 | if jachars: 209 | self._enchars = c 210 | return [RomajiSegment(text_orig[0], jachars)] 211 | 212 | # jachars, c = romaji_correction_rule.get(text, (None, None)) 213 | jachars, c = romaji_correction_rule_get(text, (None, None)) 214 | if jachars: 215 | self._enchars = c 216 | return [RomajiSegment(text_orig[0], jachars)] 217 | 218 | for i in range(min(4, len(text)), 0, -1): 219 | enchars = text[:i] 220 | 221 | jachars = self.__get_romaji_typing_rule(enchars, None) 222 | if jachars == None: 223 | jachars = symbol_rule.get(enchars, None) 224 | if jachars: 225 | jasegment = RomajiSegment(enchars, jachars) 226 | self._enchars = text_orig[i:] 227 | return [jasegment] 228 | 229 | jachars, c = romaji_double_consonat_typing_rule.get(enchars, (None, None)) 230 | if jachars: 231 | self._enchars = c + text_orig[i:] 232 | return [RomajiSegment(enchars[:-len(c)], jachars)] 233 | 234 | # jachars, c = romaji_correction_rule.get(enchars, (None, None)) 235 | jachars, c = romaji_correction_rule_get(enchars, (None, None)) 236 | if jachars: 237 | self._enchars = c + text_orig[i:] 238 | return [RomajiSegment(enchars[:-len(c)], jachars)] 239 | 240 | self._enchars = text_orig 241 | return [] 242 | 243 | def pop(self, index=-1): 244 | if index == -1: 245 | index = len(self._enchars) - 1 246 | if index < 0 or index >= len(self._enchars): 247 | raise IndexError('Out of bound') 248 | if self.is_finished(): 249 | self._enchars = '' 250 | self._jachars = '' 251 | else: 252 | enchars = list(self._enchars) 253 | del enchars[index] 254 | self._enchars = ''.join(enchars) 255 | jachars = self.__get_romaji_typing_rule(self._enchars, None) 256 | if jachars == None: 257 | jachars = symbol_rule.get(self._enchars, '') 258 | self._jachars = jachars 259 | 260 | 261 | -------------------------------------------------------------------------------- /engine/python2/romaji.py: -------------------------------------------------------------------------------- 1 | # vim:set et sts=4 sw=4: 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2010-2017 Takao Fujiwara 8 | # Copyright (c) 2007-2017 Red Hat, Inc. 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License along 21 | # with this program; if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | import sys 25 | 26 | from tables import * 27 | import segment 28 | 29 | def romaji_correction_rule_get(k, d): 30 | return (u'ん', k[1:2]) if k[0:1] == u'n' and not k[1:2] in u"aiueony'" else d 31 | 32 | class RomajiSegment(segment.Segment): 33 | _prefs = None 34 | _romaji_typing_rule_method = None 35 | _latin_with_shift = True 36 | _shift_mode = False 37 | 38 | def __init__(self, enchars=u'', jachars=u'', shift=False, unshift=False): 39 | if self._latin_with_shift: 40 | # If Shift key is pressed, Latin mode. 41 | # If Hiragana_Katakana key is pressed, Hiragana mode. 42 | if shift: 43 | self._shift_mode = True 44 | if unshift: 45 | self._shift_mode = False 46 | 47 | enchars_orig = enchars 48 | # Even if the chars are capital with CapsLock, Hiragana 49 | # should be converted. E.g. 'SA' 50 | enchars = enchars.lower() 51 | 52 | if not jachars and not shift: 53 | jachars = self.__get_romaji_typing_rule(enchars, None) 54 | if jachars == None: 55 | jachars = symbol_rule.get(enchars, u'') 56 | super(RomajiSegment, self).__init__(enchars_orig, jachars) 57 | 58 | @classmethod 59 | def INIT_ROMAJI_TYPING_RULE(cls, prefs): 60 | cls._prefs = prefs 61 | if prefs == None: 62 | cls._romaji_typing_rule_method = None 63 | return 64 | method = prefs.get_value('romaji-typing-rule', 'method') 65 | if method == None: 66 | method = 'default' 67 | cls._romaji_typing_rule_method = method 68 | keymap = prefs.get_value('romaji-typing-rule', 'list') 69 | if cls._romaji_typing_rule_method not in keymap.keys(): 70 | cls._romaji_typing_rule_method = None 71 | 72 | @classmethod 73 | def SET_LATIN_WITH_SHIFT(cls, latin_with_shift): 74 | # Do not use IBus.Config in every conversion for the performance. 75 | cls._latin_with_shift = latin_with_shift 76 | 77 | def __get_romaji_typing_rule(self, enchars, retval=None): 78 | prefs = self._prefs 79 | value = None 80 | method = self._romaji_typing_rule_method 81 | if method != None: 82 | # Need to send Unicode to typing_to_config_key instead of UTF-8 83 | # not to separate U+A5 84 | gkey = prefs.typing_to_config_key(enchars) 85 | if gkey == '': 86 | return None 87 | keymap = prefs.get_value('romaji-typing-rule', 'list')[method] 88 | value = prefs.unicode(keymap.get(gkey)) 89 | if value == '': 90 | value = None 91 | if value == None: 92 | value = retval 93 | else: 94 | value = romaji_typing_rule_static.get(enchars, retval) 95 | return value 96 | 97 | def is_finished(self): 98 | return self._jachars != u'' 99 | 100 | def append(self, enchar, shift=False, unshift=False): 101 | if self.is_finished(): 102 | if enchar == u'' and enchar == u'\0': 103 | return [] 104 | return [RomajiSegment(enchar)] 105 | 106 | text_orig = self._enchars + enchar 107 | text = text_orig.lower() 108 | 109 | if self._latin_with_shift: 110 | # If Shift key is pressed, Latin mode. 111 | # If Hiragana_Katakana key is pressed, Hiragana mode. 112 | if shift: 113 | self._shift_mode = True 114 | if unshift: 115 | self._shift_mode = False 116 | if self._shift_mode: 117 | self._enchars = text_orig 118 | return [] 119 | 120 | if shift: 121 | self._enchars = text_orig 122 | return [] 123 | 124 | jachars = self.__get_romaji_typing_rule(text, None) 125 | if jachars == None: 126 | jachars = symbol_rule.get(text, None) 127 | if jachars: 128 | self._enchars = text_orig 129 | self._jachars = jachars 130 | return [] 131 | 132 | jachars, c = romaji_double_consonat_typing_rule.get(text, (None, None)) 133 | if jachars: 134 | self._enchars = text_orig[0] 135 | self._jachars = jachars 136 | return [RomajiSegment(c)] 137 | 138 | # jachars, c = romaji_correction_rule.get(text, (None, None)) 139 | jachars, c = romaji_correction_rule_get(text, (None, None)) 140 | if jachars: 141 | self._enchars = text_orig[0] 142 | self._jachars = jachars 143 | return [RomajiSegment(c)] 144 | 145 | for i in range(-min(4, len(text)), 0): 146 | enchars = text[i:] 147 | 148 | jachars = self.__get_romaji_typing_rule(enchars, None) 149 | if jachars == None: 150 | jachars = symbol_rule.get(enchars, None) 151 | if jachars: 152 | jasegment = RomajiSegment(enchars, jachars) 153 | self._enchars = text_orig[:i] 154 | return [jasegment] 155 | 156 | jachars, c = romaji_double_consonat_typing_rule.get(enchars, (None, None)) 157 | if jachars: 158 | jasegment = RomajiSegment(enchars[:-len(c)], jachars) 159 | self._enchars = text_orig[:i] 160 | if c: 161 | return [jasegment, RomajiSegment(c)] 162 | return [jasegment] 163 | 164 | # jachars, c = romaji_correction_rule.get(enchars, (None, None)) 165 | jachars, c = romaji_correction_rule_get(enchars, (None, None)) 166 | if jachars: 167 | jasegment = RomajiSegment(enchars[:-len(c)], jachars) 168 | self._enchars = text_orig[:i] 169 | if c: 170 | return [jasegment, RomajiSegment(c)] 171 | return [jasegment] 172 | 173 | self._enchars = text_orig 174 | return [] 175 | 176 | def prepend(self, enchar, shift=False, unshift=False): 177 | if enchar == u'' or enchar == u'\0': 178 | return [] 179 | 180 | if self.is_finished(): 181 | return [RomajiSegment(enchar)] 182 | 183 | text_orig = enchar + self._enchars 184 | text = text_orig.lower() 185 | 186 | if self._latin_with_shift: 187 | if shift: 188 | self._shift_mode = True 189 | if unshift: 190 | self._shift_mode = False 191 | if self._shift_mode: 192 | self._enchars = text_orig 193 | return [] 194 | 195 | if shift: 196 | self._enchars = text_orig 197 | return [] 198 | 199 | jachars = self.__get_romaji_typing_rule(text, None) 200 | if jachars == None: 201 | jachars = symbol_rule.get(text, None) 202 | if jachars: 203 | self._enchars = text_orig 204 | self._jachars = jachars 205 | return [] 206 | 207 | jachars, c = romaji_double_consonat_typing_rule.get(text, (None, None)) 208 | if jachars: 209 | self._enchars = c 210 | return [RomajiSegment(text_orig[0], jachars)] 211 | 212 | # jachars, c = romaji_correction_rule.get(text, (None, None)) 213 | jachars, c = romaji_correction_rule_get(text, (None, None)) 214 | if jachars: 215 | self._enchars = c 216 | return [RomajiSegment(text_orig[0], jachars)] 217 | 218 | for i in range(min(4, len(text)), 0, -1): 219 | enchars = text[:i] 220 | 221 | jachars = self.__get_romaji_typing_rule(enchars, None) 222 | if jachars == None: 223 | jachars = symbol_rule.get(enchars, None) 224 | if jachars: 225 | jasegment = RomajiSegment(enchars, jachars) 226 | self._enchars = text_orig[i:] 227 | return [jasegment] 228 | 229 | jachars, c = romaji_double_consonat_typing_rule.get(enchars, (None, None)) 230 | if jachars: 231 | self._enchars = c + text_orig[i:] 232 | return [RomajiSegment(enchars[:-len(c)], jachars)] 233 | 234 | # jachars, c = romaji_correction_rule.get(enchars, (None, None)) 235 | jachars, c = romaji_correction_rule_get(enchars, (None, None)) 236 | if jachars: 237 | self._enchars = c + text_orig[i:] 238 | return [RomajiSegment(enchars[:-len(c)], jachars)] 239 | 240 | self._enchars = text_orig 241 | return [] 242 | 243 | def pop(self, index=-1): 244 | if index == -1: 245 | index = len(self._enchars) - 1 246 | if index < 0 or index >= len(self._enchars): 247 | raise IndexError('Out of bound') 248 | if self.is_finished(): 249 | self._enchars = u'' 250 | self._jachars = u'' 251 | else: 252 | enchars = list(self._enchars) 253 | del enchars[index] 254 | self._enchars = u''.join(enchars) 255 | jachars = self.__get_romaji_typing_rule(self._enchars, None) 256 | if jachars == None: 257 | jachars = symbol_rule.get(self._enchars, u'') 258 | self._jachars = jachars 259 | 260 | 261 | -------------------------------------------------------------------------------- /setup/python3/anthyprefs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim:set noet ts=4: 3 | # 4 | # ibus-anthy - The Anthy engine for IBus 5 | # 6 | # Copyright (c) 2007-2008 Peng Huang 7 | # Copyright (c) 2009 Hideaki ABE 8 | # Copyright (c) 2010-2017 Takao Fujiwara 9 | # Copyright (c) 2007-2017 Red Hat, Inc. 10 | # 11 | # This program is free software; you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation; either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License along 22 | # with this program; if not, write to the Free Software Foundation, Inc., 23 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | 25 | import sys 26 | 27 | import _config as config 28 | from prefs import Prefs 29 | 30 | N_ = lambda a : a 31 | 32 | __all__ = ['AnthyPrefs'] 33 | 34 | 35 | class AnthyPrefs(Prefs): 36 | _char_to_config_key = None 37 | 38 | def __init__(self): 39 | super(AnthyPrefs, self).__init__() 40 | 41 | def get_japanese_ordered_list(self): 42 | return _japanese_ordered_list 43 | 44 | def get_version(self): 45 | return config.VERSION 46 | 47 | # Convert gsettings key to typing sequences 48 | # E.g. 'largea-bracketleft' to 'A[' 49 | def typing_from_config_key(self, gkeys): 50 | retval = '' 51 | for key in gkeys.split('-'): 52 | if key in _supported_gsettings_key_chars: 53 | retval += key 54 | continue 55 | try: 56 | ch = _config_key_to_char[key] 57 | except KeyError: 58 | print('Not supported key in gsettings', gkeys, file=sys.stderr) 59 | retval = '' 60 | break 61 | retval += ch 62 | return retval 63 | 64 | # Convert typing sequences to gsettings key. 65 | # E.g. 'A[' to 'largea-bracketleft' 66 | def typing_to_config_key(self, typing): 67 | retval = '' 68 | if self._char_to_config_key == None: 69 | self._char_to_config_key = {} 70 | for _key, _ch in list(_config_key_to_char.items()): 71 | self._char_to_config_key[_ch] = _key 72 | for ch in typing: 73 | if ch in _supported_gsettings_key_chars: 74 | if retval != '': 75 | retval += '-' 76 | retval += ch 77 | continue 78 | try: 79 | key = self._char_to_config_key[ch] 80 | except KeyError: 81 | print('Not supported key in gsettings', typing, file=sys.stderr) 82 | retval = '' 83 | break 84 | if retval != '': 85 | retval += '-' 86 | retval += key 87 | return retval 88 | 89 | def get_value(self, section, key): 90 | not_sorted = super(AnthyPrefs, self).get_value(section, key) 91 | if section == 'shortcut' and type(not_sorted) == dict: 92 | retval = dict.fromkeys(_cmd_keys, []) 93 | retval.update(not_sorted) 94 | return retval 95 | return not_sorted 96 | 97 | 98 | # Sad! dict.keys() doesn't return the saved order. 99 | # locale.strcoll() also just returns the Unicode code point. 100 | # Unicode order is wrong in Japanese large 'a' and small 'a'. 101 | # The workaround is to save the order here... 102 | _japanese_ordered_list = [ 103 | 'あ', 'い', 'う', 'え', 'お', 104 | 'ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', 105 | 'いぇ', 106 | 'うぁ', 'うぃ', 'うぅ', 'うぇ', 'うぉ', 107 | 'うゃ', 'うゅ', 'うょ', 108 | 'か', 'き', 'く', 'け', 'こ', 109 | 'ゕ', 'ゖ', 'ヵ', 'ヶ', 110 | 'が', 'ぎ', 'ぐ', 'げ', 'ご', 111 | 'きゃ', 'きぃ', 'きゅ', 'きぇ', 'きょ', 112 | 'くぁ', 'くぃ', 'くぅ', 'くぇ', 'くぉ', 113 | 'ぎゃ', 'ぎぃ', 'ぎゅ', 'ぎぇ', 'ぎょ', 114 | 'ぐぁ', 'ぐぃ', 'ぐぅ', 'ぐぇ', 'ぐぉ', 115 | 'さ', 'し', 'す', 'せ', 'そ', 116 | 'ざ', 'じ', 'ず', 'ぜ', 'ぞ', 117 | 'しゃ', 'しぃ', 'しゅ', 'しぇ', 'しょ', 118 | 'じゃ', 'じぃ', 'じゅ', 'じぇ', 'じょ', 119 | 'すぅぃ', 'すぇ', 120 | 'ずぇ', 121 | 'た', 'ち', 'つ', 'て', 'と', 122 | 'だ', 'ぢ', 'づ', 'で', 'ど', 123 | 'っ', 124 | 'ちゃ', 'ちぃ', 'ちゅ', 'ちぇ', 'ちょ', 125 | 'ぢぃ', 'ぢぇ', 126 | 'ぢゃ', 'ぢゅ', 'ぢょ', 127 | 'つぁ', 'つぃ', 'つぇ', 'つぉ', 128 | 'つゃ', 'つぃぇ', 'つゅ', 'つょ', 129 | 'づぁ', 'づぃ', 'づぇ', 'づぉ', 130 | 'づゃ', 'づぃぇ', 'づゅ', 'づょ', 131 | 'てぃ', 'てぇ', 132 | 'てゃ', 'てゅ', 'てょ', 133 | 'とぅ', 134 | 'でぃ', 'でぇ', 135 | 'でゃ', 'でゅ', 'でょ', 136 | 'どぅ', 137 | 'な', 'に', 'ぬ', 'ね', 'の', 138 | 'にぃ', 'にぇ', 139 | 'にゃ', 'にゅ', 'にょ', 140 | 'は', 'ひ', 'ふ', 'へ', 'ほ', 141 | 'ば', 'び', 'ぶ', 'べ', 'ぼ', 142 | 'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ', 143 | 'ひぃ', 'ひぇ', 144 | 'ひゃ', 'ひゅ', 'ひょ', 145 | 'びぃ', 'びぇ', 146 | 'びゃ', 'びゅ', 'びょ', 147 | 'ぴぃ', 'ぴぇ', 148 | 'ぴゃ', 'ぴゅ', 'ぴょ', 149 | 'ふぁ', 'ふぃ', 'ふぇ', 'ふぉ', 150 | 'ふゃ', 'ふゅ', 'ふょ', 151 | 'ぶぁ', 'ぶぇ', 'ぶぉ', 152 | 'ぷぁ', 'ぷぇ', 'ぷぉ', 153 | 'ま', 'み', 'む', 'め', 'も', 154 | 'みぃ', 'みぇ', 155 | 'みゃ', 'みゅ', 'みょ', 156 | 'や', 'ゆ', 'よ', 157 | 'ゃ', 'ゅ', 'ょ', 158 | 'ら', 'り', 'る', 'れ', 'ろ', 159 | 'りぃ', 'りぇ', 160 | 'りゃ', 'りゅ', 'りょ', 161 | 'わ', 'を', 'ん', 162 | 'ゎ', 163 | 'ゐ', 'ゑ', 164 | 'ー', 165 | 'ヴぁ', 'ヴぃ', 'ヴ', 'ヴぇ', 'ヴぉ', 166 | 'ヴゃ', 'ヴぃぇ', 'ヴゅ', 'ヴょ', 167 | ] 168 | 169 | # http://git.gnome.org/browse/glib/tree/gio/glib-compile-schemas.c#n765 170 | # gsettings supports keys named by "abcdefghijklmnopqrstuvwxyz0123456789-" 171 | # and ibus-anthy uses '-' as the delimiter. 172 | _supported_gsettings_key_chars = "abcdefghijklmnopqrstuvwxyz0123456789" 173 | 174 | _config_key_to_char = { 175 | # no modifiers keys 176 | 'minus' : '-', 177 | 'asciicircum' : '^', 178 | 'at' : '@', 179 | 'bracketleft' : '[', 180 | 'semicolon' : ';', 181 | 'colon' : ':', 182 | 'bracketright' : ']', 183 | 'comma' : ',', 184 | 'period' : '.', 185 | 'slash' : '/', 186 | 'backslash' : '\\', 187 | 188 | # shift modifiered keys 189 | 'exclam' : '!', 190 | 'quotedbl' : '"', 191 | 'numbersign' : '#', 192 | 'dollar' : '$', 193 | 'percent' : '%', 194 | 'ampersand' : '&', 195 | 'apostrophe' : '\'', 196 | 'parenleft' : '(', 197 | 'parenright' : ')', 198 | 'asciitilde' : '~', 199 | 'equal' : '=', 200 | 'bar' : '|', 201 | 202 | 'largeq' : 'Q', 203 | 'largew' : 'W', 204 | 'largee' : 'E', 205 | 'larger' : 'R', 206 | 'larget' : 'T', 207 | 'largey' : 'Y', 208 | 'largeu' : 'U', 209 | 'largei' : 'I', 210 | 'largeo' : 'O', 211 | 'largep' : 'P', 212 | 'grave' : '`', 213 | 214 | 'braceleft' : '{', 215 | 216 | 'largea' : 'A', 217 | 'larges' : 'S', 218 | 'larged' : 'D', 219 | 'largef' : 'F', 220 | 'largeg' : 'G', 221 | 'largeh' : 'H', 222 | 'largej' : 'J', 223 | 'largek' : 'K', 224 | 'largel' : 'L', 225 | 'plus' : '+', 226 | 'asterisk' : '*', 227 | 228 | 'braceright' : '}', 229 | 230 | 'largez' : 'Z', 231 | 'largex' : 'X', 232 | 'largec' : 'C', 233 | 'largev' : 'V', 234 | 'largeb' : 'B', 235 | 'largen' : 'N', 236 | 'largem' : 'M', 237 | 'less' : '<', 238 | 'greater' : '>', 239 | 240 | 'question' : '?', 241 | 'underscore' : '_', 242 | 243 | 'yen' : '¥', 244 | } 245 | 246 | _cmd_keys = [ 247 | 'on_off', 248 | 'circle_input_mode', 249 | 'circle_kana_mode', 250 | 'circle_typing_method', 251 | 'circle_dict_method', 252 | 'latin_mode', 253 | 'wide_latin_mode', 254 | 'hiragana_mode', 255 | 'katakana_mode', 256 | 'half_katakana_mode', 257 | # 'cancel_pseudo_ascii_mode_key', 258 | 259 | 'hiragana_for_latin_with_shift', 260 | 261 | 'insert_space', 262 | 'insert_alternate_space', 263 | 'insert_half_space', 264 | 'insert_wide_space', 265 | 'backspace', 266 | 'delete', 267 | 'commit', 268 | 'convert', 269 | 'predict', 270 | 'cancel', 271 | 'cancel_all', 272 | 'escape_to_latin', 273 | 'reconvert', 274 | # 'do_nothing', 275 | 276 | 'select_first_candidate', 277 | 'select_last_candidate', 278 | 'select_next_candidate', 279 | 'select_prev_candidate', 280 | 'candidates_page_up', 281 | 'candidates_page_down', 282 | 283 | 'move_caret_first', 284 | 'move_caret_last', 285 | 'move_caret_forward', 286 | 'move_caret_backward', 287 | 288 | 'select_first_segment', 289 | 'select_last_segment', 290 | 'select_next_segment', 291 | 'select_prev_segment', 292 | 'shrink_segment', 293 | 'expand_segment', 294 | 'commit_first_segment', 295 | 'commit_selected_segment', 296 | 297 | 'select_candidates_1', 298 | 'select_candidates_2', 299 | 'select_candidates_3', 300 | 'select_candidates_4', 301 | 'select_candidates_5', 302 | 'select_candidates_6', 303 | 'select_candidates_7', 304 | 'select_candidates_8', 305 | 'select_candidates_9', 306 | 'select_candidates_0', 307 | 308 | 'convert_to_char_type_forward', 309 | 'convert_to_char_type_backward', 310 | 'convert_to_hiragana', 311 | 'convert_to_katakana', 312 | 'convert_to_half', 313 | 'convert_to_half_katakana', 314 | 'convert_to_wide_latin', 315 | 'convert_to_latin', 316 | 'convert_to_hiragana_all', 317 | 'convert_to_katakana_all', 318 | 'convert_to_half_all', 319 | 'convert_to_half_katakana_all', 320 | 'convert_to_wide_latin_all', 321 | 'convert_to_latin_all', 322 | 323 | 'dict_admin', 324 | 'add_word', 325 | 326 | 'start_setup', 327 | ] 328 | 329 | _dummy_translatable_strings = [ 330 | N_('General'), 331 | N_('Zip Code Conversion'), 332 | N_('Symbol'), 333 | N_('Old Character Style'), 334 | N_('Era'), 335 | N_('Emoji'), 336 | ] 337 | --------------------------------------------------------------------------------