fix(input): add sliding-window multi-tap candidate bar and input tail-scrolling across plugins and fcitx5-t9
This commit is contained in:
1 parent
a53a331111
commit
1f9138f0c6
24 files changed
+394
-125
No files matched your search
+27
-11
@@ -975,18 +975,23 @@ void T9State::showPreview(const std::vector<T9Item>& items, int index) {
|
||||
if (total == 0) {
|
||||
return;
|
||||
}
|
||||
index = std::clamp(index, 0, total - 1);
|
||||
constexpr int kMaxItemsPerPage = 7;
|
||||
std::string prefix = modePrefix() + ":";
|
||||
size_t maxItemsWidth =
|
||||
(kFixedPreeditChars > prefix.size() + 1)
|
||||
? (kFixedPreeditChars - prefix.size() - 1)
|
||||
: 23;
|
||||
(kFixedPreeditChars > prefix.size() + 2)
|
||||
? (kFixedPreeditChars - prefix.size() - 2)
|
||||
: 21;
|
||||
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
while (start < total) {
|
||||
size_t width = 0;
|
||||
int count = 0;
|
||||
int halfWin = kMaxItemsPerPage / 2;
|
||||
int start = std::max(0, index - halfWin);
|
||||
int end = start;
|
||||
size_t width = 0;
|
||||
int count = 0;
|
||||
|
||||
while (start <= index) {
|
||||
width = 0;
|
||||
count = 0;
|
||||
end = start;
|
||||
while (end < total && count < kMaxItemsPerPage) {
|
||||
size_t itemWidth = items[end].label.size() + 2;
|
||||
@@ -1000,10 +1005,21 @@ void T9State::showPreview(const std::vector<T9Item>& items, int index) {
|
||||
if (index < end) {
|
||||
break;
|
||||
}
|
||||
start = end;
|
||||
++start;
|
||||
}
|
||||
|
||||
while (start > 0 && count < kMaxItemsPerPage) {
|
||||
size_t itemWidth = items[start - 1].label.size() + 2;
|
||||
if (width + itemWidth > maxItemsWidth) {
|
||||
break;
|
||||
}
|
||||
--start;
|
||||
width += itemWidth;
|
||||
++count;
|
||||
}
|
||||
|
||||
std::string preedit = prefix;
|
||||
preedit += (start > 0) ? "<" : " ";
|
||||
for (int i = start; i < end; ++i) {
|
||||
if (i == index) {
|
||||
preedit += "[";
|
||||
@@ -1015,8 +1031,8 @@ void T9State::showPreview(const std::vector<T9Item>& items, int index) {
|
||||
preedit += " ";
|
||||
}
|
||||
}
|
||||
if (start > 0 || end < total) {
|
||||
preedit += (end < total) ? ">" : "<";
|
||||
if (end < total) {
|
||||
preedit += ">";
|
||||
}
|
||||
if (preedit.size() < kFixedPreeditChars) {
|
||||
preedit.append(kFixedPreeditChars - preedit.size(), ' ');
|
||||
|
||||
Reference in new issue
Block a user