summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2017-02-10 15:27:55 +0800
committerPeng Wu <alexepico@gmail.com>2017-02-10 15:27:55 +0800
commitb6fa9a62daaec6374d352ed5e4066e7b105a92c9 (patch)
treef37cf92b54e86c7421329234ae52f7aa465e1c1c
parent9b70b77d73333486fce7d598749d2431d5cbdb12 (diff)
downloadibus-libpinyin-b6fa9a62daaec6374d352ed5e4066e7b105a92c9.tar.gz
ibus-libpinyin-b6fa9a62daaec6374d352ed5e4066e7b105a92c9.tar.xz
ibus-libpinyin-b6fa9a62daaec6374d352ed5e4066e7b105a92c9.zip
use libpinyin 1.9.91
-rw-r--r--src/PYLibPinyin.cc5
-rw-r--r--src/PYLibPinyin.h2
-rw-r--r--src/PYPBopomofoEditor.cc12
-rw-r--r--src/PYPBopomofoEditor.h2
-rw-r--r--src/PYPPhoneticEditor.cc8
-rw-r--r--src/PYPPhoneticEditor.h2
-rw-r--r--src/PYPPinyinEditor.cc10
-rw-r--r--src/PYPPinyinEditor.h2
8 files changed, 24 insertions, 19 deletions
diff --git a/src/PYLibPinyin.cc b/src/PYLibPinyin.cc
index 179a454..4157854 100644
--- a/src/PYLibPinyin.cc
+++ b/src/PYLibPinyin.cc
@@ -309,12 +309,13 @@ LibPinyinBackEnd::clearPinyinUserData (const char * target)
}
gboolean
-LibPinyinBackEnd::rememberUserInput (pinyin_instance_t * instance)
+LibPinyinBackEnd::rememberUserInput (pinyin_instance_t * instance,
+ gint index)
{
/* pre-check the incomplete pinyin keys, prepare pinyin string,
remember user input. */
gchar * sentence = NULL;
- pinyin_get_sentence (instance, &sentence);
+ pinyin_get_sentence (instance, index, &sentence);
pinyin_remember_user_input (instance, sentence, -1);
g_free (sentence);
/* save later,
diff --git a/src/PYLibPinyin.h b/src/PYLibPinyin.h
index c7511bc..a451d8f 100644
--- a/src/PYLibPinyin.h
+++ b/src/PYLibPinyin.h
@@ -54,7 +54,7 @@ public:
gboolean exportPinyinDictionary (const char * filename);
gboolean clearPinyinUserData (const char * target);
- gboolean rememberUserInput (pinyin_instance_t * instance);
+ gboolean rememberUserInput (pinyin_instance_t * instance, gint index);
/* use static initializer in C++. */
static LibPinyinBackEnd & instance (void) { return *m_instance; }
diff --git a/src/PYPBopomofoEditor.cc b/src/PYPBopomofoEditor.cc
index be89eb5..4588a34 100644
--- a/src/PYPBopomofoEditor.cc
+++ b/src/PYPBopomofoEditor.cc
@@ -137,7 +137,7 @@ BopomofoEditor::processAuxiliarySelectKey
gboolean
BopomofoEditor::processSelectKey (guint keyval, guint keycode,
- guint modifiers)
+ guint modifiers)
{
if (G_UNLIKELY (!m_text))
return FALSE;
@@ -254,7 +254,7 @@ BopomofoEditor::updatePinyin (void)
}
void
-BopomofoEditor::commit ()
+BopomofoEditor::commit (gint index)
{
if (G_UNLIKELY (m_text.empty ()))
return;
@@ -263,7 +263,7 @@ BopomofoEditor::commit ()
/* sentence candidate */
char *tmp = NULL;
- pinyin_get_sentence (m_instance, &tmp);
+ pinyin_get_sentence (m_instance, index, &tmp);
if (tmp) {
if (m_props.modeSimp ()) {
m_buffer << tmp;
@@ -291,9 +291,9 @@ BopomofoEditor::commit ()
++p;
}
- pinyin_train(m_instance);
+ pinyin_train(m_instance, index);
if (m_config.rememberEveryInput ())
- LibPinyinBackEnd::instance ().rememberUserInput (m_instance);
+ LibPinyinBackEnd::instance ().rememberUserInput (m_instance, index);
LibPinyinBackEnd::instance ().modified();
PhoneticEditor::commit ((const gchar *)m_buffer);
reset();
@@ -310,7 +310,7 @@ BopomofoEditor::updatePreeditText ()
m_buffer.clear ();
char *sentence = NULL;
- pinyin_get_sentence(m_instance, &sentence);
+ pinyin_get_sentence(m_instance, 0, &sentence);
if (sentence) {
if (m_props.modeSimp ()) {
m_buffer<<sentence;
diff --git a/src/PYPBopomofoEditor.h b/src/PYPBopomofoEditor.h
index 0093842..b2eea47 100644
--- a/src/PYPBopomofoEditor.h
+++ b/src/PYPBopomofoEditor.h
@@ -51,7 +51,7 @@ protected:
virtual void updateAuxiliaryText ();
virtual void updatePinyin (void);
- void commit ();
+ void commit (gint index = 0);
void reset ();
gboolean insert (gint ch);
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc
index 0ef11d7..8141685 100644
--- a/src/PYPPhoneticEditor.cc
+++ b/src/PYPPhoneticEditor.cc
@@ -388,8 +388,12 @@ PhoneticEditor::selectCandidate (guint i)
lookup_candidate_type_t type;
pinyin_get_candidate_type (m_instance, candidate, &type);
- if (BEST_MATCH_CANDIDATE == type) {
- commit ();
+ if (NBEST_MATCH_CANDIDATE == type) {
+ /* as nbest match candidate starts from the beginning of user input. */
+ pinyin_choose_candidate (m_instance, 0, candidate);
+ guint8 index = 0;
+ pinyin_get_candidate_nbest_index(m_instance, candidate, &index);
+ commit (index);
return TRUE;
}
diff --git a/src/PYPPhoneticEditor.h b/src/PYPPhoneticEditor.h
index e8a3ece..fb2f7c3 100644
--- a/src/PYPPhoneticEditor.h
+++ b/src/PYPPhoneticEditor.h
@@ -71,7 +71,7 @@ protected:
virtual gboolean moveCursorRightByWord (void);
virtual gboolean moveCursorToBegin (void);
virtual gboolean moveCursorToEnd (void);
- virtual void commit (void) = 0;
+ virtual void commit (gint index = 0) = 0;
virtual void updateAuxiliaryText (void) = 0;
virtual void updatePreeditText (void) = 0;
virtual void updatePinyin (void) = 0;
diff --git a/src/PYPPinyinEditor.cc b/src/PYPPinyinEditor.cc
index b7ab8c3..2cbd41b 100644
--- a/src/PYPPinyinEditor.cc
+++ b/src/PYPPinyinEditor.cc
@@ -199,7 +199,7 @@ PinyinEditor::processKeyEvent (guint keyval, guint keycode,
}
void
-PinyinEditor::commit ()
+PinyinEditor::commit (gint index)
{
if (G_UNLIKELY (m_text.empty ()))
return;
@@ -208,7 +208,7 @@ PinyinEditor::commit ()
/* sentence candidate */
char *tmp = NULL;
- pinyin_get_sentence (m_instance, &tmp);
+ pinyin_get_sentence (m_instance, index, &tmp);
if (tmp) {
if (m_props.modeSimp ()) {
m_buffer << tmp;
@@ -228,9 +228,9 @@ PinyinEditor::commit ()
m_buffer << p;
}
- pinyin_train (m_instance);
+ pinyin_train (m_instance, index);
if (m_config.rememberEveryInput ())
- LibPinyinBackEnd::instance ().rememberUserInput (m_instance);
+ LibPinyinBackEnd::instance ().rememberUserInput (m_instance, index);
LibPinyinBackEnd::instance ().modified ();
PhoneticEditor::commit ((const gchar *)m_buffer);
reset();
@@ -247,7 +247,7 @@ PinyinEditor::updatePreeditText ()
m_buffer.clear ();
char *sentence = NULL;
- pinyin_get_sentence (m_instance, &sentence);
+ pinyin_get_sentence (m_instance, 0, &sentence);
if (sentence) {
if (m_props.modeSimp ()) {
m_buffer<<sentence;
diff --git a/src/PYPPinyinEditor.h b/src/PYPPinyinEditor.h
index 30dff69..a9b690a 100644
--- a/src/PYPPinyinEditor.h
+++ b/src/PYPPinyinEditor.h
@@ -40,7 +40,7 @@ protected:
gboolean processPunct (guint keyval, guint keycode, guint modifiers);
gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers);
- void commit ();
+ void commit (gint index = 0);
virtual void updateAuxiliaryText (void) = 0;
virtual void updateLookupTable (void);