diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2008-09-03 08:38:08 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-09-03 08:38:08 +0800 |
commit | 6a036dbf0d3f3147828d9591a0f902f1e4355522 (patch) | |
tree | 875529396cc15dde8d2ac4aad00f3bd122e1291d /engine | |
parent | 8cdb785f56f3957dd0a12493a6dea88435dc4faa (diff) | |
download | ibus-anthy-6a036dbf0d3f3147828d9591a0f902f1e4355522.tar.gz |
Fix soem typos.
Diffstat (limited to 'engine')
-rw-r--r-- | engine/engine.py | 24 | ||||
-rw-r--r-- | engine/tables.py | 3 |
2 files changed, 16 insertions, 11 deletions
diff --git a/engine/engine.py b/engine/engine.py index db6f195..5c93f17 100644 --- a/engine/engine.py +++ b/engine/engine.py @@ -305,7 +305,7 @@ class Engine(ibus.EngineBase): return self.__convert_mode = CONV_MODE_ANTHY - self.__preedit_ja_string.insert(u"") + self.__preedit_ja_string.insert(u"\0") text, cursor = self.__preedit_ja_string.get_hiragana() @@ -682,6 +682,8 @@ class JaString: def insert(self, c): segment_before = None segment_after = None + new_segments = None + if self.__cursor >= 1: segment_before = self.__segments[self.__cursor - 1] if self.__cursor < len(self.__segments): @@ -691,7 +693,8 @@ class JaString: elif segment_after and not segment_after.is_finished(): new_segments = segment_after.prepend(c) else: - new_segments = [JaSegment(c)] + if c != u"\0" and c != u"": + new_segments = [JaSegment(c)] if new_segments: self.__segments[self.__cursor:self.__cursor] = new_segments self.__cursor += len(new_segments) @@ -787,12 +790,9 @@ class JaSegment: return self.__jachars != u"" def append(self, enchar): - if enchar == u"": - if not self.is_finished() and self.__enchars == u"n": - self.__jachars = u"ん" - return [] - if self.is_finished(): + if enchar == u"" and enchar == u"\0": + return [] return [JaSegment(enchar)] text = self.__enchars + enchar @@ -822,13 +822,17 @@ class JaSegment: if jachars: jasegment = JaSegment(enchars[:-len(c)], jachars) self.__enchars = text[:i] - return [jasegment, JaSegment(c)] + if c: + return [jasegment, JaSegment(c)] + return [jasegment] jachars, c = romaji_correction_rule.get(enchars, (None, None)) if jachars: jasegment = JaSegment(enchars[:-len(c)], jachars) self.__enchars = text[:i] - return [jasegment, JaSegment(c)] + if c: + return [jasegment, JaSegment(c)] + return [jasegment] @@ -836,7 +840,7 @@ class JaSegment: return [] def prepend(self, enchar): - if enchar == u"": + if enchar == u"" or enchar == u"\0": return [] if self.is_finished(): diff --git a/engine/tables.py b/engine/tables.py index 9694ae0..54d4785 100644 --- a/engine/tables.py +++ b/engine/tables.py @@ -284,7 +284,7 @@ romaji_double_consonat_typing_rule = { } # this is only used with romaji_typing_rule -romaji_oorrection_rule = { +romaji_correction_rule = { u"nb" : (u"ん", u"b"), u"nc" : (u"ん", u"c"), u"nd" : (u"ん", u"d"), @@ -303,6 +303,7 @@ romaji_oorrection_rule = { u"nw" : (u"ん", u"w"), u"nx" : (u"ん", u"x"), u"nz" : (u"ん", u"z"), + u"n\0" : (u"ん", u""), } # a port of 101kana.sty from scim-anthy |