diff options
| author | Peng Wu <alexepico@gmail.com> | 2010-05-11 14:48:25 +0800 |
|---|---|---|
| committer | Peng Wu <alexepico@gmail.com> | 2010-05-19 10:09:33 +0800 |
| commit | 4a56a37823f7cf93a89f9fea0afedcdbe3ce69d1 (patch) | |
| tree | 366bc640637ad18042bd565b162ed6e1dee2feb2 /src/ExtEditor.cc | |
| parent | cedc8d5c6968deae7936a59a608184d91edd5121 (diff) | |
| download | ibus-libpinyin-4a56a37823f7cf93a89f9fea0afedcdbe3ce69d1.tar.gz ibus-libpinyin-4a56a37823f7cf93a89f9fea0afedcdbe3ce69d1.tar.xz ibus-libpinyin-4a56a37823f7cf93a89f9fea0afedcdbe3ce69d1.zip | |
add m_cursor_pos.
Diffstat (limited to 'src/ExtEditor.cc')
| -rw-r--r-- | src/ExtEditor.cc | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/ExtEditor.cc b/src/ExtEditor.cc index 4bd3933..d849c9a 100644 --- a/src/ExtEditor.cc +++ b/src/ExtEditor.cc @@ -8,7 +8,8 @@ namespace PY { ExtEditor::ExtEditor (PinyinProperties & props) : Editor (props), - m_mode(LABEL_NONE) + m_mode(LABEL_NONE), + m_cursor_pos(0) { m_lua_plugin = ibus_engine_plugin_new(); @@ -49,13 +50,17 @@ ExtEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) //handle page/cursor up/down here. //handle label key select here. + m_cursor_pos = std::min(m_cursor_pos, m_input.length()); + /* Remember the input string. */ - switch(m_input.length()){ + switch(m_cursor_pos){ case 0: //Empty input string. { g_return_val_if_fail( 'i' == keyval, FALSE); - if ( 'i' == keyval ) - m_input += keyval; + if ( 'i' == keyval ) { + m_input.insert(m_cursor_pos, keyval); + m_cursor_pos++; + } //move to updateStateFromInput. m_mode = LABEL_NONE; } @@ -63,8 +68,10 @@ ExtEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) case 1 ... 2: // Only contains 'i' in input string. { g_return_val_if_fail( 'i' == m_input[0], FALSE); - if ( isalnum(keyval) ) - m_input += keyval; + if ( isalnum(keyval) ) { + m_input.insert(m_cursor_pos, keyval); + m_cursor_pos++; + } //move to updateStateFromInput. if ( isalpha(m_input[1])) m_mode = LABEL_LIST_COMMANDS; @@ -76,8 +83,10 @@ ExtEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) default: //Here is the appended argment. { g_return_val_if_fail( 'i' == m_input[0], FALSE); - if (isprint(keyval)) - m_input += keyval; + if (isprint(keyval)){ + m_input.insert(m_cursor_pos, keyval); + m_cursor_pos++; + } //move to updateStateFromInput. if ( isalpha(m_input[1])) { |
