mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 13:02:35 +00:00
Updated ShortcutsWindow to properly ellipsize contents.
This commit is contained in:
parent
65203c8fbc
commit
a3c7a76b75
@ -70,16 +70,45 @@ void ShortcutsWindow::Repaint() {
|
|||||||
|
|
||||||
WINDOW* c = this->GetContent();
|
WINDOW* c = this->GetContent();
|
||||||
|
|
||||||
for (size_t i = 0; i < this->entries.size(); i++) {
|
size_t remaining = this->GetContentWidth();
|
||||||
|
for (size_t i = 0; i < this->entries.size() && remaining > 0; i++) {
|
||||||
auto e = this->entries[i];
|
auto e = this->entries[i];
|
||||||
int64 keyAttrs = (e->key == this->activeKey) ? activeAttrs : normalAttrs;
|
int64 keyAttrs = (e->key == this->activeKey) ? activeAttrs : normalAttrs;
|
||||||
|
|
||||||
wprintw(c, " ");
|
wprintw(c, " ");
|
||||||
|
--remaining;
|
||||||
|
|
||||||
|
if (remaining == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string key = " " + e->key + " ";
|
||||||
|
std::string value = " " + e->description + " ";
|
||||||
|
|
||||||
|
size_t len = u8cols(key);
|
||||||
|
if (len > remaining) {
|
||||||
|
key = text::Ellipsize(key, remaining);
|
||||||
|
len = remaining;
|
||||||
|
}
|
||||||
|
|
||||||
wattron(c, keyAttrs);
|
wattron(c, keyAttrs);
|
||||||
wprintw(c, " %s ", e->key.c_str());
|
wprintw(c, key.c_str());
|
||||||
wattroff(c, keyAttrs);
|
wattroff(c, keyAttrs);
|
||||||
|
|
||||||
wprintw(c, " %s ", e->description.c_str());
|
remaining -= len;
|
||||||
|
|
||||||
|
if (remaining == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = u8cols(value);
|
||||||
|
if (len > remaining) {
|
||||||
|
value = text::Ellipsize(value, remaining);
|
||||||
|
len = remaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
wprintw(c, value.c_str());
|
||||||
|
|
||||||
|
remaining -= len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user