Commit dcca3dde authored by ChangZhuo Chen's avatar ChangZhuo Chen

New upstream version 1.9.2

parent 29df6d8b
version 1.9.2
* fixes pinyin and bopomofo config
version 1.9.1
* add sort candidate option to setup dialog
version 1.9.0
* bump version
version 1.8.92
* fixes config in setup dialog
version 1.8.91
* use libpinyin 1.9.91
version 1.8.1
* change dconf key name to lower case
version 1.8.0
* use libpinyin 1.6.0
* fixes setup dialog
version 1.7.91
* use libpinyin 1.5.91
* allow to remove the user phrase
* enable lua script extension in double pinyin
version 1.7.0
* python 3.x migration
* use opencc 1.0
......
......@@ -21,8 +21,8 @@
# if not 1, append datestamp to the version number.
m4_define([ibus_released], [1])
m4_define([ibus_major_version], [1])
m4_define([ibus_minor_version], [7])
m4_define([ibus_micro_version], [3])
m4_define([ibus_minor_version], [9])
m4_define([ibus_micro_version], [2])
m4_define(ibus_maybe_datestamp,
m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
......@@ -54,17 +54,21 @@ AC_PROG_SED
# check ibus
PKG_CHECK_MODULES(IBUS, [
ibus-1.0 >= 1.4.0
ibus-1.0 >= 1.5.11
])
# check sqlite
PKG_CHECK_MODULES(SQLITE, [
sqlite3
])
AC_PATH_PROG(SQLITE3, sqlite3)
if test -z "$SQLITE3"; then
AC_MSG_ERROR([could not find sqlite3 tool.])
fi
PKG_CHECK_MODULES(LIBPINYIN, [
libpinyin >= 1.2.91
libpinyin >= 1.9.91
], [enable_libpinyin=yes])
LIBPINYIN_DATADIR=`$PKG_CONFIG --variable=pkgdatadir libpinyin`
......@@ -93,6 +97,23 @@ AC_ARG_WITH(python,
)
AM_PATH_PYTHON([2.5])
# check icon_prop_key in IBus.EngineDesc
AC_MSG_CHECKING([if IBus.EngineDesc has get_icon_prop_key])
ICON_PROP_KEY_TEST="import gi
gi.require_version('IBus', '1.0')
from gi.repository import IBus
exit(not hasattr(IBus.EngineDesc, 'get_icon_prop_key'))
"
$PYTHON -c "$ICON_PROP_KEY_TEST"
if test $? -eq 0; then
ICON_PROP_KEY_XML="<icon_prop_key>InputMode</icon_prop_key>"
AC_MSG_RESULT([yes])
else
ICON_PROP_KEY_XML="<!-- <icon_prop_key>InputMode</icon_prop_key> -->"
AC_MSG_RESULT([ibus 1.5.11 or later supports icon-prop-key in IBus.EngineDesc])
fi
AC_SUBST(ICON_PROP_KEY_XML)
# --enable-boost
AC_ARG_ENABLE(boost,
AC_HELP_STRING([--enable-boost],
......@@ -129,10 +150,6 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
AM_GLIB_GNU_GETTEXT
PKG_CHECK_MODULES(GDK3, [
gdk-3.0
])
# --disable-lua-extension
AC_ARG_ENABLE(lua-extension,
AS_HELP_STRING([--disable-lua-extension],
......
......@@ -7,7 +7,7 @@ Comment=Set ibus-libbopomofo Preferences
Comment[zh_CN]=设置 IBus 智能注音首选项
Comment[zh_TW]=設定 IBus 智能注音個人偏好
Comment[zh_HK]=設定 IBus 智能注音個人偏好
Exec=@libexecdir@/ibus-setup-libpinyin bopomofo
Exec=@libexecdir@/ibus-setup-libpinyin libbopomofo
Icon=@pkgdatadir@/icons/ibus-bopomofo.svg
NoDisplay=true
Type=Application
......
......@@ -7,7 +7,7 @@ Comment=Set ibus-libpinyin Preferences
Comment[zh_CN]=设置 IBus 智能拼音首选项
Comment[zh_TW]=設定 IBus 智能拼音個人偏好
Comment[zh_HK]=設定 IBus 智能拼音個人偏好
Exec=@libexecdir@/ibus-setup-libpinyin
Exec=@libexecdir@/ibus-setup-libpinyin libpinyin
Icon=@pkgdatadir@/icons/ibus-pinyin.svg
NoDisplay=true
Type=Application
......
......@@ -101,8 +101,6 @@ int main(int argc, char * argv[]){
exit(1);
}
g_type_init();
IBusEnginePlugin * plugin = ibus_engine_plugin_new();
for ( i = 1; i < argc; ++i){
......@@ -128,7 +126,7 @@ int main(int argc, char * argv[]){
print_interactive_help();
if ( 0 == strcmp("i", strs[0]) )
list_all_commands(plugin);
break;
break;
case 2:
if ( 0 == strcmp("i", strs[0]))
do_lua_call(plugin, strs[1], NULL);
......
......@@ -29,7 +29,9 @@
#if LUA_VERSION_NUM >= 502
/* ugly hack for lua 5.2 */
#ifndef lua_objlen
#define lua_objlen lua_rawlen
#endif
#endif
......
......@@ -30,7 +30,9 @@
#define lua_open luaL_newstate
#ifndef lua_objlen
#define lua_objlen lua_rawlen
#endif
#endif
......
......@@ -28,8 +28,6 @@
int main(int argc, char * argv[]){
printf("starting test...\n");
g_type_init();
IBusEnginePlugin * plugin;
plugin = ibus_engine_plugin_new();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -48,11 +48,11 @@ test-libpinyin:
IBUS_LOCALEDIR=@localedir@ \
IBUS_PKGDATADIR=$(pkgdatadir) \
PYTHONPATH=$(abs_top_srcdir):$(pyexecdir) \
$(PYTHON) $(srcdir)/main2.py pinyin
$(PYTHON) $(srcdir)/main2.py libpinyin
test-libbopomofo:
$(ENV) DBUS_DEBUG=true \
IBUS_LOCALEDIR=@localedir@ \
IBUS_PKGDATADIR=$(pkgdatadir) \
PYTHONPATH=$(abs_top_srcdir):$(pyexecdir) \
$(PYTHON) $(srcdir)/main2.py bopomofo
$(PYTHON) $(srcdir)/main2.py libbopomofo
This diff is collapsed.
This diff is collapsed.
......@@ -43,10 +43,10 @@ COLUMN_ACCELERATOR,
# The default shortcut value is stored here.
accelerators = \
(
(_("Switch Chinese/English"), "MainSwitch" , "<Shift>"),
(_("Full/Half Width Letter"), "LetterSwitch", ""),
(_("Full/Half Width Punct"), "PunctSwitch", "<Control>period"),
(_("Switch Traditional/Simplfied Chinese"), "TradSwitch", "<Control><Shift>f")
(_("Switch Chinese/English"), "main_switch" , "<Shift>"),
(_("Full/Half Width Letter"), "letter_switch", ""),
(_("Full/Half Width Punct"), "punct_switch", "<Control>period"),
(_("Switch Traditional/Simplfied Chinese"), "trad_switch", "<Control><Shift>f")
)
class ShortcutTreeView(Gtk.TreeView):
......
......@@ -109,8 +109,8 @@ ibus_engine_libpinyin_CXXFLAGS = \
@SQLITE_CFLAGS@ \
@LIBPINYIN_CFLAGS@ \
@OPENCC_CFLAGS@ \
@GDK3_CFLAGS@ \
-DGETTEXT_PACKAGE=\"@GETTEXT_PACKAGE@\" \
-DLOCALEDIR=\"$(localedir)\" \
-DPKGDATADIR=\"$(pkgdatadir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
$(NULL)
......@@ -130,7 +130,6 @@ ibus_engine_libpinyin_LDADD = \
@SQLITE_LIBS@ \
@LIBPINYIN_LIBS@ \
@OPENCC_LIBS@ \
@GDK3_LIBS@ \
$(NULL)
ibus_engine_libpinyin_CXXFLAGS += \
......
......@@ -47,6 +47,7 @@ Config::initDefaultValues (void)
m_orientation = IBUS_ORIENTATION_HORIZONTAL;
m_page_size = 5;
m_remember_every_input = FALSE;
m_sort_option = SORT_BY_PHRASE_LENGTH_AND_FREQUENCY;
m_shift_select_candidate = FALSE;
m_minus_equal_page = TRUE;
......
......@@ -46,6 +46,7 @@ public:
guint orientation (void) const { return m_orientation; }
guint pageSize (void) const { return m_page_size; }
gboolean rememberEveryInput (void) const { return m_remember_every_input; }
sort_option_t sortOption (void) const { return m_sort_option; }
gboolean shiftSelectCandidate (void) const { return m_shift_select_candidate; }
gboolean minusEqualPage (void) const { return m_minus_equal_page; }
gboolean commaPeriodPage (void) const { return m_comma_period_page; }
......@@ -96,6 +97,7 @@ protected:
gint m_orientation;
guint m_page_size;
gboolean m_remember_every_input;
sort_option_t m_sort_option;
gboolean m_shift_select_candidate;
gboolean m_minus_equal_page;
......
......@@ -21,7 +21,6 @@
#include "PYEngine.h"
#include <cstring>
#include <gdk/gdk.h>
#include "PYPPinyinEngine.h"
#include "PYPBopomofoEngine.h"
......@@ -339,7 +338,7 @@ pinyin_accelerator_name(guint keyval, guint modifiers, std::string & name) {
/* Convert keyval. */
if (keyval) {
const gchar * symbol = gdk_keyval_name (gdk_keyval_to_lower (keyval));
const gchar * symbol = ibus_keyval_name (ibus_keyval_to_lower (keyval));
name += symbol;
}
......
......@@ -83,7 +83,7 @@ simplest_cn_number(gint64 num)
}
static inline const std::string
translate_to_longform(gint64 num, const char * number[10], unit_t units[])
translate_to_longform(gint64 num, const char * number[10], unit_t units[], int units_len)
{
std::string result = "";
int cur_pos = -1;
......@@ -97,7 +97,7 @@ translate_to_longform(gint64 num, const char * number[10], unit_t units[])
int pos = cur_pos;
size_t i = 6;
while ( pos > 0 ) {
for ( i = 0; i < 7; ++i) {
for ( i = 0; i < units_len; ++i) {
pos = pos % units[i].digits;
if ( pos == 0 )
break;
......@@ -133,7 +133,7 @@ translate_to_longform(gint64 num, const char * number[10], unit_t units[])
static const std::string
simplified_number(gint64 num)
{
return translate_to_longform(num, numbers[1], units_simplified);
return translate_to_longform(num, numbers[1], units_simplified, G_N_ELEMENTS(units_simplified));
}
static const std::string
......@@ -141,7 +141,7 @@ traditional_number(gint64 num)
{
if ( 0 == num )
return numbers[0][0];
return translate_to_longform(num, numbers[0], units_traditional);
return translate_to_longform(num, numbers[0], units_traditional, G_N_ELEMENTS(units_traditional));
}
......@@ -219,16 +219,16 @@ ExtEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
switch (m_cursor) {
case 0: //Empty input string.
{
g_return_val_if_fail ( 'i' == keyval, FALSE);
if ( 'i' == keyval ) {
g_return_val_if_fail ( 'i' == keyval || 'I' == keyval, FALSE);
if ( 'i' == keyval || 'I' == keyval) {
m_text.insert (m_cursor, keyval);
m_cursor++;
}
}
break;
case 1 ... 2: // Only contains 'i' in input string.
case 1 ... 2: // Only contains 'i' or 'I' in input string.
{
g_return_val_if_fail ( 'i' == m_text[0], FALSE);
g_return_val_if_fail ( 'i' == m_text[0] || 'I' == m_text[0], FALSE);
if ( isalnum (keyval) ) {
m_text.insert (m_cursor, keyval);
m_cursor++;
......@@ -237,7 +237,7 @@ ExtEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
break;
default: //Here is the appended argment.
{
g_return_val_if_fail ( 'i' == m_text[0], FALSE);
g_return_val_if_fail ( 'i' == m_text[0] || 'I' == m_text[0], FALSE);
if (isprint (keyval)) {
m_text.insert (m_cursor, keyval);
m_cursor++;
......@@ -603,12 +603,12 @@ ExtEditor::updateStateFromInput (void)
return FALSE;
}
if ( 'i' != m_text[0] ) {
g_warning ("i is expected in m_text string.\n");
if ( 'i' != m_text[0] && 'I' != m_text[0] ) {
g_warning ("'i' or 'I' is expected in m_text string.\n");
return FALSE;
}
m_auxiliary_text = "i";
m_auxiliary_text = m_text[0];
m_mode = LABEL_LIST_COMMANDS;
if ( 1 == m_text.length () ) {
......
......@@ -152,9 +152,9 @@ FallbackEditor::processPunctForTraditionalChinese (guint keyval, guint keycode,
commit ("。");
return TRUE;
case '<':
commit (""); return TRUE;
commit (""); return TRUE;
case '>':
commit (""); return TRUE;
commit (""); return TRUE;
case '?':
commit ("?"); return TRUE;
}
......@@ -200,8 +200,7 @@ FallbackEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
{
gboolean retval = FALSE;
modifiers &= (IBUS_SHIFT_MASK |
IBUS_CONTROL_MASK |
modifiers &= (IBUS_CONTROL_MASK |
IBUS_MOD1_MASK |
IBUS_SUPER_MASK |
IBUS_HYPER_MASK |
......
......@@ -213,8 +213,10 @@ LibPinyinBackEnd::importPinyinDictionary (const char * filename)
import_iterator_t * iter = pinyin_begin_add_phrases
(m_pinyin_context, USER_DICTIONARY);
if (NULL == iter)
if (NULL == iter) {
fclose(dictfile);
return FALSE;
}
char* linebuf = NULL; size_t size = 0; ssize_t read;
while ((read = getline (&linebuf, &size, dictfile)) != -1) {
......@@ -261,8 +263,10 @@ LibPinyinBackEnd::exportPinyinDictionary (const char * filename)
export_iterator_t * iter = pinyin_begin_get_phrases
(m_pinyin_context, USER_DICTIONARY);
if (NULL == iter)
if (NULL == iter) {
fclose(dictfile);
return FALSE;
}
/* use " " as the separator. */
while (pinyin_iterator_has_next_phrase (iter)) {
......@@ -279,6 +283,7 @@ LibPinyinBackEnd::exportPinyinDictionary (const char * filename)
g_free (phrase); g_free (pinyin);
}
pinyin_end_get_phrases(iter);
fclose (dictfile);
return TRUE;
}
......@@ -304,49 +309,15 @@ 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. */
guint len = 0;
g_assert (pinyin_get_n_pinyin (instance, &len));
if (0 == len || len >= MAX_PHRASE_LENGTH)
return FALSE;
size_t i = 0;
for ( ; i < len; ++i) {
PinyinKey *key = NULL;
g_assert (pinyin_get_pinyin_key (instance, i, &key));
if (pinyin_get_pinyin_is_incomplete (instance, key))
return FALSE;
}
/* prepare pinyin string. */
GPtrArray *array = g_ptr_array_new ();
for (i = 0; i < len; ++i) {
PinyinKey *key = NULL;
g_assert (pinyin_get_pinyin_key (instance, i, &key));
gchar * pinyin = NULL;
g_assert (pinyin_get_pinyin_string (instance, key, &pinyin));
g_ptr_array_add (array, pinyin);
}
g_ptr_array_add (array, NULL);
gchar **strings = (gchar **) g_ptr_array_free (array, FALSE);
gchar *pinyins = g_strjoinv ("'", strings);
g_strfreev (strings);
/* remember user input. */
import_iterator_t * iter = NULL;
pinyin_context_t * context = pinyin_get_context (instance);
iter = pinyin_begin_add_phrases (context, USER_DICTIONARY);
char * phrase = NULL;
g_assert (pinyin_get_sentence (instance, &phrase));
g_assert (pinyin_iterator_add_phrase (iter, phrase, pinyins, -1));
pinyin_end_add_phrases (iter);
g_free (phrase);
g_free (pinyins);
/* pre-check the incomplete pinyin keys, prepare pinyin string,
remember user input. */
gchar * sentence = NULL;
pinyin_get_sentence (instance, index, &sentence);
pinyin_remember_user_input (instance, sentence, -1);
g_free (sentence);
/* save later,
will mark modified from pinyin/bopomofo editor. */
return TRUE;
......
......@@ -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; }
......
......@@ -25,6 +25,7 @@
#include <ibus.h>
#include <stdlib.h>
#include <locale.h>
#include <libintl.h>
#include "PYEngine.h"
#include "PYPointer.h"
#include "PYBus.h"
......@@ -165,6 +166,10 @@ main (gint argc, gchar **argv)
setlocale (LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
context = g_option_context_new ("- ibus pinyin engine component");
g_option_context_add_main_entries (context, entries, "ibus-libpinyin");
......
......@@ -20,7 +20,6 @@
*/
#include "PYPBopomofoEditor.h"
#include <assert.h>
#include "PYConfig.h"
#include "PYLibPinyin.h"
#include "PYPinyinProperties.h"
......@@ -138,7 +137,7 @@ BopomofoEditor::processAuxiliarySelectKey
gboolean
BopomofoEditor::processSelectKey (guint keyval, guint keycode,
guint modifiers)
guint modifiers)
{
if (G_UNLIKELY (!m_text))
return FALSE;
......@@ -255,7 +254,7 @@ BopomofoEditor::updatePinyin (void)
}
void
BopomofoEditor::commit ()
BopomofoEditor::commit (gint index)
{
if (G_UNLIKELY (m_text.empty ()))
return;
......@@ -264,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;
......@@ -279,7 +278,7 @@ BopomofoEditor::commit ()
while (*p != '\0') {
gchar ** symbols = NULL;
if (pinyin_in_chewing_keyboard (m_instance, *p, &symbols)) {
assert (1 == g_strv_length (symbols));
g_assert (1 == g_strv_length (symbols));
m_buffer << symbols[0];
g_strfreev (symbols);
} else {
......@@ -292,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,16 +309,14 @@ BopomofoEditor::updatePreeditText ()
}
m_buffer.clear ();
char *tmp = NULL;
pinyin_get_sentence(m_instance, &tmp);
if (tmp) {
char *sentence = NULL;
pinyin_get_sentence(m_instance, 0, &sentence);
if (sentence) {
if (m_props.modeSimp ()) {
m_buffer<<tmp;
m_buffer<<sentence;
} else {
SimpTradConverter::simpToTrad (tmp, m_buffer);
SimpTradConverter::simpToTrad (sentence, m_buffer);
}
g_free (tmp);
tmp = NULL;
}
/* append rest text */
......@@ -330,8 +327,13 @@ BopomofoEditor::updatePreeditText ()
/* underline */
preedit_text.appendAttribute (IBUS_ATTR_TYPE_UNDERLINE, IBUS_ATTR_UNDERLINE_SINGLE, 0, -1);
guint pinyin_cursor = getPinyinCursor ();
Editor::updatePreeditText (preedit_text, pinyin_cursor, TRUE);
size_t offset = 0;
guint cursor = getPinyinCursor ();
pinyin_get_character_offset(m_instance, sentence, cursor, &offset);
Editor::updatePreeditText (preedit_text, offset, TRUE);
if (sentence)
g_free (sentence);
}
void
......@@ -344,71 +346,16 @@ BopomofoEditor::updateAuxiliaryText (void)
m_buffer.clear ();
guint len = 0;
pinyin_get_n_pinyin (m_instance, &len);
for (guint i = 0; i < len; ++i) {
PinyinKey *key = NULL;
pinyin_get_pinyin_key (m_instance, i, &key);
PinyinKeyPos *pos = NULL;
pinyin_get_pinyin_key_rest (m_instance, i, &pos);
guint16 cursor = 0, end = 0;
pinyin_get_pinyin_key_rest_positions (m_instance, pos, &cursor, &end);
gchar * str = NULL;
if (G_UNLIKELY (cursor == m_cursor)) { /* at word boundary. */
pinyin_get_zhuyin_string (m_instance, key, &str);
m_buffer << '|' << str;
g_free (str);
} else if (G_LIKELY (cursor < m_cursor &&
m_cursor < end)) { /* in word */
/* raw text */
guint16 length = 0;
pinyin_get_pinyin_key_rest_length (m_instance, pos, &length);
String raw = m_text.substr (cursor, length);
guint offset = m_cursor - cursor;
m_buffer << ' ';
String before = raw.substr (0, offset);
String after = raw.substr (offset);
String::const_iterator iter;
gchar ** symbols = NULL;
for (iter = before.begin (); iter != before.end (); ++iter) {
if (pinyin_in_chewing_keyboard(m_instance, *iter, &symbols)) {
assert (1 == g_strv_length (symbols));
m_buffer << symbols[0];
g_strfreev (symbols);
} else {
m_buffer << *iter;
}
}
m_buffer << '|';
for (iter = after.begin (); iter != after.end (); ++iter) {
if (pinyin_in_chewing_keyboard (m_instance, *iter, &symbols)) {
assert (1 == g_strv_length (symbols));
m_buffer << symbols[0];
g_strfreev (symbols);
} else {
m_buffer << *iter;
}
}
} else { /* other words */
pinyin_get_zhuyin_string (m_instance, key, &str);
m_buffer << ' ' << str;
g_free (str);
}
}
if (m_cursor == m_pinyin_len)
m_buffer << '|';
gchar * aux_text = NULL;
pinyin_get_chewing_auxiliary_text (m_instance, m_cursor, &aux_text);
m_buffer << aux_text;
g_free(aux_text);
/* append rest text */
const gchar * p = m_text.c_str() + m_pinyin_len;
m_buffer << p;
StaticText aux_text (m_buffer);
Editor::updateAuxiliaryText (aux_text, TRUE);
StaticText text (m_buffer);
Editor::updateAuxiliaryText (text, TRUE);
}
......@@ -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);
......
......@@ -230,7 +230,7 @@ inline void
BopomofoEngine::showSetupDialog (void)
{
g_spawn_command_line_async
(LIBEXECDIR"/ibus-setup-libpinyin bopomofo", NULL);
(LIBEXECDIR"/ibus-setup-libpinyin libbopomofo", NULL);
}
gboolean
......
This diff is collapsed.
......@@ -127,48 +127,15 @@ DoublePinyinEditor::updateAuxiliaryText (void)
m_buffer.clear ();
guint len = 0;
pinyin_get_n_pinyin (m_instance, &len);
for (guint i = 0; i < len; ++i) {
PinyinKey *key = NULL;
pinyin_get_pinyin_key (m_instance, i, &key);
PinyinKeyPos *pos = NULL;
pinyin_get_pinyin_key_rest (m_instance, i, &pos);
guint16 cursor = 0, end = 0;
pinyin_get_pinyin_key_rest_positions (m_instance, pos, &cursor, &end);
gchar * str = NULL;
if (G_UNLIKELY (cursor == m_cursor)) { /* at word boundary. */
pinyin_get_pinyin_string (m_instance, key, &str);
m_buffer << '|' << str;
g_free (str);
} else if (G_LIKELY (cursor < m_cursor &&
m_cursor < end)) { /* in word */
guint16 length = 0;
pinyin_get_pinyin_key_rest_length (m_instance, pos, &length);
/* raw text */
String raw = m_text.substr (cursor, length);
guint offset = m_cursor - cursor;
m_buffer << ' ' << raw.substr (0, offset)
<< '|' << raw.substr (offset);
} else { /* other words */
pinyin_get_pinyin_string (m_instance, key, &str);
m_buffer << ' ' << str;
g_free (str);
}
}
if (m_cursor == m_pinyin_len)
m_buffer << '|';
gchar * aux_text = NULL;
pinyin_get_double_pinyin_auxiliary_text (m_instance, m_cursor, &aux_text);
m_buffer << aux_text;
g_free(aux_text);
/* append rest text */
const gchar * p = m_text.c_str() + m_pinyin_len;
m_buffer << p;
StaticText aux_text (m_buffer);
Editor::updateAuxiliaryText (aux_text, TRUE);
StaticText text (m_buffer);
Editor::updateAuxiliaryText (text, TRUE);
}