diff --git a/CMakeLists.txt b/CMakeLists.txt index e96508c..aa85bb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,9 @@ if (NOT DEFINED RIME_TARGET) set(RIME_TARGET PkgConfig::Rime) endif() +if ("${Rime_VERSION}" VERSION_LESS "1.10.0") + add_definitions(-DFCITX_RIME_NO_HIGHLIGHT_CANDIDATE) +endif() if ("${Rime_VERSION}" VERSION_LESS "1.8.0") add_definitions(-DFCITX_RIME_NO_DELETE_CANDIDATE) endif() diff --git a/src/rimecandidate.cpp b/src/rimecandidate.cpp index fc84a03..0c756a3 100644 --- a/src/rimecandidate.cpp +++ b/src/rimecandidate.cpp @@ -75,6 +75,9 @@ RimeCandidateList::RimeCandidateList(RimeEngine *engine, InputContext *ic, setPageable(this); setBulk(this); setActionable(this); +#ifndef FCITX_RIME_NO_HIGHLIGHT_CANDIDATE + setBulkCursor(this); +#endif const auto &menu = context.menu; @@ -187,4 +190,19 @@ void RimeCandidateList::triggerAction(const CandidateWord &candidate, int id) { } } } + +#ifndef FCITX_RIME_NO_HIGHLIGHT_CANDIDATE +int RimeCandidateList::globalCursorIndex() const { + return -1; // No API available. +} + +void RimeCandidateList::setGlobalCursorIndex(int index) { + auto session = engine_->state(ic_)->session(false); + if (!session) { + return; + } + auto *api = engine_->api(); + api->highlight_candidate(session, index); +} +#endif } // namespace fcitx diff --git a/src/rimecandidate.h b/src/rimecandidate.h index 6c96898..a52b87a 100644 --- a/src/rimecandidate.h +++ b/src/rimecandidate.h @@ -52,6 +52,10 @@ class RimeCandidateList final : public CandidateList, , public BulkCandidateList #endif +#ifndef FCITX_RIME_NO_HIGHLIGHT_CANDIDATE + , + public BulkCursorCandidateList +#endif { public: RimeCandidateList(RimeEngine *engine, InputContext *ic, @@ -94,6 +98,11 @@ class RimeCandidateList final : public CandidateList, int totalSize() const override; #endif +#ifndef FCITX_RIME_NO_HIGHLIGHT_CANDIDATE + int globalCursorIndex() const override; + void setGlobalCursorIndex(int index) override; +#endif + bool hasAction(const CandidateWord &candidate) const override; std::vector candidateActions(const CandidateWord &candidate) const override;