diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index f2319c93..7fdf4b70 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -348,7 +348,6 @@ int main(int argc, char *argv[]) wFooter = new Window(0, footer_start_y, COLS, footer_height, "", Config.statusbar_color, brNone); wFooter->SetGetStringHelper(TraceMpdStatus); wFooter->Display(); - wCurrent = mPlaylist; current_screen = csPlaylist; diff --git a/src/scrollpad.cpp b/src/scrollpad.cpp index a926bbb1..c5fcab30 100644 --- a/src/scrollpad.cpp +++ b/src/scrollpad.cpp @@ -57,15 +57,24 @@ void Scrollpad::Add(string str) if (BBEnabled) { - if (s[i] == '[') + if (s[i] == '[' && (s[i+1] == '.' || s[i+1] == '/')) collect = 1; - + if (collect) - tmp += s[i]; - - if (s[i] == ']' || tmp.length() > 10) // the longest bbcode is 10 chars long + { + if (s[i] != '[') + { + tmp += s[i]; + if (tmp.length() > 10) // the longest bbcode is 10 chars long + collect = 0; + } + else + tmp = s[i]; + } + + if (s[i] == ']') collect = 0; - + if (!collect && !tmp.empty()) { if (IsValidColor(TO_STRING(tmp))) diff --git a/src/window.cpp b/src/window.cpp index 37e0a663..35890072 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -270,20 +270,21 @@ void Window::ReadKey() const void Window::Write(int limit, const string &str, bool clrtoeol) { - if (BBEnabled && !str.empty()) + if (BBEnabled) { bool collect = false; string color, tmp; for (string::const_iterator it = str.begin(); it != str.end() && limit > 0; it++) { - if (*it != '[' && !collect) + if (*it == '[' && (*(it+1) == '.' || *(it+1) == '/')) + collect = 1; + + if (!collect) { tmp += *it; limit--; } - else - collect = 1; - + if (collect) { if (*it != '[') @@ -339,13 +340,14 @@ void Window::Write(int limit, const wstring &str, bool clrtoeol) wstring color, tmp; for (wstring::const_iterator it = str.begin(); it != str.end() && limit > 0; it++) { - if (*it != '[' && !collect) + if (*it == '[' && (*(it+1) == '.' || *(it+1) == '/')) + collect = 1; + + if (!collect) { tmp += *it; limit--; } - else - collect = 1; if (collect) { @@ -643,18 +645,16 @@ wstring ToWString(const string &s) string Window::OmitBBCodes(const string &str) { - if (str.empty()) - return ""; bool collect = false; string tmp, color, result; for (string::const_iterator it = str.begin(); it != str.end(); it++) { - if (*it != '[' && !collect) - tmp += *it; - else + if (*it == '[' && (*(it+1) == '.' || *(it+1) == '/')) collect = 1; - if (collect) + if (!collect) + tmp += *it; + else { if (*it != '[') color += *it; @@ -668,7 +668,7 @@ string Window::OmitBBCodes(const string &str) if (*it == ']' || it+1 == str.end()) collect = 0; - if (!collect) + if (!collect && !color.empty()) { result += tmp; tmp.clear();