diff options
author | Peng Wu <alexepico@gmail.com> | 2010-05-17 16:08:09 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-05-19 10:09:33 +0800 |
commit | 9702be36351fbf1cd7a7be2a6bd27415880c3b9a (patch) | |
tree | babd916831a556258d798e5afac3ffc82833dd5a /src | |
parent | 717ec8f7335511d33a2a0f054bb1eb141c945a79 (diff) | |
download | ibus-pinyin-9702be36351fbf1cd7a7be2a6bd27415880c3b9a.tar.gz |
add update auxiliary and fill candidates label according to m_mode.
Diffstat (limited to 'src')
-rw-r--r-- | src/ExtEditor.cc | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/ExtEditor.cc b/src/ExtEditor.cc index 8e39fae..fcf55d7 100644 --- a/src/ExtEditor.cc +++ b/src/ExtEditor.cc @@ -134,9 +134,12 @@ ExtEditor::updateStateFromInput() return false; } + m_auxiliary_text = "i"; + m_mode = LABEL_LIST_COMMANDS; if ( 1 == m_text.length() ){ fillCommandCandidates(); + updateAuxiliaryText(); return true; } /* Check m_text len, and update auxiliary string meanwhile. @@ -151,16 +154,24 @@ ExtEditor::updateStateFromInput() m_mode = LABEL_LIST_COMMANDS; if ( m_text.length() == 2){ fillCommandCandidates(m_text.substr(1,1).c_str()); + + m_auxiliary_text += " "; + m_auxiliary_text += m_text.substr(1, 1); + updateAuxiliaryText(); return true; - } else if ( m_text.length() == 3) { + } else if ( m_text.length() >= 3) { std::string command_name = m_text.substr(1,2); + m_auxiliary_text += " "; + m_auxiliary_text += m_text.substr(1,2); + const lua_command_t * command = ibus_engine_plugin_lookup_command(m_lua_plugin, command_name.c_str()); if ( NULL == command) { m_mode = LABEL_NONE; clearLookupTable(); m_lookup_table.clear(); sendLookupTable(); + updateAuxiliaryText(); return false; } @@ -173,7 +184,17 @@ ExtEditor::updateStateFromInput() else m_mode = LABEL_LIST_NONE; - //fillCommandCandidates(...).(list or single value.) + const char * argment = NULL; + std::string arg = ""; + if (m_text.length() > 3) { + arg = m_text.substr(3); + argment = arg.c_str(); + m_auxiliary_text += ""; + m_auxiliary_text += argment; + } + + fillCommand(command_name, argment); + updateAuxiliaryText(); } } else if ( isdigit(m_text[1]) ){ @@ -223,8 +244,30 @@ ExtEditor::fillCommand(std::string command_name, const char * argument){ if ( 1 == result_num ) m_mode = LABEL_LIST_SINGLE; - + clearLookupTable(); + + //Generate labels according to m_mode + if ( LABEL_LIST_DIGIT == m_mode ) { + //skip codes, as this is the default behavior of lookup table. +#if 0 + for ( int i = 1; i <= 9; ++i) { + m_lookup_table.appendLabel( Text(i + '0') ); + } + m_lookup_table.appendLabel( Text ('0') ); +#endif + } + + if ( LABEL_LIST_ALPHA == m_mode) { + for ( int i = 1; i <= 10; ++i ) + m_lookup_table.appendLabel( Text(i - 1 + 'a') ); + } + if ( LABEL_LIST_NONE == m_mode || LABEL_LIST_SINGLE == m_mode) { + for ( int i = 1; i <= 10; ++i) + m_lookup_table.appendLabel(Text("")); + } + + sendLookupTable(); return true; } |