Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package fcitx5-unikey for openSUSE:Factory checked in at 2022-11-15 13:18:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/fcitx5-unikey (Old) and /work/SRC/openSUSE:Factory/.fcitx5-unikey.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "fcitx5-unikey" Tue Nov 15 13:18:38 2022 rev:4 rq:1035667 version:5.0.11 Changes: -------- --- /work/SRC/openSUSE:Factory/fcitx5-unikey/fcitx5-unikey.changes 2022-11-06 12:42:34.761516878 +0100 +++ /work/SRC/openSUSE:Factory/.fcitx5-unikey.new.1597/fcitx5-unikey.changes 2022-11-15 13:21:25.476800493 +0100 @@ -1,0 +2,9 @@ +Mon Nov 14 02:24:33 UTC 2022 - Tranter Madi <tr...@yandex.com> + +- Remove: fix-enter.diff, fix-uou.diff +- Backport fix: + * Add backport-commit-on-switchingIM.diff + * Add backport-rebuild-surrounding-state.diff + * Add backport-allow-uoh.diff + +------------------------------------------------------------------- Old: ---- fix-enter.diff fix-uou.diff New: ---- backport-allow-uoh.diff backport-commit-on-switchingIM.diff backport-rebuild-surrounding-state.diff ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ fcitx5-unikey.spec ++++++ --- /var/tmp/diff_new_pack.5maCoN/_old 2022-11-15 13:21:25.872802537 +0100 +++ /var/tmp/diff_new_pack.5maCoN/_new 2022-11-15 13:21:25.884802599 +0100 @@ -23,10 +23,13 @@ License: GPL-2.0-or-later AND LGPL-2.0-or-later URL: https://github.com/fcitx/fcitx5-unikey Source: https://download.fcitx-im.org/fcitx5/%{name}/%{name}-%{version}.tar.xz -# Backport https://github.com/fcitx/fcitx5-unikey/issues/24 -Patch1: fix-uou.diff -# Backport https://github.com/fcitx/fcitx5-unikey/issues/23 -Patch2: fix-enter.diff +# Backport from git +#e352da5 +Patch1: backport-commit-on-switchingIM.diff +#b5f70ed +Patch2: backport-rebuild-surrounding-state.diff +#0eac455 +Patch3: backport-allow-uoh.diff BuildRequires: cmake BuildRequires: extra-cmake-modules BuildRequires: fcitx5-devel @@ -49,6 +52,7 @@ %setup -q %patch1 -p1 %patch2 -p1 +%patch3 -p1 %build %cmake ++++++ backport-allow-uoh.diff ++++++ diff --git a/unikey/ukengine.cpp b/unikey/ukengine.cpp index e7b6176..4938f03 100644 --- a/unikey/ukengine.cpp +++ b/unikey/ukengine.cpp @@ -1267,10 +1267,13 @@ int UkEngine::processHookWithUO(UkKeyEvent &ev) { default: // vneHookAll, vneHookUO: if (v[0] == vnl_u) { if (v[1] == vnl_o || v[1] == vnl_or) { - // uo -> uo+ if prefixed by "th" + // uo -> uo+ if prefixed by "h", "kh", "th", or stand alone if ((vs == vs_uo || vs == vs_uor) && vEnd == m_current && - m_buffer[m_current].form == vnw_cv && - m_buffer[m_current - 2].cseq == cs_th) { + ((m_buffer[m_current].form == vnw_cv && + (m_buffer[m_current - 2].cseq == cs_h || + m_buffer[m_current - 2].cseq == cs_kh || + m_buffer[m_current - 2].cseq == cs_th)) || + m_buffer[m_current].form == vnw_v)) { newVs = vs_uoh; markChange(vStart + 1); m_buffer[vStart + 1].vnSym = vnl_oh; @@ -1904,6 +1907,7 @@ int UkEngine::processAppend(UkKeyEvent &ev) { //---------------------------------------------------------- int UkEngine::appendVowel(UkKeyEvent &ev) { bool autoCompleted = false; + bool complexEvent = false; m_current++; WordInfo &entry = m_buffer[m_current]; @@ -1956,10 +1960,28 @@ int UkEngine::appendVowel(UkKeyEvent &ev) { case vnw_v: case vnw_cv: vs = prev.vseq; + prevTonePos = (m_current - 1) - (VSeqList[vs].len - 1) + getTonePosition(vs, true); tone = m_buffer[prevTonePos].tone; + // u+o/uo+ + u/i -> u+o+ + u/i + if ((vs == vs_uoh || vs == vs_uho) && + (lowerSym == vnl_i || lowerSym == vnl_u)) { + if (vs == vs_uho) { + markChange(m_current - 1); + prev.vnSym = vnl_oh; + prev.vseq = vs_uhoh; + } else { + markChange(m_current - 2); + m_buffer[m_current - 2].vnSym = vnl_uh; + m_buffer[m_current - 2].vseq = vs_uh; + } + + vs = vs_uhoh; + complexEvent = true; + } + if (lowerSym != canSym && tone != 0) // new sym has a tone, but there's // is already a preceeding tone newVs = vs_nil; @@ -2052,6 +2074,10 @@ int UkEngine::appendVowel(UkKeyEvent &ev) { break; } + if (complexEvent) { + return 1; + } + if (!autoCompleted && (m_pCtrl->charsetId != CONV_CHARSET_UNI_CSTRING) && isalpha(entry.keyCode)) { return 0; ++++++ backport-commit-on-switchingIM.diff ++++++ diff --git a/src/unikey-im.cpp b/src/unikey-im.cpp index 232d686..65dc5cf 100644 --- a/src/unikey-im.cpp +++ b/src/unikey-im.cpp @@ -325,6 +325,10 @@ void UnikeyEngine::activate(const InputMethodEntry &, void UnikeyEngine::deactivate(const InputMethodEntry &entry, InputContextEvent &event) { + if (event.type() == EventType::InputContextSwitchInputMethod) { + auto *state = event.inputContext()->propertyFor(&factory_); + state->commit(); + } reset(entry, event); } ++++++ backport-rebuild-surrounding-state.diff ++++++ diff --git a/src/unikey-im.cpp b/src/unikey-im.cpp index 65dc5cf..b7f9421 100644 --- a/src/unikey-im.cpp +++ b/src/unikey-im.cpp @@ -35,10 +35,7 @@ static const unsigned int Unikey_OC[] = { static constexpr unsigned int NUM_OUTPUTCHARSET = FCITX_ARRAY_SIZE(Unikey_OC); static_assert(NUM_OUTPUTCHARSET == UkConvI18NAnnotation::enumLength); -static const unsigned char WordBreakSyms[] = { - ',', ';', ':', '.', '\"', '\'', '!', '?', ' ', '<', '>', - '=', '+', '-', '*', '/', '\\', '_', '~', '`', '@', '#', - '$', '%', '^', '&', '(', ')', '{', '}', '[', ']', '|'}; +static bool isWordBreakSym(unsigned char c) { return WordBreakSyms.count(c); } static bool isWordAutoCommit(unsigned char c) { static const std::unordered_set<unsigned char> WordAutoCommit = { @@ -49,6 +46,18 @@ static bool isWordAutoCommit(unsigned char c) { return WordAutoCommit.count(c); } +static bool isVniChar(uint32_t c) { + static const std::unordered_set<uint32_t> vniChar = []() { + std::unordered_set<uint32_t> result; + for (int i = 0; i < vnl_lastChar; i++) { + result.insert(UnicodeComposite[i]); + } + return result; + }(); + + return vniChar.count(c); +} + // code from x-unikey, for convert charset that not is XUtf-8 int latinToUtf(unsigned char *dst, const unsigned char *src, int inSize, int *pOutSize) { @@ -145,7 +154,10 @@ public: return; } - if (!*engine_->config().surroundingText) { + // Check if output charset is utf8, otherwise it doesn't make much + // sense. + if (!*engine_->config().surroundingText || + *engine_->config().oc != UkConv::XUTF8) { return; } @@ -157,7 +169,7 @@ public: !ic_->surroundingText().isValid()) { return; } - // We need text before the cursor. + // We need the character before the cursor. const auto &text = ic_->surroundingText().text(); auto cursor = ic_->surroundingText().cursor(); auto length = utf8::lengthValidated(text); @@ -175,22 +187,43 @@ public: lastCharBeforeCursor == utf8::NOT_ENOUGH_SPACE) { return; } + + const auto isValidStateCharacter = [](char c) { + return isWordAutoCommit(c) && !charutils::isdigit(c); + }; + if (std::distance(start, end) != 1 || - !isWordAutoCommit(lastCharBeforeCursor) || - charutils::isdigit(lastCharBeforeCursor)) { + !isValidStateCharacter(lastCharBeforeCursor)) { return; } // Reverse search for word auto commit. // all char for isWordAutoCommit == true would be ascii. - while (start != text.begin() && isWordAutoCommit(*start) && - !charutils::isdigit(lastCharBeforeCursor) && + while (start != text.begin() && isValidStateCharacter(*start) && std::distance(start, end) < MAX_CONTEXT_SIZE) { --start; } + + // The loop will move the character on to an invalid character, if it + // doesn't by pass the start point. Need to add by one to move it to the + // starting point we expect. + if (!isValidStateCharacter(*start)) { + ++start; + } + + assert(isValidStateCharacter(*start) && start >= text.begin()); + + // Check if surrounding is not in a bigger part of word. + if (start != text.begin()) { + auto chr = utf8::getLastChar(text.begin(), start); + if (isVniChar(chr)) { + return; + } + } + FCITX_UNIKEY_DEBUG() - << "Rebuild surrounding with: " - << std::string_view(&*start, std::distance(start, end)); + << "Rebuild surrounding with: \"" + << std::string_view(&*start, std::distance(start, end)) << "\""; for (; start != end; ++start) { uic_.putChar(*start); autoCommit_ = true; @@ -463,11 +496,9 @@ void UnikeyState::preedit(KeyEvent &keyEvent) { // commit string: if need if (!preeditStr_.empty()) { - for (auto wordBreakSym : WordBreakSyms) { - if (wordBreakSym == preeditStr_.back() && wordBreakSym == sym) { - commit(); - return keyEvent.filterAndAccept(); - } + if (preeditStr_.back() == sym && isWordBreakSym(sym)) { + commit(); + return keyEvent.filterAndAccept(); } } // end commit string diff --git a/unikey/inputproc.cpp b/unikey/inputproc.cpp index 1e6db4a..cafa419 100644 --- a/unikey/inputproc.cpp +++ b/unikey/inputproc.cpp @@ -4,7 +4,9 @@ * SPDX-License-Identifier: LGPL-2.0-or-later */ #include "inputproc.h" +#include <array> #include <iostream> +#include <unordered_set> using namespace std; @@ -15,7 +17,7 @@ unsigned char WordBreakSyms[] = { '_', '~', '`', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']'}; */ -unsigned char WordBreakSyms[] = { +const std::unordered_set<unsigned char> WordBreakSyms = { ',', ';', ':', '.', '\"', '\'', '!', '?', ' ', '<', '>', '=', '+', '-', '*', '/', '\\', '_', '@', '#', '$', '%', '&', '(', ')', '{', '}', '[', ']', '|'}; // we excluded ~, `, ^ @@ -155,9 +157,8 @@ void SetupInputClassifierTable() { UkcMap[(unsigned char)'w'] = ukcNonVn; UkcMap[(unsigned char)'W'] = ukcNonVn; - int count = sizeof(WordBreakSyms) / sizeof(unsigned char); - for (i = 0; i < count; i++) - UkcMap[WordBreakSyms[i]] = ukcWordBreak; + for (auto wordBreakSym : WordBreakSyms) + UkcMap[wordBreakSym] = ukcWordBreak; // Calculate IsoVnLexiMap for (i = 0; i < 256; i++) { diff --git a/unikey/inputproc.h b/unikey/inputproc.h index ae52a76..bf1311f 100644 --- a/unikey/inputproc.h +++ b/unikey/inputproc.h @@ -8,6 +8,7 @@ #include "keycons.h" #include "vnlexi.h" +#include <unordered_set> #if defined(_WIN32) #define DllExport __declspec(dllexport) @@ -107,4 +108,6 @@ inline VnLexiName IsoToVnLexi(unsigned int keyCode) { return (keyCode >= 256) ? vnl_nonVnChar : IsoVnLexiMap[keyCode]; } +extern const std::unordered_set<unsigned char> WordBreakSyms; + #endif