From 9702be36351fbf1cd7a7be2a6bd27415880c3b9a Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 17 May 2010 16:08:09 +0800 Subject: [PATCH] add update auxiliary and fill candidates label according to m_mode. --- src/ExtEditor.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file 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; } -- 2.7.4