From 395500aa41d6034e8774edae9d96d6cb809cd32f Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Tue, 2 Apr 2024 01:59:17 -0400 Subject: [PATCH] Use new setComment API for candidate (#94) Co-authored-by: Weng Xuetian --- CMakeLists.txt | 2 +- src/rimecandidate.cpp | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24f4f51..f6f9909 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include(ECMSetupVersion) include(ECMUninstallTarget) find_package(Gettext REQUIRED) -find_package(Fcitx5Core 5.1.7 REQUIRED) +find_package(Fcitx5Core 5.1.9 REQUIRED) find_package(Fcitx5Module REQUIRED COMPONENTS Notifications) find_package(PkgConfig REQUIRED) diff --git a/src/rimecandidate.cpp b/src/rimecandidate.cpp index 607034c..ddc09f2 100644 --- a/src/rimecandidate.cpp +++ b/src/rimecandidate.cpp @@ -19,13 +19,10 @@ RimeCandidateWord::RimeCandidateWord(RimeEngine *engine, const RimeCandidate &candidate, KeySym sym, int idx) : CandidateWord(), engine_(engine), sym_(sym), idx_(idx) { - Text text; - text.append(std::string(candidate.text)); - if (candidate.comment && strlen(candidate.comment)) { - text.append(" "); - text.append(std::string(candidate.comment)); + setText(Text{candidate.text}); + if (candidate.comment && candidate.comment[0]) { + setComment(Text{candidate.comment}); } - setText(text); } void RimeCandidateWord::select(InputContext *inputContext) const { @@ -45,13 +42,10 @@ RimeGlobalCandidateWord::RimeGlobalCandidateWord(RimeEngine *engine, const RimeCandidate &candidate, int idx) : CandidateWord(), engine_(engine), idx_(idx) { - Text text; - text.append(std::string(candidate.text)); - if (candidate.comment && strlen(candidate.comment)) { - text.append(" "); - text.append(std::string(candidate.comment)); + setText(Text{candidate.text}); + if (candidate.comment && candidate.comment[0]) { + setComment(Text{candidate.comment}); } - setText(text); } void RimeGlobalCandidateWord::select(InputContext *inputContext) const {