fix(input): add sliding-window multi-tap candidate bar and input tail-scrolling across plugins and fcitx5-t9

This commit is contained in:
Luxferre committed 2026-10-26 17:37:53 +02:00
1 parent a53a331111
commit 1f9138f0c6
24 files changed
+394 -125

No files matched your search

+33 -17
View File
@@ -42,16 +42,16 @@ enum class TextCaseMode {
};
const char* kMultiTapLower[10] = {
" 0+", // 0
".,-@_1", // 1
"abc2", // 2
"def3", // 3
"ghi4", // 4
"jkl5", // 5
"mno6", // 6
"pqrs7", // 7
"tuv8", // 8
"wxyz9" // 9
" 0+", // 0
kMultiTapPunct1, // 1
"abc2", // 2
"def3", // 3
"ghi4", // 4
"jkl5", // 5
"mno6", // 6
"pqrs7", // 7
"tuv8", // 8
"wxyz9" // 9
};
int runContactsApp(int argc, char** argv) {
@@ -527,14 +527,15 @@ int runContactsApp(int argc, char** argv) {
modeBadge);
// Field 0: Name box (y = 44..108)
auto drawFieldBox = [&](int y, int h, bool active, const char* label,
auto drawFieldBox = [&](int y, int h, bool active,
const std::string& label,
const std::string& val, const char* placeholder) {
XSetForeground(dpy, gc, active ? theme.spec.bgInputFocus : theme.spec.bgButton);
XFillRectangle(dpy, pix, gc, 6, y, kWinWidth - 12, h);
XSetForeground(dpy, gc, active ? theme.spec.accent : theme.spec.border);
XDrawRectangle(dpy, pix, gc, 6, y, kWinWidth - 13, h - 1);
drawPango(layoutSmall, active ? &colYellow : &colMuted, 12, y + 3, 18,
label);
label, 214);
std::string shown = val;
if (active) {
shown.push_back('|');
@@ -542,14 +543,19 @@ int runContactsApp(int argc, char** argv) {
if (val.empty() && !active) {
drawPango(layoutMain, &colMuted, 12, y + 23, 28, placeholder, 214);
} else {
if (shown.size() > 21) {
shown = ".." + shown.substr(shown.size() - 19);
}
shown = tailFitPangoText(layoutMain, shown, 214);
drawPango(layoutMain, &colWhite, 12, y + 23, 28, shown, 214);
}
};
drawFieldBox(44, 56, editField == 0, "Name (# Input mode):", editName,
std::string nameHdr = "Name (# Input mode):";
if (editField == 0 && lastTapDigit >= 0 && lastTapDigit <= 9 &&
(nowMs() - lastTapMs) <= 850) {
nameHdr = formatMultiTapBar(
std::to_string(lastTapDigit) + ":", kMultiTapLower[lastTapDigit],
lastTapCycle, caseMode == TextCaseMode::Upper);
}
drawFieldBox(44, 56, editField == 0, nameHdr, editName,
"Type name on keypad...");
drawFieldBox(106, 56, editField == 1,
"Number (Hold 0 for +):", editNumber, "Enter phone number...");
@@ -863,7 +869,7 @@ int runContactsApp(int argc, char** argv) {
}
const char* seq = kMultiTapLower[digit];
int seqLen = static_cast<int>(std::strlen(seq));
if (digit == lastTapDigit && (now - lastTapMs) <= 650 && !editName.empty()) {
if (digit == lastTapDigit && (now - lastTapMs) <= 850 && !editName.empty()) {
lastTapCycle = (lastTapCycle + 1) % seqLen;
char ch = seq[lastTapCycle];
bool makeUpper = false;
@@ -1751,6 +1757,12 @@ int runContactsApp(int argc, char** argv) {
}
}
if (visible && mode == ViewMode::Edit && lastTapDigit != -1 &&
(nowMs() - lastTapMs) > 850) {
lastTapDigit = -1;
render();
}
int timeoutMs = -1;
if (visible) {
timeoutMs = 200;
@@ -1762,6 +1774,10 @@ int runContactsApp(int argc, char** argv) {
int64_t rem = 420 - (nowMs() - zeroPressMs);
timeoutMs = std::min(timeoutMs, static_cast<int>(std::max<int64_t>(5, rem)));
}
if (mode == ViewMode::Edit && lastTapDigit != -1) {
int64_t rem = 851 - (nowMs() - lastTapMs);
timeoutMs = std::min(timeoutMs, static_cast<int>(std::max<int64_t>(5, rem)));
}
}
struct pollfd pfds[2] {};