From d73113f06856114e603c8aef9cacf5c985bf2214 Mon Sep 17 00:00:00 2001 From: casey Date: Thu, 14 Jul 2016 07:55:45 -0700 Subject: [PATCH] A couple small tweaks to the ellipsizing algorithm in TransportWindow. --- src/musikbox/app/window/TransportWindow.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/musikbox/app/window/TransportWindow.cpp b/src/musikbox/app/window/TransportWindow.cpp index 9b2c263d8..2e8ae9897 100755 --- a/src/musikbox/app/window/TransportWindow.cpp +++ b/src/musikbox/app/window/TransportWindow.cpp @@ -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 */