From a360dbe761107cd98530c24f2c115dd5c7613dca Mon Sep 17 00:00:00 2001 From: BYVoid Date: Thu, 13 May 2010 11:18:30 +0800 Subject: add Bopomofo Support --- src/PinyinEngine.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/PinyinEngine.cc') diff --git a/src/PinyinEngine.cc b/src/PinyinEngine.cc index aa9f247..d279e66 100644 --- a/src/PinyinEngine.cc +++ b/src/PinyinEngine.cc @@ -7,8 +7,10 @@ #include "ExtEditor.h" #include "FullPinyinEditor.h" #include "DoublePinyinEditor.h" +#include "BopomofoEditor.h" #include "PinyinEngine.h" #include "HalfFullConverter.h" +#include "SimpTradConverter.h" #include "Config.h" #include "Text.h" #include "Util.h" @@ -27,7 +29,8 @@ PinyinEngine::PinyinEngine (IBusEngine *engine) gint i; /* create editors */ if (Config::doublePinyin ()) - m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + //m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + m_editors[MODE_INIT].reset (new BopomofoEditor (m_props)); else m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); @@ -128,8 +131,10 @@ PinyinEngine::focusIn (void) { /* reset pinyin editor */ if (Config::doublePinyin ()) { - if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { - m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + //if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { + // m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { + m_editors[MODE_INIT].reset (new BopomofoEditor (m_props)); connectEditorSignals (m_editors[MODE_INIT]); } } -- cgit From 44eb3a3beaaf8a9ee66a633783b3e6dd03a9e1f1 Mon Sep 17 00:00:00 2001 From: BYVoid Date: Thu, 13 May 2010 17:41:57 +0800 Subject: Bopomofo --- src/PinyinEngine.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src/PinyinEngine.cc') diff --git a/src/PinyinEngine.cc b/src/PinyinEngine.cc index d279e66..ec84bb5 100644 --- a/src/PinyinEngine.cc +++ b/src/PinyinEngine.cc @@ -10,7 +10,6 @@ #include "BopomofoEditor.h" #include "PinyinEngine.h" #include "HalfFullConverter.h" -#include "SimpTradConverter.h" #include "Config.h" #include "Text.h" #include "Util.h" -- cgit From c18e74986fb1e608e313497d3b3914ab22a4854b Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Thu, 13 May 2010 19:15:39 +0800 Subject: Make bopomofo as a separate input engine. --- src/PinyinEngine.cc | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src/PinyinEngine.cc') diff --git a/src/PinyinEngine.cc b/src/PinyinEngine.cc index ec84bb5..0b5ed3f 100644 --- a/src/PinyinEngine.cc +++ b/src/PinyinEngine.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include "RawEditor.h" #include "ExtEditor.h" @@ -23,15 +24,25 @@ PinyinEngine::PinyinEngine (IBusEngine *engine) : m_engine (engine), m_prev_pressed_key (IBUS_VoidSymbol), m_input_mode (MODE_INIT), + m_bopomofo (FALSE), m_fallback_editor (new FallbackEditor (m_props)) { gint i; + + /* Is it bopomofo engine */ + m_bopomofo = std::strcmp (ibus_engine_get_name (engine), "bopomofo") == 0 || + std::strcmp (ibus_engine_get_name (engine), "bopomofo-debug") == 0; + /* create editors */ - if (Config::doublePinyin ()) - //m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + if (!m_bopomofo) { + if (Config::doublePinyin ()) + m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + else + m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); + } + else { m_editors[MODE_INIT].reset (new BopomofoEditor (m_props)); - else - m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); + } m_editors[MODE_RAW].reset (new RawEditor (m_props)); m_editors[MODE_EXTENSION].reset (new ExtEditor (m_props)); @@ -129,21 +140,21 @@ void PinyinEngine::focusIn (void) { /* reset pinyin editor */ - if (Config::doublePinyin ()) { - //if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { - // m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); - if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { - m_editors[MODE_INIT].reset (new BopomofoEditor (m_props)); - connectEditorSignals (m_editors[MODE_INIT]); + if (!m_bopomofo) { + if (Config::doublePinyin ()) { + if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { + m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + connectEditorSignals (m_editors[MODE_INIT]); + } } - } - else { - if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { - m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); - connectEditorSignals (m_editors[MODE_INIT]); + else { + if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { + m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); + connectEditorSignals (m_editors[MODE_INIT]); + } } + ibus_engine_register_properties (m_engine, m_props.properties ()); } - ibus_engine_register_properties (m_engine, m_props.properties ()); } -- cgit From 35e5f6a5e90dde1b3683774247a4d9bb304bcc3c Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Fri, 14 May 2010 10:44:01 +0800 Subject: Create BopomofoEngine --- src/PinyinEngine.cc | 68 +++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 41 deletions(-) (limited to 'src/PinyinEngine.cc') diff --git a/src/PinyinEngine.cc b/src/PinyinEngine.cc index 0b5ed3f..c64e297 100644 --- a/src/PinyinEngine.cc +++ b/src/PinyinEngine.cc @@ -21,28 +21,17 @@ namespace PY { /* constructor */ PinyinEngine::PinyinEngine (IBusEngine *engine) - : m_engine (engine), + : Engine (engine), m_prev_pressed_key (IBUS_VoidSymbol), m_input_mode (MODE_INIT), - m_bopomofo (FALSE), m_fallback_editor (new FallbackEditor (m_props)) { gint i; - /* Is it bopomofo engine */ - m_bopomofo = std::strcmp (ibus_engine_get_name (engine), "bopomofo") == 0 || - std::strcmp (ibus_engine_get_name (engine), "bopomofo-debug") == 0; - - /* create editors */ - if (!m_bopomofo) { - if (Config::doublePinyin ()) - m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); - else - m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); - } - else { - m_editors[MODE_INIT].reset (new BopomofoEditor (m_props)); - } + if (Config::doublePinyin ()) + m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + else + m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); m_editors[MODE_RAW].reset (new RawEditor (m_props)); m_editors[MODE_EXTENSION].reset (new ExtEditor (m_props)); @@ -139,22 +128,19 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers) void PinyinEngine::focusIn (void) { - /* reset pinyin editor */ - if (!m_bopomofo) { - if (Config::doublePinyin ()) { - if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { - m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); - connectEditorSignals (m_editors[MODE_INIT]); - } + if (Config::doublePinyin ()) { + if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { + m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props)); + connectEditorSignals (m_editors[MODE_INIT]); } - else { - if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { - m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); - connectEditorSignals (m_editors[MODE_INIT]); - } + } + else { + if (dynamic_cast (m_editors[MODE_INIT].get ()) == NULL) { + m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props)); + connectEditorSignals (m_editors[MODE_INIT]); } - ibus_engine_register_properties (m_engine, m_props.properties ()); } + registerProperties (m_props.properties ()); } @@ -211,7 +197,7 @@ PinyinEngine::candidateClicked (guint index, guint button, guint state) void PinyinEngine::slotCommitText (Text & text) { - ibus_engine_commit_text (m_engine, text); + commitText (text); if (m_input_mode != MODE_INIT) m_input_mode = MODE_INIT; if (text.text ()) @@ -223,67 +209,67 @@ PinyinEngine::slotCommitText (Text & text) void PinyinEngine::slotUpdatePreeditText (Text & text, guint cursor, gboolean visible) { - ibus_engine_update_preedit_text (m_engine, text, cursor, visible); + updatePreeditText (text, cursor, visible); } void PinyinEngine::slotShowPreeditText (void) { - ibus_engine_show_preedit_text (m_engine); + showPreeditText (); } void PinyinEngine::slotHidePreeditText (void) { - ibus_engine_hide_preedit_text (m_engine); + hidePreeditText (); } void PinyinEngine::slotUpdateAuxiliaryText (Text & text, gboolean visible) { - ibus_engine_update_auxiliary_text (m_engine, text, visible); + updateAuxiliaryText (text, visible); } void PinyinEngine::slotShowAuxiliaryText (void) { - ibus_engine_show_auxiliary_text (m_engine); + showAuxiliaryText (); } void PinyinEngine::slotHideAuxiliaryText (void) { - ibus_engine_hide_auxiliary_text (m_engine); + hideAuxiliaryText (); } void PinyinEngine::slotUpdateLookupTable (LookupTable & table, gboolean visible) { - ibus_engine_update_lookup_table (m_engine, table, visible); + updateLookupTable (table, visible); } void PinyinEngine::slotUpdateLookupTableFast (LookupTable & table, gboolean visible) { - ibus_engine_update_lookup_table_fast (m_engine, table, visible); + updateLookupTableFast (table, visible); } void PinyinEngine::slotShowLookupTable (void) { - ibus_engine_show_lookup_table (m_engine); + showLookupTable (); } void PinyinEngine::slotHideLookupTable (void) { - ibus_engine_hide_lookup_table (m_engine); + hideLookupTable (); } void PinyinEngine::slotUpdateProperty (Property & prop) { - ibus_engine_update_property (m_engine, prop); + updateProperty (prop); } void -- cgit