A couple small tweaks to the ellipsizing algorithm in TransportWindow.

This commit is contained in:
casey 2016-07-14 07:55:45 -07:00 committed by Casey Langen
parent 1a7ba93e0a
commit d73113f068

View File

@ -170,11 +170,24 @@ size_t writePlayingFormat(
}
size_t len = u8cols(value);
bool ellipsized = false;
if (len > remaining) {
std::string original = value;
value = text::Ellipsize(value, remaining);
ellipsized = (value != original);
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);
wprintw(w, value.c_str());
OFF(w, attr);
@ -289,10 +302,10 @@ void TransportWindow::Update() {
}
wmove(c, 0, cx - shuffleLabelLen);
int64 shuffleAttrs = this->playback.IsShuffled() ? gb : disabled;
ON(c, shuffleAttrs);
int64 shuffleAttrs = this->playback.IsShuffled() ? gb : disabled;
ON(c, shuffleAttrs);
wprintw(c, shuffleLabel.c_str());
OFF(c, shuffleAttrs);
OFF(c, shuffleAttrs);
wmove(c, 1, 0); /* move cursor to the second line */