fix bug with removing format from artist's info screen

This commit is contained in:
Andrzej Rybczak
2009-05-10 02:09:21 +02:00
parent ec5a4bb3c2
commit da13e93df0
3 changed files with 17 additions and 9 deletions

View File

@@ -188,6 +188,8 @@ void Info::GetArtist()
input.close();
w->SetFormatting(fmtBold, "\n\nSimilar artists:\n", fmtBoldEnd, 0);
w->SetFormatting(Config.color2, "\n * ", clEnd);
// below is used so format won't be removed using RemoveFormatting() by accident.
w->ForgetFormatting();
w->Flush();
}
else

View File

@@ -33,8 +33,8 @@ Scrollpad::Scrollpad(size_t startx,
: Window(startx, starty, width, height, title, color, border),
itsBeginning(0),
itsFoundForEach(0),
itsFoundValueBegin(0),
itsFoundValueEnd(0),
itsFoundValueBegin(-1),
itsFoundValueEnd(-1),
itsRealHeight(1)
{
}
@@ -114,17 +114,21 @@ bool Scrollpad::SetFormatting(short vb, const std::basic_string<my_char_t> &s, s
itsFoundPattern = s;
}
else
ForgetFormatting();
return result;
}
void Scrollpad::ForgetFormatting()
{
itsFoundForEach = 0;
itsFoundValueBegin = 0;
itsFoundValueEnd = 0;
itsFoundValueBegin = -1;
itsFoundValueEnd = -1;
itsFoundPattern.clear();
}
return result;
}
void Scrollpad::RemoveFormatting()
{
if (itsFoundValueBegin >= 0 && itsFoundValueEnd >= 0)
itsBuffer.RemoveFormatting(itsFoundValueBegin, itsFoundPattern, itsFoundValueEnd, itsFoundForEach);
}
@@ -205,6 +209,7 @@ void Scrollpad::Clear(bool clrscr)
itsWindow = newpad(itsHeight, itsWidth);
SetTimeout(itsWindowTimeout);
SetColor(itsColor, itsBgColor);
ForgetFormatting();
keypad(itsWindow, 1);
if (clrscr)
Refresh();

View File

@@ -35,6 +35,7 @@ namespace NCurses
void Flush();
bool SetFormatting(short, const std::basic_string<my_char_t> &, short, bool for_each = 1);
void ForgetFormatting();
void RemoveFormatting();
std::basic_string<my_char_t> Content() { return itsBuffer.Str(); }