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 = new Window(0, footer_start_y, COLS, footer_height, "", Config.statusbar_color, brNone);
|
||||||
wFooter->SetGetStringHelper(TraceMpdStatus);
|
wFooter->SetGetStringHelper(TraceMpdStatus);
|
||||||
wFooter->Display();
|
wFooter->Display();
|
||||||
|
|
||||||
wCurrent = mPlaylist;
|
wCurrent = mPlaylist;
|
||||||
current_screen = csPlaylist;
|
current_screen = csPlaylist;
|
||||||
|
|
||||||
|
|||||||
@@ -57,13 +57,22 @@ void Scrollpad::Add(string str)
|
|||||||
|
|
||||||
if (BBEnabled)
|
if (BBEnabled)
|
||||||
{
|
{
|
||||||
if (s[i] == '[')
|
if (s[i] == '[' && (s[i+1] == '.' || s[i+1] == '/'))
|
||||||
collect = 1;
|
collect = 1;
|
||||||
|
|
||||||
if (collect)
|
if (collect)
|
||||||
tmp += s[i];
|
{
|
||||||
|
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;
|
collect = 0;
|
||||||
|
|
||||||
if (!collect && !tmp.empty())
|
if (!collect && !tmp.empty())
|
||||||
|
|||||||
@@ -270,19 +270,20 @@ void Window::ReadKey() const
|
|||||||
|
|
||||||
void Window::Write(int limit, const string &str, bool clrtoeol)
|
void Window::Write(int limit, const string &str, bool clrtoeol)
|
||||||
{
|
{
|
||||||
if (BBEnabled && !str.empty())
|
if (BBEnabled)
|
||||||
{
|
{
|
||||||
bool collect = false;
|
bool collect = false;
|
||||||
string color, tmp;
|
string color, tmp;
|
||||||
for (string::const_iterator it = str.begin(); it != str.end() && limit > 0; it++)
|
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;
|
tmp += *it;
|
||||||
limit--;
|
limit--;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
collect = 1;
|
|
||||||
|
|
||||||
if (collect)
|
if (collect)
|
||||||
{
|
{
|
||||||
@@ -339,13 +340,14 @@ void Window::Write(int limit, const wstring &str, bool clrtoeol)
|
|||||||
wstring color, tmp;
|
wstring color, tmp;
|
||||||
for (wstring::const_iterator it = str.begin(); it != str.end() && limit > 0; it++)
|
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;
|
tmp += *it;
|
||||||
limit--;
|
limit--;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
collect = 1;
|
|
||||||
|
|
||||||
if (collect)
|
if (collect)
|
||||||
{
|
{
|
||||||
@@ -643,18 +645,16 @@ wstring ToWString(const string &s)
|
|||||||
|
|
||||||
string Window::OmitBBCodes(const string &str)
|
string Window::OmitBBCodes(const string &str)
|
||||||
{
|
{
|
||||||
if (str.empty())
|
|
||||||
return "";
|
|
||||||
bool collect = false;
|
bool collect = false;
|
||||||
string tmp, color, result;
|
string tmp, color, result;
|
||||||
for (string::const_iterator it = str.begin(); it != str.end(); it++)
|
for (string::const_iterator it = str.begin(); it != str.end(); it++)
|
||||||
{
|
{
|
||||||
if (*it != '[' && !collect)
|
if (*it == '[' && (*(it+1) == '.' || *(it+1) == '/'))
|
||||||
tmp += *it;
|
|
||||||
else
|
|
||||||
collect = 1;
|
collect = 1;
|
||||||
|
|
||||||
if (collect)
|
if (!collect)
|
||||||
|
tmp += *it;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (*it != '[')
|
if (*it != '[')
|
||||||
color += *it;
|
color += *it;
|
||||||
@@ -668,7 +668,7 @@ string Window::OmitBBCodes(const string &str)
|
|||||||
if (*it == ']' || it+1 == str.end())
|
if (*it == ']' || it+1 == str.end())
|
||||||
collect = 0;
|
collect = 0;
|
||||||
|
|
||||||
if (!collect)
|
if (!collect && !color.empty())
|
||||||
{
|
{
|
||||||
result += tmp;
|
result += tmp;
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user