diff options
author | Peng Wu <alexepico@gmail.com> | 2010-05-06 16:24:28 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-05-19 10:09:33 +0800 |
commit | e2295b71251476650fb376a3d973c53e0c319bdc (patch) | |
tree | 4415b2aa64b15400ba71cda03f35728c19fa4a75 /src | |
parent | 5cf2d6572742d095af07c84182fb3ae4e96f7602 (diff) | |
download | ibus-pinyin-e2295b71251476650fb376a3d973c53e0c319bdc.tar.gz |
add fillCommandCandidates(string) implementation.
Diffstat (limited to 'src')
-rw-r--r-- | src/ExtEditor.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/ExtEditor.cc b/src/ExtEditor.cc index 3f0addf..f4a2d7d 100644 --- a/src/ExtEditor.cc +++ b/src/ExtEditor.cc @@ -88,9 +88,11 @@ ExtEditor::updateStateFromInput() bool ExtEditor::fillCommandCandidates() { + + /* try to replace this with fillCommandCandidates("") call. */ clearLookupTable(); - /* fill Candidates here. */ + /* fill candidates here. */ const GArray * commands = ibus_engine_plugin_get_available_commands(m_lua_plugin); for ( int i = 0; i < commands->len; ++i){ lua_command_t * command = &g_array_index(commands, lua_command_t, i); @@ -105,6 +107,21 @@ ExtEditor::fillCommandCandidates() bool ExtEditor::fillCommandCandidates(std::string prefix) { + clearLookupTable(); + + /* fill candidates here. */ + int len = prefix.length(); + const char * prefix_str = prefix.c_str(); + const GArray * commands = ibus_engine_plugin_get_available_commands(m_lua_plugin); + for ( int i = 0; i < commands->len; ++i){ + lua_command_t * command = &g_array_index(commands, lua_command_t, i); + if ( strncmp(prefix_str, command->command_name, len) == 0){ + m_lookup_table.appendLabel(Text(command->command_name)); + m_lookup_table.appendCandidate(Text(command->description)); + } + } + + sendLookupTable(); return true; } |