Index: src/IBusChewingEngine.gob |
diff --git a/src/IBusChewingEngine.gob b/src/IBusChewingEngine.gob |
index 850b8bc90c01cdbc441f56064a417cb320323510..2248debd730af8366fd256ab1d54020baff241d9 100644 |
--- a/src/IBusChewingEngine.gob |
+++ b/src/IBusChewingEngine.gob |
@@ -108,6 +108,7 @@ enum ENGINE_STATUS{ |
FOCUS_IN= 0x4, |
SHOW_CANDIDATE= 0x8, |
NEED_COMMIT= 0x10, |
+ FORCE_COMMIT= 0x20, |
} Engine:Status; |
%h{ |
@@ -439,7 +440,7 @@ class IBus:Chewing:Engine from IBus:Engine{ |
private void update_lookup_table(self){ |
if (!self->table){ |
- self->table=ibus_lookup_table_new(1,0,FALSE,TRUE); |
+ self->table=ibus_lookup_table_new(1,0,TRUE,TRUE); |
g_object_ref_sink(self->table); |
} |
ibus_lookup_table_clear(self->table); |
@@ -520,7 +521,6 @@ class IBus:Chewing:Engine from IBus:Engine{ |
case CHEWING_INPUT_STYLE_IN_APPLICATION: |
if (chewing_aux_Length(self->context)>0){ |
gchar *aux_string=chewing_aux_String(self->context); |
- iText=ibus_text_new_from_string (aux_string); |
iText=g_object_ref_sink(ibus_text_new_from_string (aux_string)); |
ibus_engine_update_auxiliary_text(IBUS_ENGINE(self),iText,TRUE); |
g_object_unref (iText); |
@@ -555,6 +555,7 @@ class IBus:Chewing:Engine from IBus:Engine{ |
self_determine_input_mode(self); |
gint chiSymbolCursor; |
glong zhuyin_item_written; |
+ self_commit(self); |
gchar *preeditBuf=self_make_preedit_string(self, &zhuyin_item_written); |
IBusText *iText=self_decorate_preedit(self, preeditBuf, &chiSymbolCursor, zhuyin_item_written); |
if (g_object_is_floating(iText)){ |
@@ -577,7 +578,7 @@ class IBus:Chewing:Engine from IBus:Engine{ |
free(phoneSeq); |
} |
self_update_lookup_table(self); |
- self_commit(self); |
+ //self_commit(self); |
gboolean ret=TRUE; |
if (chewing_keystroke_CheckAbsorb(self->context)){ |
@@ -792,7 +793,7 @@ class IBus:Chewing:Engine from IBus:Engine{ |
protected gboolean commit(self){ |
gint commit=chewing_commit_Check(self->context); |
G_DEBUG_MSG(2,"[I2] commit() %s statusFlags=%x", (commit) ? "TRUE": "FALSE", self->_priv->statusFlags); |
- if (commit && (self->_priv->statusFlags & ENGINE_STATUS_NEED_COMMIT)){ |
+ if ((self->_priv->statusFlags & ENGINE_STATUS_NEED_COMMIT) && commit){ |
IBusText *iText=NULL; |
gchar *commit_string=chewing_commit_String(self->context); |
@@ -801,7 +802,19 @@ class IBus:Chewing:Engine from IBus:Engine{ |
ibus_engine_commit_text(IBUS_ENGINE(self),iText); |
g_free(commit_string); |
g_object_unref(iText); |
- ibus_chewing_engine_clear_status_flag(self, ENGINE_STATUS_NEED_COMMIT); |
+ if (!chewing_buffer_Check(self->context)){ |
+ /* Buffer is clean */ |
+ ibus_chewing_engine_clear_status_flag(self, ENGINE_STATUS_NEED_COMMIT | ENGINE_STATUS_FORCE_COMMIT ); |
+ }else if (self->_priv->statusFlags & ENGINE_STATUS_FORCE_COMMIT){ |
+ /* Flush the buffer */ |
+ chewing_handle_Enter(self->context); |
+ commit_string=chewing_commit_String(self->context); |
+ iText=g_object_ref_sink(ibus_text_new_from_string(commit_string)); |
+ ibus_engine_commit_text(IBUS_ENGINE(self),iText); |
+ g_free(commit_string); |
+ g_object_unref(iText); |
+ ibus_chewing_engine_clear_status_flag(self, ENGINE_STATUS_FORCE_COMMIT ); |
+ } |
} |
return commit; |
} |
@@ -820,7 +833,7 @@ class IBus:Chewing:Engine from IBus:Engine{ |
} |
chewing_handle_Enter(self->context); |
} |
- ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_NEED_COMMIT); |
+ ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_NEED_COMMIT | ENGINE_STATUS_FORCE_COMMIT); |
self_update(self); |
} |
} |
@@ -832,6 +845,10 @@ class IBus:Chewing:Engine from IBus:Engine{ |
reset(IBus:Engine *engine){ |
G_DEBUG_MSG(1,"[I1] reset"); |
Self *self=SELF(engine); |
+ if (self->_priv->statusFlags & ENGINE_STATUS_NEED_COMMIT){ |
+ /* Force commit non-empty preedit buffer */ |
+ self_force_commit(self); |
+ } |
ibus_lookup_table_clear(self->table); |
/* Save KBType type, becaue chewing_Reset() will reset it to default. |
*/ |