diff options
author | fujiwarat <takao.fujiwara1@gmail.com> | 2011-05-13 10:33:20 +0900 |
---|---|---|
committer | fujiwarat <takao.fujiwara1@gmail.com> | 2011-05-13 10:33:20 +0900 |
commit | a86df1b6d8fc0552c82fd3e63f003566444e0014 (patch) | |
tree | 0e28e7d5f666730fd62387b2adee5c40d779f3c9 | |
parent | 35f0898601caf39bc5a5c71765f734f5b749a3e1 (diff) | |
download | ibus-anthy-a86df1b6d8fc0552c82fd3e63f003566444e0014.tar.gz |
Added an old character dict.
-rw-r--r-- | data/Makefile.am | 2 | ||||
-rw-r--r-- | data/oldchar.t | 30 | ||||
-rw-r--r-- | engine/engine.py | 16 | ||||
-rw-r--r-- | engine/tables.py | 7 | ||||
-rw-r--r-- | setup/anthyprefs.py.in | 13 | ||||
-rw-r--r-- | setup/main.py | 4 |
6 files changed, 70 insertions, 2 deletions
diff --git a/data/Makefile.am b/data/Makefile.am index fcd3375..25f4f23 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -20,11 +20,13 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dicts_DATA = \ + oldchar.t \ symbol.t \ $(NULL) dictsdir = $(pkgdatadir)/dicts EXTRA_DIST = \ + oldchar.t \ symbol.t \ $(NULL) diff --git a/data/oldchar.t b/data/oldchar.t new file mode 100644 index 0000000..25bbf70 --- /dev/null +++ b/data/oldchar.t @@ -0,0 +1,30 @@ +# vim:set noet ts=4: +# +# ibus-anthy - The Anthy engine for IBus +# +# Copyright (c) 2010-2011 Takao Fujiwara <takao.fujiwara1@gmail.com> +# Copyright (c) 2010-2011 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# This file was imported from im-dict-ja +# im-dict-ja - Japanese word dictionary set for input method +# http://github.com/fujiwarat/im-dict-ja +# +# Typing 'va' can convert 'ヷ' with this dictionary. +う゛ぁ #T35*500 ヷ +う゛ぃ #T35*500 ヸ +う゛ぇ #T35*500 ヹ +う゛ぉ #T35*500 ヺ diff --git a/engine/engine.py b/engine/engine.py index c32b261..ae78d0f 100644 --- a/engine/engine.py +++ b/engine/engine.py @@ -721,7 +721,8 @@ class Engine(ibus.EngineBase): files = self.__prefs.get_value('dict', 'files') if id == 'embedded': pass - elif id == 'anthy_zipcode' or id == 'ibus_symbol': + elif id == 'anthy_zipcode' or id == 'ibus_symbol' or \ + id == 'ibus_oldchar': file = self.__prefs.get_value('dict', id)[0] else: found = False @@ -792,6 +793,15 @@ class Engine(ibus.EngineBase): else: break + def __normalize_preedit(self, preedit): + if not self.__is_utf8: + return preedit + for key in romaji_normalize_rule.keys(): + if preedit.find(key) >= 0: + for value in romaji_normalize_rule[key]: + preedit = preedit.replace(key, value) + return preedit + # begine convert def __begin_anthy_convert(self): if self.__segment_mode & SEGMENT_IMMEDIATE: @@ -803,6 +813,7 @@ class Engine(ibus.EngineBase): # text, cursor = self.__preedit_ja_string.get_hiragana() text, cursor = self.__preedit_ja_string.get_hiragana(True) + text = self.__normalize_preedit(text) self.__context.set_string(text.encode("utf8")) if self.__segment_mode & SEGMENT_SINGLE: self.__join_all_segments() @@ -835,6 +846,7 @@ class Engine(ibus.EngineBase): def __end_convert(self): self.__end_anthy_convert() + # test case 'verudhi' can show U+3046 + U+309B and U+3094 def __candidate_cb(self, candidate): if not self.__is_utf8: return @@ -1442,6 +1454,8 @@ class Engine(ibus.EngineBase): id = 'anthy_zipcode' elif file in cls.__prefs.get_value('dict', 'ibus_symbol'): id = 'ibus_symbol' + elif file in cls.__prefs.get_value('dict', 'ibus_oldchar'): + id = 'ibus_oldchar' else: id = cls._get_quoted_id(file) return id diff --git a/engine/tables.py b/engine/tables.py index af99be1..e312d72 100644 --- a/engine/tables.py +++ b/engine/tables.py @@ -359,7 +359,12 @@ romaji_correction_rule = { # EUC-JP and SJIS do not have the chars romaji_utf8_rule = { - u"ヴ" : (u"ゔ"), + u"う゛" : [u"ゔ"], +} + +# Hiragana normalization is needed for the personal dict. +romaji_normalize_rule = { + u"ヴ" : [u"う゛"], } # a port of 101kana.sty from scim-anthy diff --git a/setup/anthyprefs.py.in b/setup/anthyprefs.py.in index e0910b5..fe238a5 100644 --- a/setup/anthyprefs.py.in +++ b/setup/anthyprefs.py.in @@ -817,9 +817,11 @@ _config = { 'dict': { 'anthy_zipcode': ['@ANTHY_ZIPCODE_FILE@'], 'ibus_symbol': ['@pkgdatadir@/dicts/symbol.t'], + 'ibus_oldchar': ['@pkgdatadir@/dicts/oldchar.t'], 'files': [ '@ANTHY_ZIPCODE_FILE@', '@pkgdatadir@/dicts/symbol.t', + '@pkgdatadir@/dicts/oldchar.t', ], }, @@ -868,6 +870,17 @@ _config = { 'reverse': False, 'is_system': True, }, + + 'dict/file/ibus_oldchar': { + 'embed': False, + 'single': True, + 'icon': None, + 'short_label': '旧', + 'long_label': N_("Old Character Style"), + 'preview_lines': -1, + 'reverse': False, + 'is_system': True, + }, } _shortcut_default = { diff --git a/setup/main.py b/setup/main.py index fb7ff88..8d5cfe5 100644 --- a/setup/main.py +++ b/setup/main.py @@ -528,6 +528,8 @@ class AnthySetup(object): return self.prefs.get_value('dict', 'anthy_zipcode')[0] elif selected_id == 'ibus_symbol': return self.prefs.get_value('dict', 'ibus_symbol')[0] + elif selected_id == 'ibus_oldchar': + return self.prefs.get_value('dict', 'ibus_oldchar')[0] for file in files: id = self.__get_quoted_id(file) if selected_id == id: @@ -573,6 +575,8 @@ class AnthySetup(object): id = 'anthy_zipcode' elif file in prefs.get_value('dict', 'ibus_symbol'): id = 'ibus_symbol' + elif file in prefs.get_value('dict', 'ibus_oldchar'): + id = 'ibus_oldchar' else: id = self.__get_quoted_id(file) section = 'dict/file/' + id |