mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-23 09:40:59 +00:00
A couple small tweaks to the ellipsizing algorithm in TransportWindow.
This commit is contained in:
parent
1a7ba93e0a
commit
d73113f068
@ -170,11 +170,24 @@ size_t writePlayingFormat(
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t len = u8cols(value);
|
size_t len = u8cols(value);
|
||||||
|
bool ellipsized = false;
|
||||||
|
|
||||||
if (len > remaining) {
|
if (len > remaining) {
|
||||||
|
std::string original = value;
|
||||||
value = text::Ellipsize(value, remaining);
|
value = text::Ellipsize(value, remaining);
|
||||||
|
ellipsized = (value != original);
|
||||||
len = remaining;
|
len = remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if we're not at the last token, but there's not enough space
|
||||||
|
to show the next token, ellipsize now and bail out of the loop */
|
||||||
|
if (remaining - len < 3) {
|
||||||
|
if (!ellipsized) {
|
||||||
|
value = text::Ellipsize(value, remaining - 3);
|
||||||
|
len = remaining;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ON(w, attr);
|
ON(w, attr);
|
||||||
wprintw(w, value.c_str());
|
wprintw(w, value.c_str());
|
||||||
OFF(w, attr);
|
OFF(w, attr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user