From c9d7cd3ce501e7134692c51b3ba42e2eb079b312 Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Sat, 24 Apr 2010 15:31:13 +0800 Subject: [PATCH] Fix half and full punch problem --- src/FallbackEditor.cc | 4 ++-- src/FallbackEditor.h | 11 ++++++----- src/PinyinEngine.cc | 4 ++++ src/Text.h | 4 ++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/FallbackEditor.cc b/src/FallbackEditor.cc index e530539..2ea7a79 100644 --- a/src/FallbackEditor.cc +++ b/src/FallbackEditor.cc @@ -89,7 +89,7 @@ FallbackEditor::processPunct (guint keyval, guint keycode, guint modifiers) case ',': commit (","); return TRUE; case '.': - if (m_prev_commited_char >= '0' && m_prev_commited_char <= '9') + if (m_prev_committed_char >= '0' && m_prev_committed_char <= '9') commit (keyval); else commit ("。"); @@ -183,7 +183,7 @@ void FallbackEditor::reset (void) { m_quote = TRUE; m_double_quote = TRUE; - m_prev_commited_char = 0; + m_prev_committed_char = 0; } diff --git a/src/FallbackEditor.h b/src/FallbackEditor.h index 799740f..de2a691 100644 --- a/src/FallbackEditor.h +++ b/src/FallbackEditor.h @@ -13,29 +13,30 @@ public: : Editor (props), m_quote (TRUE), m_double_quote (TRUE), - m_prev_commited_char (0) {} + m_prev_committed_char (0) {} gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); void reset (void); + void setPrevCommittedChar (gunichar ch) { + m_prev_committed_char = ch; + } + private: void commit (gchar ch) { gchar str[2] = {ch, 0}; StaticText text (str); commitText (text); - m_prev_commited_char = ch; } void commit (gunichar ch) { Text text (ch); commitText (text); - m_prev_commited_char = ch; } void commit (const gchar *str) { StaticText text (str); commitText (text); - m_prev_commited_char = 0; } void commit (const String &str) { @@ -47,7 +48,7 @@ private: private: gboolean m_quote; gboolean m_double_quote; - gunichar m_prev_commited_char; + gunichar m_prev_committed_char; }; diff --git a/src/PinyinEngine.cc b/src/PinyinEngine.cc index 149d935..1d39e2c 100644 --- a/src/PinyinEngine.cc +++ b/src/PinyinEngine.cc @@ -198,6 +198,10 @@ PinyinEngine::slotCommitText (Text & text) ibus_engine_commit_text (m_engine, text); if (m_input_mode != MODE_INIT) m_input_mode = MODE_INIT; + if (text.text ()) + static_cast (m_fallback_editor.get ())->setPrevCommittedChar (*text.text ()); + else + static_cast (m_fallback_editor.get ())->setPrevCommittedChar (0); } void diff --git a/src/Text.h b/src/Text.h index ae98814..b378918 100644 --- a/src/Text.h +++ b/src/Text.h @@ -24,6 +24,10 @@ public: ibus_text_append_attribute (get (), type, value, start, end); } + const gchar *text (void) const { + return get ()->text; + } + operator IBusText * (void) const { return get (); } -- 2.7.4