Commit string if use press common key in convert mode.
authorHuang Peng <shawn.p.huang@gmail.com>
Thu, 12 Jun 2008 07:11:12 +0000 (15:11 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Thu, 12 Jun 2008 07:11:12 +0000 (15:11 +0800)
engine/anthy/engine.py
ibus/gtk.py

index d60192c..f38cf1a 100644 (file)
@@ -134,7 +134,7 @@ class Engine (interface.IEngine):
        def _commit_string (self, text):
                self._reset ()
                self.CommitString (text)
-               self._update ()
+               self._invalidate ()
 
        def _update_input_chars (self):
                begin, end  = max (self._cursor_pos - 4, 0), self._cursor_pos
@@ -323,7 +323,10 @@ class Engine (interface.IEngine):
 
        def _on_key_common (self, keyval):
                if self._convert_begined:
-                       return True
+                       i = 0
+                       for seg_index, text in self._segments:
+                               self._context.commit_segment (i, seg_index)
+                       self._commit_string (self._convert_chars)
                self._input_chars += unichr (keyval)
                self._cursor_pos += 1
                self._invalidate ()
index 4d1cb0a..56a352f 100644 (file)
@@ -11,10 +11,13 @@ class PangoAttrList (pango.AttrList):
                for c in unistr:
                        offsets.append (offset)
                        offset += len (c.encode ("utf8"))
+               offsets.append (offset)
                for attr in attrs:
                        pango_attr = None
-                       start_index = offsets[attr._start_index]
-                       end_index = offsets[attr._end_index]
+                       start_index = attrs._start_index if attrs._start_index >= 0 else 0
+                       end_index = attrs._end_index if attrs._end_index >= 0 else 0
+                       start_index = offsets[_start_index] if attrstart_index < len (offsets) else offsets[-1]
+                       end_index = offsets[_end_index] if end_index < len (offsets) else offsets[-1]
                        if attr._type == ibus.ATTR_TYPE_FOREGROUND:
                                r = (attr._value & 0x00ff0000) >> 8
                                g = (attr._value & 0x0000ff00)