summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2018-02-23 15:54:25 +0800
committerPeng Wu <alexepico@gmail.com>2018-02-23 15:54:25 +0800
commitf80b1fbf06ffe89a15ad74d7c0c4e8b4aa4ec1c2 (patch)
tree8600e06548db336d70f3d7bfe12538f9d12cac8b
parent28fa26af3d5680253e7a47953801add0e44118bf (diff)
downloadibus-libpinyin-f80b1fbf06ffe89a15ad74d7c0c4e8b4aa4ec1c2.tar.gz
ibus-libpinyin-f80b1fbf06ffe89a15ad74d7c0c4e8b4aa4ec1c2.tar.xz
ibus-libpinyin-f80b1fbf06ffe89a15ad74d7c0c4e8b4aa4ec1c2.zip
enable English and Stroke Editor for Double Pinyin
-rw-r--r--src/PYEnglishEditor.cc11
-rw-r--r--src/PYExtEditor.cc2
-rw-r--r--src/PYExtEditor.h4
-rw-r--r--src/PYPPinyinEngine.cc12
-rw-r--r--src/PYStrokeEditor.cc11
5 files changed, 27 insertions, 13 deletions
diff --git a/src/PYEnglishEditor.cc b/src/PYEnglishEditor.cc
index 8d58e0f..1e27deb 100644
--- a/src/PYEnglishEditor.cc
+++ b/src/PYEnglishEditor.cc
@@ -418,11 +418,11 @@ EnglishEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
/* Remember the input string. */
if (m_cursor == 0) {
- g_return_val_if_fail ('v' == keyval, FALSE);
- m_text = "v";
+ g_return_val_if_fail ('v' == keyval || 'V' == keyval, FALSE);
+ m_text.insert (m_cursor, keyval);
m_cursor ++;
} else {
- g_return_val_if_fail ('v' == m_text[0], FALSE);
+ g_return_val_if_fail ('v' == m_text[0] || 'V' == m_text[0], FALSE);
if ((keyval >= 'a' && keyval <= 'z') ||
(keyval >= 'A' && keyval <= 'Z')) {
m_text.insert (m_cursor, keyval);
@@ -596,14 +596,15 @@ EnglishEditor::updateStateFromInput (void)
return FALSE;
}
- if ('v' != m_text[0]) {
+ if ('v' != m_text[0] && 'V' != m_text[0]) {
g_warning ("v is expected in m_text string.\n");
m_auxiliary_text = "";
clearLookupTable ();
return FALSE;
}
- m_auxiliary_text = "v";
+ m_auxiliary_text.printf("%c", m_text[0]);
+
if (1 == m_text.length ()) {
clearLookupTable ();
diff --git a/src/PYExtEditor.cc b/src/PYExtEditor.cc
index a7f08fb..accbe4e 100644
--- a/src/PYExtEditor.cc
+++ b/src/PYExtEditor.cc
@@ -608,7 +608,7 @@ ExtEditor::updateStateFromInput (void)
return FALSE;
}
- m_auxiliary_text = m_text[0];
+ m_auxiliary_text.printf("%c", m_text[0]);
m_mode = LABEL_LIST_COMMANDS;
if ( 1 == m_text.length () ) {
diff --git a/src/PYExtEditor.h b/src/PYExtEditor.h
index 5342f5f..cef967f 100644
--- a/src/PYExtEditor.h
+++ b/src/PYExtEditor.h
@@ -87,8 +87,8 @@ private:
LabelMode m_mode;
Pointer<IBusEnginePlugin> m_lua_plugin;
- std::string m_preedit_text;
- std::string m_auxiliary_text;
+ String m_preedit_text;
+ String m_auxiliary_text;
LookupTable m_lookup_table;
diff --git a/src/PYPPinyinEngine.cc b/src/PYPPinyinEngine.cc
index 047cad2..eb0e748 100644
--- a/src/PYPPinyinEngine.cc
+++ b/src/PYPPinyinEngine.cc
@@ -206,6 +206,12 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
break;
m_input_mode = MODE_ENGLISH;
break;
+ case IBUS_V:
+ // for double pinyin
+ if (!PinyinConfig::instance ().doublePinyin ())
+ break;
+ m_input_mode = MODE_ENGLISH;
+ break;
#endif
#ifdef IBUS_BUILD_STROKE_INPUT_MODE
case IBUS_u:
@@ -214,6 +220,12 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
break;
m_input_mode = MODE_STROKE;
break;
+ case IBUS_U:
+ // for double pinyin
+ if (!PinyinConfig::instance ().doublePinyin ())
+ break;
+ m_input_mode = MODE_STROKE;
+ break;
#endif
}
} else {
diff --git a/src/PYStrokeEditor.cc b/src/PYStrokeEditor.cc
index 20bc84f..af26baa 100644
--- a/src/PYStrokeEditor.cc
+++ b/src/PYStrokeEditor.cc
@@ -194,11 +194,11 @@ StrokeEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
/* Remember the input string. */
if (m_cursor == 0) {
- g_return_val_if_fail ('u' == keyval, FALSE);
- m_text = "u";
+ g_return_val_if_fail ('u' == keyval || 'U' == keyval, FALSE);
+ m_text.insert (m_cursor, keyval);
m_cursor ++;
} else {
- g_return_val_if_fail ('u' == m_text[0], FALSE);
+ g_return_val_if_fail ('u' == m_text[0] || 'U' == m_text[0], FALSE);
if (keyval >= 'a' && keyval <= 'z') {
/* only lower case characters here */
m_text.insert (m_cursor, keyval);
@@ -371,14 +371,15 @@ StrokeEditor::updateStateFromInput (void)
return FALSE;
}
- if ('u' != m_text[0]) {
+ if ('u' != m_text[0] && 'U' != m_text[0]) {
g_warning ("u is expected in m_text string.\n");
m_auxiliary_text = "";
clearLookupTable ();
return FALSE;
}
- m_auxiliary_text = "u";
+ m_auxiliary_text.printf("%c", m_text[0]);
+
if (1 == m_text.length ()) {
clearLookupTable ();