@@ -173,7 +173,7 @@ void TableState::reset(const InputMethodEntry *entry) {
173
173
174
174
std::unique_ptr<CandidateList>
175
175
TableState::predictCandidateList (const std::vector<std::string> &words) {
176
- if (words.empty ()) {
176
+ if (words.empty () || isComposeTableMode () ) {
177
177
return nullptr ;
178
178
}
179
179
auto candidateList = std::make_unique<CommonCandidateList>();
@@ -239,6 +239,15 @@ bool TableState::isContextEmpty() const {
239
239
return context_->empty ();
240
240
}
241
241
242
+ bool TableState::isComposeTableMode () const {
243
+
244
+ if (!context_) {
245
+ return false ;
246
+ }
247
+
248
+ return *context_->config ().pageSize == 0 ;
249
+ }
250
+
242
251
bool TableState::autoSelectCandidate () const {
243
252
auto candidateList = ic_->inputPanel ().candidateList ();
244
253
if (candidateList && !candidateList->empty ()) {
@@ -249,6 +258,13 @@ bool TableState::autoSelectCandidate() const {
249
258
candidateList->candidate (idx).select (ic_);
250
259
return true ;
251
260
}
261
+ if (isComposeTableMode () && !context_->candidates ().empty ()) {
262
+ // Create a dummy candidate word to reuse the logic in
263
+ // TableCandidateWord::select
264
+ TableCandidateWord candidate (engine_, Text{}, 0 );
265
+ candidate.select (ic_);
266
+ return true ;
267
+ }
252
268
return false ;
253
269
}
254
270
@@ -390,7 +406,7 @@ bool TableState::handlePinyinMode(KeyEvent &event) {
390
406
auto &inputPanel = ic_->inputPanel ();
391
407
ic_->inputPanel ().reset ();
392
408
393
- if (!pinyinModeBuffer_.empty ()) {
409
+ if (!pinyinModeBuffer_.empty () && ! isComposeTableMode () ) {
394
410
const auto &dict = engine_->pinyinDict ();
395
411
const auto &lm = engine_->pinyinModel ();
396
412
auto pinyin = libime::PinyinEncoder::encodeOneUserPinyin (
@@ -878,7 +894,7 @@ void TableState::keyEvent(const InputMethodEntry &entry, KeyEvent &event) {
878
894
event.filterAndAccept ();
879
895
maybePredict = true ;
880
896
}
881
- } else if (!isContextEmpty ()) {
897
+ } else if (!isContextEmpty () && ! isComposeTableMode () ) {
882
898
if (event.key ().check (FcitxKey_Return, KeyState::Shift) ||
883
899
event.key ().check (FcitxKey_KP_Enter, KeyState::Shift)) {
884
900
// This key is used to type long auto select buffer.
@@ -1010,6 +1026,14 @@ void TableState::keyEvent(const InputMethodEntry &entry, KeyEvent &event) {
1010
1026
event.filterAndAccept ();
1011
1027
return ;
1012
1028
}
1029
+
1030
+ if (isComposeTableMode ()) {
1031
+ if (!autoSelectCandidate ()) {
1032
+ commitBuffer (true );
1033
+ needUpdate = true ;
1034
+ }
1035
+ }
1036
+
1013
1037
break ;
1014
1038
}
1015
1039
// if current key will produce some string, select the candidate.
@@ -1027,7 +1051,7 @@ void TableState::keyEvent(const InputMethodEntry &entry, KeyEvent &event) {
1027
1051
auto pushResult =
1028
1052
engine_->punctuation ()->call <IPunctuation::pushPunctuationV2>(
1029
1053
entry.languageCode (), inputContext, chr);
1030
- if (candidates.size () == 1 ) {
1054
+ if (candidates.size () == 1 || isComposeTableMode () ) {
1031
1055
std::tie (punc, puncAfter) = pushResult;
1032
1056
} else if (candidates.size () > 1 ) {
1033
1057
updatePuncCandidate (inputContext, utf8::UCS4ToUTF8 (chr),
@@ -1292,7 +1316,7 @@ void TableState::updateUI(bool keepOldCursor, bool maybePredict) {
1292
1316
auto &inputPanel = ic_->inputPanel ();
1293
1317
if (!context->userInput ().empty ()) {
1294
1318
auto candidates = context->candidates ();
1295
- if (!candidates.empty ()) {
1319
+ if (!candidates.empty () && ! isComposeTableMode () ) {
1296
1320
auto candidateList = std::make_unique<CommonCandidateList>();
1297
1321
size_t idx = 0 ;
1298
1322
candidateList->setLayoutHint (*config.candidateLayoutHint );
0 commit comments