Skip to content

Commit 5ce5622

Browse files
committed
Configurable when to show annotation
1 parent facf82c commit 5ce5622

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.13)
22
cmake_policy(SET CMP0063 NEW)
3-
project(fcitx5-cskk VERSION 1.0.0)
3+
project(fcitx5-cskk VERSION 1.1.0)
44
set(CMAKE_CXX_FLAGS "-Wall")
55
set(CMAKE_CXX_STANDARD 17)
66
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

src/cskk.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ void FcitxCskkContext::updateUI() {
339339
CSKK_WARN() << "No context setup";
340340
return;
341341
}
342+
auto &config = engine_->config();
342343
auto &inputPanel = ic_->inputPanel();
343344

344345
// Output
@@ -359,7 +360,8 @@ void FcitxCskkContext::updateUI() {
359360
// CandidateList
360361
int currentCursorPosition =
361362
skk_context_get_current_candidate_cursor_position(context_);
362-
if (currentCursorPosition > engine_->config().pageStartIdx.value() - 1) {
363+
bool showCandidateList = currentCursorPosition > engine_->config().pageStartIdx.value() - 1;
364+
if (showCandidateList) {
363365
char *current_to_composite = skk_context_get_current_to_composite(context_);
364366
auto currentCandidateList =
365367
std::dynamic_pointer_cast<FcitxCskkCandidateList>(
@@ -383,7 +385,10 @@ void FcitxCskkContext::updateUI() {
383385

384386
if (ic_->capabilityFlags().test(CapabilityFlag::Preedit)) {
385387
inputPanel.setClientPreedit(mainPreedit);
386-
inputPanel.setPreedit(supplementPreedit);
388+
if ((config.showAnnotationCondition.value() == ShowAnnotationCondition::Always) ||
389+
(config.showAnnotationCondition.value() == ShowAnnotationCondition::SingleCandidate && !showCandidateList)) {
390+
inputPanel.setPreedit(supplementPreedit);
391+
}
387392
ic_->updatePreedit();
388393
} else {
389394
inputPanel.setPreedit(mainPreedit);

src/cskkconfig.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ FCITX_CONFIG_ENUM_NAME_WITH_I18N(CandidateLayoutHint, N_("Not set"),
3636
N_("Vertical"), N_("Horizontal"));
3737

3838
FCITX_CONFIG_ENUM(CandidateSelectionKeys, Number, ABCD, QwertyCenter)
39+
40+
enum class ShowAnnotationCondition {
41+
Always, SingleCandidate, Never
42+
};
43+
FCITX_CONFIG_ENUM_NAME_WITH_I18N(ShowAnnotationCondition, N_("Always"),
44+
N_("SingleCandidate"), N_("Never"));
45+
3946
static constexpr const char *CandidateSelectionKeys_Annotations[] = {
4047
"Number (1,2,3,...)", "ABCD (a,b,c,d,...)",
4148
"Qwerty Center row (a,s,d,f,...)"};
42-
4349
struct CandidateSelectionKeysAnnotation : public EnumAnnotation {
4450
void dumpDescription(RawConfig &config) const {
4551
EnumAnnotation::dumpDescription(config);
@@ -132,10 +138,13 @@ FCITX_CONFIGURATION(
132138
candidateSelectionKeys{this, "Candidate selection keys",
133139
_("Candidate selection keys"),
134140
CandidateSelectionKeys::Number};
141+
OptionWithAnnotation<ShowAnnotationCondition,
142+
ShowAnnotationConditionI18NAnnotation>
143+
showAnnotationCondition{this, "Show Annotation when",
144+
_("Show Annotation when"),
145+
ShowAnnotationCondition::Always};
135146
ExternalOption dictionary{this, "Dictionary", _("Dictionary"),
136147
"fcitx://config/addon/cskk/dictionary_list"};
137-
// Option<bool> showAnnotation{this, "ShowAnnotation",
138-
// _("Show Annotation. Fake yet."), true};);
139148
) // FCITX_CONFIGURATION
140149
} // namespace fcitx
141150
#endif // FCITX5_CSKK_CSKKCONFIG_H

0 commit comments

Comments
 (0)