color artist's info loaded from a file

This commit is contained in:
Andrzej Rybczak
2009-01-22 16:08:09 +01:00
parent 1244223919
commit 237e494b08
4 changed files with 29 additions and 0 deletions

View File

@@ -99,6 +99,8 @@ void * GetArtistInfo(void *ptr)
first = 0; first = 0;
} }
input.close(); input.close();
sInfo->SetFormatting(fmtBold, "\n\nSimilar artists:\n", fmtBoldEnd, 0);
sInfo->SetFormatting(Config.color2, "\n * ", clEnd);
artist_info_ready = 1; artist_info_ready = 1;
pthread_exit(NULL); pthread_exit(NULL);
} }

View File

@@ -101,6 +101,11 @@ void Scrollpad::Flush()
itsBuffer.SetTemp(0); itsBuffer.SetTemp(0);
} }
void Scrollpad::SetFormatting(short vb, const std::basic_string<my_char_t> &s, short ve, bool for_each)
{
itsBuffer.SetFormatting(vb, s, ve, for_each);
}
void Scrollpad::Recreate() void Scrollpad::Recreate()
{ {
delwin(itsWindow); delwin(itsWindow);

View File

@@ -32,6 +32,7 @@ class Scrollpad: public Window
virtual ~Scrollpad() { } virtual ~Scrollpad() { }
void Flush(); void Flush();
void SetFormatting(short, const std::basic_string<my_char_t> &, short, bool for_each = 1);
std::basic_string<my_char_t> Content() { return itsBuffer.Str(); } std::basic_string<my_char_t> Content() { return itsBuffer.Str(); }
virtual void Refresh(); virtual void Refresh();
@@ -50,6 +51,7 @@ class Scrollpad: public Window
Scrollpad &operator<<(std::ostream &(*os)(std::ostream &)); Scrollpad &operator<<(std::ostream &(*os)(std::ostream &));
# ifdef _UTF8 # ifdef _UTF8
void SetFormatting(short vb, const std::string &s, short ve, bool for_each = 1) { SetFormatting(vb, ToWString(s), ve, for_each); }
Scrollpad &operator<<(const char *s); Scrollpad &operator<<(const char *s);
Scrollpad &operator<<(const std::string &s); Scrollpad &operator<<(const std::string &s);
# endif // _UTF8 # endif // _UTF8

View File

@@ -47,6 +47,7 @@ template <class C> class basic_buffer
basic_buffer() : itsTempString(0) { } basic_buffer() : itsTempString(0) { }
std::basic_string<C> Str() const; std::basic_string<C> Str() const;
void SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each = 1);
void SetTemp(std::basic_string<C> *); void SetTemp(std::basic_string<C> *);
void Clear(); void Clear();
@@ -72,6 +73,25 @@ template <class C> std::basic_string<C> basic_buffer<C>::Str() const
return itsString.str(); return itsString.str();
} }
template <class C> void basic_buffer<C>::SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each)
{
std::basic_string<C> base = itsString.str();
FormatPos fp;
for (size_t i = base.find(s); i != std::basic_string<C>::npos; i = base.find(s))
{
base[i] = 0;
fp.Value = vb;
fp.Position = i;
itsFormat.push_back(fp);
fp.Value = ve;
fp.Position = i+s.length();
itsFormat.push_back(fp);
if (!for_each)
break;
}
}
template <class C> void basic_buffer<C>::SetTemp(std::basic_string<C> *tmp) template <class C> void basic_buffer<C>::SetTemp(std::basic_string<C> *tmp)
{ {
itsTempString = tmp; itsTempString = tmp;