Hello community, here is the log from the commit of package ibus-libpinyin for openSUSE:Factory checked in at 2016-08-13 18:30:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ibus-libpinyin (Old) and /work/SRC/openSUSE:Factory/.ibus-libpinyin.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ibus-libpinyin" Changes: -------- --- /work/SRC/openSUSE:Factory/ibus-libpinyin/ibus-libpinyin.changes 2015-12-29 12:59:21.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ibus-libpinyin.new/ibus-libpinyin.changes 2016-08-13 18:30:50.000000000 +0200 @@ -1,0 +2,14 @@ +Thu Aug 11 03:15:16 UTC 2016 - [email protected] + +- Fix lua build on openSUSE leap. + * add ibus-libpinyin-build_lua_5.2.patch + +------------------------------------------------------------------- +Wed Aug 10 02:16:13 UTC 2016 - [email protected] + +- Update to 1.7.92 + * use ibus 1.5.11 + * use libpinyin 1.5.92 + * work around getLookupCursor + +------------------------------------------------------------------- Old: ---- ibus-libpinyin-1.7.4.tar.gz New: ---- ibus-libpinyin-1.7.92.tar.gz ibus-libpinyin-build_lua_5.2.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ibus-libpinyin.spec ++++++ --- /var/tmp/diff_new_pack.1jrLNL/_old 2016-08-13 18:30:51.000000000 +0200 +++ /var/tmp/diff_new_pack.1jrLNL/_new 2016-08-13 18:30:51.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package ibus-libpinyin # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2015 Hillwood Yang ([email protected]) # # All modifications and additions to the file contributed by third parties @@ -18,13 +18,15 @@ Name: ibus-libpinyin -Version: 1.7.4 +Version: 1.7.92 Release: 0 Summary: Intelligent Pinyin engine based on libpinyin for IBus License: GPL-2.0+ Group: System/I18n/Chinese Url: https://github.com/libpinyin/ibus-libpinyin Source: https://github.com/libpinyin/ibus-libpinyin/archive/%{version}/%{name}-%{version}.tar.gz +# PATCH-FIX-OPENSUSE [email protected] - fix lua build +Patch0: ibus-libpinyin-build_lua_5.2.patch BuildRequires: fdupes BuildRequires: gcc-c++ BuildRequires: gettext-devel @@ -39,7 +41,7 @@ BuildRequires: sqlite3-devel BuildRequires: update-desktop-files BuildRequires: pkgconfig(gdk-3.0) -BuildRequires: pkgconfig(libpinyin) >= 1.0.99 +BuildRequires: pkgconfig(libpinyin) >= 1.5.92 Requires: python-xdg Provides: locale(ibus:zh_CN;zh_SG) %{ibus_requires} @@ -54,6 +56,9 @@ %prep %setup -q +%if 0%{?suse_version} == 1315 || 0%{?suse_version} == 1320 || 0%{?suse_version} <= 1310 +%patch0 -p1 +%endif %build NOCONFIGURE=1 ./autogen.sh ++++++ ibus-libpinyin-1.7.4.tar.gz -> ibus-libpinyin-1.7.92.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/configure.ac new/ibus-libpinyin-1.7.92/configure.ac --- old/ibus-libpinyin-1.7.4/configure.ac 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/configure.ac 2016-08-02 07:42:29.000000000 +0200 @@ -22,7 +22,7 @@ m4_define([ibus_released], [1]) m4_define([ibus_major_version], [1]) m4_define([ibus_minor_version], [7]) -m4_define([ibus_micro_version], [4]) +m4_define([ibus_micro_version], [92]) m4_define(ibus_maybe_datestamp, m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi])) @@ -54,7 +54,7 @@ # check ibus PKG_CHECK_MODULES(IBUS, [ - ibus-1.0 >= 1.4.0 + ibus-1.0 >= 1.5.11 ]) # check sqlite @@ -68,7 +68,7 @@ fi PKG_CHECK_MODULES(LIBPINYIN, [ - libpinyin >= 1.2.91 + libpinyin >= 1.5.92 ], [enable_libpinyin=yes]) LIBPINYIN_DATADIR=`$PKG_CONFIG --variable=pkgdatadir libpinyin` @@ -133,10 +133,6 @@ 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], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/lua/lua-plugin-init.c new/ibus-libpinyin-1.7.92/lua/lua-plugin-init.c --- old/ibus-libpinyin-1.7.4/lua/lua-plugin-init.c 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/lua/lua-plugin-init.c 2016-08-02 07:42:29.000000000 +0200 @@ -26,11 +26,8 @@ #include "lua-plugin.h" -#if LUA_VERSION_NUM >= 502 -/* ugly hack for lua 5.2 */ - +#ifndef lua_objlen #define lua_objlen lua_rawlen - #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/lua/lua-plugin.c new/ibus-libpinyin-1.7.92/lua/lua-plugin.c --- old/ibus-libpinyin-1.7.4/lua/lua-plugin.c 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/lua/lua-plugin.c 2016-08-02 07:42:29.000000000 +0200 @@ -25,13 +25,15 @@ #include "lua-plugin.h" +#ifndef lua_objlen +#define lua_objlen lua_rawlen +#endif + #if LUA_VERSION_NUM >= 502 /* ugly hack for lua 5.2 */ #define lua_open luaL_newstate -#define lua_objlen lua_rawlen - #endif #define IBUS_ENGINE_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePluginPrivate)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/Makefile.am new/ibus-libpinyin-1.7.92/src/Makefile.am --- old/ibus-libpinyin-1.7.4/src/Makefile.am 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/Makefile.am 2016-08-02 07:42:29.000000000 +0200 @@ -109,7 +109,6 @@ @SQLITE_CFLAGS@ \ @LIBPINYIN_CFLAGS@ \ @OPENCC_CFLAGS@ \ - @GDK3_CFLAGS@ \ -DGETTEXT_PACKAGE=\"@GETTEXT_PACKAGE@\" \ -DPKGDATADIR=\"$(pkgdatadir)\" \ -DLIBEXECDIR=\"$(libexecdir)\" \ @@ -130,7 +129,6 @@ @SQLITE_LIBS@ \ @LIBPINYIN_LIBS@ \ @OPENCC_LIBS@ \ - @GDK3_LIBS@ \ $(NULL) ibus_engine_libpinyin_CXXFLAGS += \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYEngine.cc new/ibus-libpinyin-1.7.92/src/PYEngine.cc --- old/ibus-libpinyin-1.7.4/src/PYEngine.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYEngine.cc 2016-08-02 07:42:29.000000000 +0200 @@ -21,7 +21,6 @@ #include "PYEngine.h" #include <cstring> -#include <gdk/gdk.h> #include "PYPPinyinEngine.h" #include "PYPBopomofoEngine.h" @@ -339,7 +338,7 @@ /* 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; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYExtEditor.cc new/ibus-libpinyin-1.7.92/src/PYExtEditor.cc --- old/ibus-libpinyin-1.7.4/src/PYExtEditor.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYExtEditor.cc 2016-08-02 07:42:29.000000000 +0200 @@ -219,16 +219,16 @@ 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 @@ 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 @@ 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 () ) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYFallbackEditor.cc new/ibus-libpinyin-1.7.92/src/PYFallbackEditor.cc --- old/ibus-libpinyin-1.7.4/src/PYFallbackEditor.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYFallbackEditor.cc 2016-08-02 07:42:29.000000000 +0200 @@ -200,8 +200,7 @@ { gboolean retval = FALSE; - modifiers &= (IBUS_SHIFT_MASK | - IBUS_CONTROL_MASK | + modifiers &= (IBUS_CONTROL_MASK | IBUS_MOD1_MASK | IBUS_SUPER_MASK | IBUS_HYPER_MASK | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYLibPinyin.cc new/ibus-libpinyin-1.7.92/src/PYLibPinyin.cc --- old/ibus-libpinyin-1.7.4/src/PYLibPinyin.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYLibPinyin.cc 2016-08-02 07:42:29.000000000 +0200 @@ -213,8 +213,10 @@ 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 @@ 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 @@ g_free (phrase); g_free (pinyin); } + pinyin_end_get_phrases(iter); fclose (dictfile); return TRUE; } @@ -306,47 +311,12 @@ gboolean LibPinyinBackEnd::rememberUserInput (pinyin_instance_t * instance) { - /* 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, &sentence); + pinyin_remember_user_input (instance, sentence, -1); + g_free (sentence); /* save later, will mark modified from pinyin/bopomofo editor. */ return TRUE; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYPBopomofoEditor.cc new/ibus-libpinyin-1.7.92/src/PYPBopomofoEditor.cc --- old/ibus-libpinyin-1.7.4/src/PYPBopomofoEditor.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYPBopomofoEditor.cc 2016-08-02 07:42:29.000000000 +0200 @@ -20,7 +20,6 @@ */ #include "PYPBopomofoEditor.h" -#include <assert.h> #include "PYConfig.h" #include "PYLibPinyin.h" #include "PYPinyinProperties.h" @@ -279,7 +278,7 @@ 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 { @@ -310,16 +309,14 @@ } m_buffer.clear (); - char *tmp = NULL; - pinyin_get_sentence(m_instance, &tmp); - if (tmp) { + char *sentence = NULL; + pinyin_get_sentence(m_instance, &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 @@ /* 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 (); + g_assert (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 @@ 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); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYPDoublePinyinEditor.cc new/ibus-libpinyin-1.7.92/src/PYPDoublePinyinEditor.cc --- old/ibus-libpinyin-1.7.4/src/PYPDoublePinyinEditor.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYPDoublePinyinEditor.cc 2016-08-02 07:42:29.000000000 +0200 @@ -127,48 +127,15 @@ 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); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYPFullPinyinEditor.cc new/ibus-libpinyin-1.7.92/src/PYPFullPinyinEditor.cc --- old/ibus-libpinyin-1.7.4/src/PYPFullPinyinEditor.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYPFullPinyinEditor.cc 2016-08-02 07:42:29.000000000 +0200 @@ -93,57 +93,24 @@ 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_full_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); } void FullPinyinEditor::update (void) { guint lookup_cursor = getLookupCursor (); - pinyin_guess_full_pinyin_candidates (m_instance, lookup_cursor); + pinyin_guess_candidates (m_instance, lookup_cursor); updateLookupTable (); updatePreeditText (); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYPPhoneticEditor.cc new/ibus-libpinyin-1.7.92/src/PYPPhoneticEditor.cc --- old/ibus-libpinyin-1.7.4/src/PYPPhoneticEditor.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYPPhoneticEditor.cc 2016-08-02 07:42:29.000000000 +0200 @@ -155,6 +155,19 @@ moveCursorRightByWord (); return TRUE; + /* remove user phrase */ + case IBUS_D: + { + guint index = m_lookup_table.cursorPos (); + lookup_candidate_t * candidate = NULL; + pinyin_get_candidate (m_instance, index, &candidate); + if (pinyin_is_user_candidate (m_instance, candidate)) { + pinyin_remove_user_candidate (m_instance, candidate); + updatePinyin (); + update (); + } + return TRUE; + } default: return TRUE; } @@ -253,6 +266,9 @@ } Text text (word); + /* show user candidate as blue. */ + if (pinyin_is_user_candidate (m_instance, candidate)) + text.appendAttribute (IBUS_ATTR_TYPE_FOREGROUND, 0x000000ef, 0, -1); m_lookup_table.appendCandidate (text); } @@ -337,11 +353,9 @@ guint PhoneticEditor::getPinyinCursor () { - guint len = 0; - /* Translate cursor position to pinyin position. */ - guint16 pinyin_cursor = 0; - pinyin_get_pinyin_key_rest_offset (m_instance, m_cursor, &pinyin_cursor); + size_t pinyin_cursor = 0; + pinyin_get_pinyin_offset (m_instance, m_cursor, &pinyin_cursor); return pinyin_cursor; } @@ -349,12 +363,17 @@ guint PhoneticEditor::getLookupCursor (void) { - guint len = 0; - pinyin_get_n_pinyin (m_instance, &len); guint lookup_cursor = getPinyinCursor (); + /* as pinyin_get_pinyin_offset can't handle the last "'" characters, + strip the string to work around it here. */ + String stripped = m_text; + size_t pos = stripped.find_last_not_of ("'") + 1; + if (pos < stripped.length ()) + stripped.erase (pos); + /* show candidates when pinyin cursor is at end. */ - if (lookup_cursor == len) + if (lookup_cursor == stripped.length ()) lookup_cursor = 0; return lookup_cursor; } @@ -384,21 +403,10 @@ lookup_cursor = pinyin_choose_candidate (m_instance, lookup_cursor, candidate); - if (DIVIDED_CANDIDATE == type || - RESPLIT_CANDIDATE == type) { - const gchar * str = NULL; - pinyin_get_raw_full_pinyin (m_instance, &str); - - m_text = str; - updatePinyin (); - } pinyin_guess_sentence (m_instance); - len = 0; - pinyin_get_n_pinyin (m_instance, &len); - if (lookup_cursor == len) { - pinyin_train(m_instance); - commit(); + if (lookup_cursor == m_text.length ()) { + commit (); return TRUE; } @@ -409,6 +417,7 @@ pinyin_get_pinyin_key_rest_positions (m_instance, pos, &begin, NULL); m_cursor = begin; + update (); return TRUE; } @@ -504,37 +513,13 @@ guint PhoneticEditor::getCursorLeftByWord (void) { - guint16 cursor = 0; - - if (G_UNLIKELY (m_cursor > m_pinyin_len)) { - cursor = m_pinyin_len; - } else { - guint len = 0; - pinyin_get_n_pinyin (m_instance, &len); + size_t offset = 0; - guint pinyin_cursor = getPinyinCursor (); + pinyin_get_pinyin_offset (m_instance, m_cursor, &offset); - PinyinKeyPos *pos = NULL; + size_t cursor = 0; - if (pinyin_cursor < len) { - pinyin_get_pinyin_key_rest (m_instance, pinyin_cursor, &pos); - - pinyin_get_pinyin_key_rest_positions - (m_instance, pos, &cursor, NULL); - } else { - /* at the end of pinyin string. */ - cursor = m_cursor; - } - - /* cursor at the begin of one pinyin */ - g_return_val_if_fail (pinyin_cursor > 0, 0); - if ( cursor == m_cursor) { - pinyin_get_pinyin_key_rest (m_instance, pinyin_cursor - 1, &pos); - - pinyin_get_pinyin_key_rest_positions - (m_instance, pos, &cursor, NULL); - } - } + pinyin_get_left_pinyin_offset(m_instance, offset, &cursor); return cursor; } @@ -542,16 +527,13 @@ guint PhoneticEditor::getCursorRightByWord (void) { - guint16 cursor = 0; + size_t offset = 0; - if (G_UNLIKELY (m_cursor > m_pinyin_len)) { - cursor = m_text.length (); - } else { - guint pinyin_cursor = getPinyinCursor (); - PinyinKeyPos *pos = NULL; - pinyin_get_pinyin_key_rest (m_instance, pinyin_cursor, &pos); - pinyin_get_pinyin_key_rest_positions (m_instance, pos, NULL, &cursor); - } + pinyin_get_pinyin_offset (m_instance, m_cursor, &offset); + + size_t cursor = 0; + + pinyin_get_right_pinyin_offset(m_instance, offset, &cursor); return cursor; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYPPinyinEditor.cc new/ibus-libpinyin-1.7.92/src/PYPPinyinEditor.cc --- old/ibus-libpinyin-1.7.4/src/PYPPinyinEditor.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYPPinyinEditor.cc 2016-08-02 07:42:29.000000000 +0200 @@ -246,16 +246,14 @@ } m_buffer.clear (); - char *tmp = NULL; - pinyin_get_sentence (m_instance, &tmp); - if (tmp) { + char *sentence = NULL; + pinyin_get_sentence (m_instance, &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 */ @@ -266,10 +264,16 @@ /* 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 (); + g_assert (pinyin_get_character_offset(m_instance, sentence, cursor, &offset)); + Editor::updatePreeditText (preedit_text, offset, TRUE); + + if (sentence) + g_free (sentence); } +#if 0 void PinyinEditor::updateAuxiliaryText () { @@ -306,6 +310,7 @@ StaticText aux_text (m_buffer); Editor::updateAuxiliaryText (aux_text, TRUE); } +#endif void PinyinEditor::updateLookupTable () diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYPPinyinEditor.h new/ibus-libpinyin-1.7.92/src/PYPPinyinEditor.h --- old/ibus-libpinyin-1.7.4/src/PYPPinyinEditor.h 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYPPinyinEditor.h 2016-08-02 07:42:29.000000000 +0200 @@ -42,7 +42,7 @@ void commit (); - virtual void updateAuxiliaryText (void); + virtual void updateAuxiliaryText (void) = 0; virtual void updateLookupTable (void); virtual void updatePreeditText (void); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibus-libpinyin-1.7.4/src/PYPPinyinEngine.cc new/ibus-libpinyin-1.7.92/src/PYPPinyinEngine.cc --- old/ibus-libpinyin-1.7.4/src/PYPPinyinEngine.cc 2015-12-17 07:51:46.000000000 +0100 +++ new/ibus-libpinyin-1.7.92/src/PYPPinyinEngine.cc 2016-08-02 07:42:29.000000000 +0200 @@ -187,11 +187,17 @@ break; #ifdef IBUS_BUILD_LUA_EXTENSION case IBUS_i: - // do not enable lua extension when use double pinyin. + // for full pinyin if (PinyinConfig::instance ().doublePinyin ()) break; m_input_mode = MODE_EXTENSION; break; + case IBUS_I: + // for double pinyin + if (!PinyinConfig::instance ().doublePinyin ()) + break; + m_input_mode = MODE_EXTENSION; + break; #endif #ifdef IBUS_BUILD_ENGLISH_INPUT_MODE case IBUS_v: ++++++ ibus-libpinyin-build_lua_5.2.patch ++++++ diff -Nur ibus-libpinyin-1.7.92/lua/lua-plugin.c ibus-libpinyin-1.7.92-new/lua/lua-plugin.c --- ibus-libpinyin-1.7.92/lua/lua-plugin.c 2016-08-02 13:42:29.000000000 +0800 +++ ibus-libpinyin-1.7.92-new/lua/lua-plugin.c 2016-08-11 11:04:29.506431695 +0800 @@ -25,15 +25,13 @@ #include "lua-plugin.h" -#ifndef lua_objlen -#define lua_objlen lua_rawlen -#endif - #if LUA_VERSION_NUM >= 502 /* ugly hack for lua 5.2 */ #define lua_open luaL_newstate +#define lua_objlen lua_rawlen + #endif #define IBUS_ENGINE_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePluginPrivate)) diff -Nur ibus-libpinyin-1.7.92/lua/lua-plugin-init.c ibus-libpinyin-1.7.92-new/lua/lua-plugin-init.c --- ibus-libpinyin-1.7.92/lua/lua-plugin-init.c 2016-08-02 13:42:29.000000000 +0800 +++ ibus-libpinyin-1.7.92-new/lua/lua-plugin-init.c 2016-08-11 11:05:31.866431378 +0800 @@ -26,7 +26,9 @@ #include "lua-plugin.h" -#ifndef lua_objlen +#if LUA_VERSION_NUM >= 502 +/* ugly hack for lua 5.2 */ + #define lua_objlen lua_rawlen #endif
