some fixes for color parser
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -57,13 +57,22 @@ void Scrollpad::Add(string str)
|
||||
|
||||
if (BBEnabled)
|
||||
{
|
||||
if (s[i] == '[')
|
||||
if (s[i] == '[' && (s[i+1] == '.' || s[i+1] == '/'))
|
||||
collect = 1;
|
||||
|
||||
if (collect)
|
||||
{
|
||||
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] == ']' || tmp.length() > 10) // the longest bbcode is 10 chars long
|
||||
if (s[i] == ']')
|
||||
collect = 0;
|
||||
|
||||
if (!collect && !tmp.empty())
|
||||
|
||||
@@ -270,19 +270,20 @@ 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)
|
||||
{
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user