scrollpad: use std::string as container
This commit is contained in:
@@ -1971,7 +1971,7 @@ void Find::Run()
|
||||
Statusbar::msg("Searching...");
|
||||
auto s = static_cast<Screen<NC::Scrollpad> *>(myScreen);
|
||||
s->main().removeProperties();
|
||||
Statusbar::msg("%s", findme.empty() || s->main().setProperties(NC::fmtReverse, ToWString(findme), NC::fmtReverseEnd) ? "Done" : "No matching patterns found");
|
||||
Statusbar::msg("%s", findme.empty() || s->main().setProperties(NC::fmtReverse, findme, NC::fmtReverseEnd) ? "Done" : "No matching patterns found");
|
||||
s->main().flush();
|
||||
}
|
||||
|
||||
|
||||
12
src/help.cpp
12
src/help.cpp
@@ -144,25 +144,25 @@ std::string Help::DisplayKeys(const ActionType at)
|
||||
|
||||
void Help::Section(const char *type_, const char *title_)
|
||||
{
|
||||
w << L"\n " << NC::fmtBold << ToWString(type_) << L" - ";
|
||||
w << ToWString(title_) << NC::fmtBoldEnd << L"\n\n";
|
||||
w << "\n " << NC::fmtBold << type_ << " - ";
|
||||
w << title_ << NC::fmtBoldEnd << "\n\n";
|
||||
}
|
||||
|
||||
void Help::KeyDesc(const ActionType at, const char *desc)
|
||||
{
|
||||
w << L" " << DisplayKeys(at) << L" : " << ToWString(desc) << '\n';
|
||||
w << " " << DisplayKeys(at) << " : " << desc << '\n';
|
||||
}
|
||||
|
||||
void Help::MouseDesc(std::string action, const char *desc, bool indent)
|
||||
{
|
||||
action.resize(31 - (indent ? 2 : 0), ' ');
|
||||
w << L" " << (indent ? L" " : L"") << ToWString(action);
|
||||
w << L": " << ToWString(desc) << '\n';
|
||||
w << " " << (indent ? " " : "") << action;
|
||||
w << ": " << desc << '\n';
|
||||
}
|
||||
|
||||
void Help::MouseColumn(const char *column)
|
||||
{
|
||||
w << NC::fmtBold << L" " << ToWString(column) << L" column:\n" << NC::fmtBoldEnd;
|
||||
w << NC::fmtBold << " " << column << " column:\n" << NC::fmtBoldEnd;
|
||||
}
|
||||
|
||||
void Help::GetKeybindings()
|
||||
|
||||
@@ -343,9 +343,6 @@ template <typename T> struct StringConverter {
|
||||
template <> struct StringConverter<NC::WBuffer> {
|
||||
std::wstring operator()(const char *s) { return ToWString(s); }
|
||||
};
|
||||
template <> struct StringConverter<NC::Scrollpad> {
|
||||
std::wstring operator()(const char *s) { return ToWString(s); }
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
void stringToBuffer(Iterator first, Iterator last, NC::BasicBuffer<typename Iterator::value_type> &buf)
|
||||
|
||||
@@ -139,7 +139,7 @@ void Lastfm::Load()
|
||||
}
|
||||
else
|
||||
{
|
||||
w << L"Fetching informations... ";
|
||||
w << "Fetching informations... ";
|
||||
pthread_create(&itsDownloader, 0, DownloadWrapper, this);
|
||||
isDownloadInProgress = 1;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ bool ArtistInfo::checkArgs(const Args &args)
|
||||
|
||||
void ArtistInfo::colorizeOutput(NC::Scrollpad &w)
|
||||
{
|
||||
w.setProperties(NC::fmtBold, L"\n\nSimilar artists:\n", NC::fmtBoldEnd, 0);
|
||||
w.setProperties(Config.color2, L"\n * ", NC::clEnd, 0);
|
||||
w.setProperties(NC::fmtBold, "\n\nSimilar artists:\n", NC::fmtBoldEnd, 0);
|
||||
w.setProperties(Config.color2, "\n * ", NC::clEnd, 0);
|
||||
}
|
||||
|
||||
bool ArtistInfo::parse(std::string &data)
|
||||
|
||||
@@ -235,10 +235,10 @@ void *Lyrics::Download()
|
||||
bool fetcher_defined = itsFetcher && *itsFetcher;
|
||||
for (LyricsFetcher **plugin = fetcher_defined ? itsFetcher : lyricsPlugins; *plugin != 0; ++plugin)
|
||||
{
|
||||
w << L"Fetching lyrics from " << NC::fmtBold << ToWString((*plugin)->name()) << NC::fmtBoldEnd << L"... ";
|
||||
w << "Fetching lyrics from " << NC::fmtBold << (*plugin)->name() << NC::fmtBoldEnd << "... ";
|
||||
result = (*plugin)->fetch(artist, title_);
|
||||
if (result.first == false)
|
||||
w << NC::clRed << ToWString(result.second) << NC::clEnd << '\n';
|
||||
w << NC::clRed << result.second << NC::clEnd << '\n';
|
||||
else
|
||||
break;
|
||||
if (fetcher_defined)
|
||||
@@ -252,7 +252,7 @@ void *Lyrics::Download()
|
||||
w << Charset::utf8ToLocale(result.second);
|
||||
}
|
||||
else
|
||||
w << '\n' << L"Lyrics weren't found.";
|
||||
w << '\n' << "Lyrics weren't found.";
|
||||
|
||||
isReadyToTake = 1;
|
||||
pthread_exit(0);
|
||||
|
||||
@@ -231,10 +231,4 @@ void Scrollpad::reset()
|
||||
m_beginning = 0;
|
||||
}
|
||||
|
||||
Scrollpad &Scrollpad::operator<<(const std::string &s)
|
||||
{
|
||||
m_buffer << ToWString(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ struct Scrollpad: public Window
|
||||
Scrollpad(size_t startx, size_t starty, size_t width, size_t height,
|
||||
const std::string &title, Color color, Border border);
|
||||
|
||||
const std::wstring &buffer() { return m_buffer.str(); }
|
||||
const std::string &buffer() { return m_buffer.str(); }
|
||||
|
||||
void flush();
|
||||
void reset();
|
||||
|
||||
template <typename PropertyT>
|
||||
bool setProperties(PropertyT begin, const std::wstring &ws, PropertyT end, size_t id = -2)
|
||||
bool setProperties(PropertyT begin, const std::string &ws, PropertyT end, size_t id = -2)
|
||||
{
|
||||
bool success = false;
|
||||
for (size_t i = 0; (i = m_buffer.str().find(ws, i)) != std::string::npos;)
|
||||
@@ -66,10 +66,9 @@ struct Scrollpad: public Window
|
||||
m_buffer << obj;
|
||||
return *this;
|
||||
}
|
||||
Scrollpad &operator<<(const std::string &s);
|
||||
|
||||
private:
|
||||
WBuffer m_buffer;
|
||||
Buffer m_buffer;
|
||||
|
||||
size_t m_beginning;
|
||||
size_t m_real_height;
|
||||
|
||||
@@ -84,28 +84,28 @@ void ServerInfo::update()
|
||||
|
||||
w.clear();
|
||||
|
||||
w << NC::fmtBold << L"Version: " << NC::fmtBoldEnd << L"0." << Mpd.Version() << L".*\n";
|
||||
w << NC::fmtBold << L"Uptime: " << NC::fmtBoldEnd;
|
||||
w << NC::fmtBold << "Version: " << NC::fmtBoldEnd << "0." << Mpd.Version() << ".*\n";
|
||||
w << NC::fmtBold << "Uptime: " << NC::fmtBoldEnd;
|
||||
ShowTime(w, stats.uptime(), 1);
|
||||
w << '\n';
|
||||
w << NC::fmtBold << L"Time playing: " << NC::fmtBoldEnd << MPD::Song::ShowTime(stats.playTime()) << '\n';
|
||||
w << NC::fmtBold << "Time playing: " << NC::fmtBoldEnd << MPD::Song::ShowTime(stats.playTime()) << '\n';
|
||||
w << '\n';
|
||||
w << NC::fmtBold << L"Total playtime: " << NC::fmtBoldEnd;
|
||||
w << NC::fmtBold << "Total playtime: " << NC::fmtBoldEnd;
|
||||
ShowTime(w, stats.dbPlayTime(), 1);
|
||||
w << '\n';
|
||||
w << NC::fmtBold << L"Artist names: " << NC::fmtBoldEnd << stats.artists() << '\n';
|
||||
w << NC::fmtBold << L"Album names: " << NC::fmtBoldEnd << stats.albums() << '\n';
|
||||
w << NC::fmtBold << L"Songs in database: " << NC::fmtBoldEnd << stats.songs() << '\n';
|
||||
w << NC::fmtBold << "Artist names: " << NC::fmtBoldEnd << stats.artists() << '\n';
|
||||
w << NC::fmtBold << "Album names: " << NC::fmtBoldEnd << stats.albums() << '\n';
|
||||
w << NC::fmtBold << "Songs in database: " << NC::fmtBoldEnd << stats.songs() << '\n';
|
||||
w << '\n';
|
||||
w << NC::fmtBold << L"Last DB update: " << NC::fmtBoldEnd << Timestamp(stats.dbUpdateTime()) << '\n';
|
||||
w << NC::fmtBold << "Last DB update: " << NC::fmtBoldEnd << Timestamp(stats.dbUpdateTime()) << '\n';
|
||||
w << '\n';
|
||||
w << NC::fmtBold << L"URL Handlers:" << NC::fmtBoldEnd;
|
||||
w << NC::fmtBold << "URL Handlers:" << NC::fmtBoldEnd;
|
||||
for (auto it = itsURLHandlers.begin(); it != itsURLHandlers.end(); ++it)
|
||||
w << (it != itsURLHandlers.begin() ? L", " : L" ") << *it;
|
||||
w << L"\n\n";
|
||||
w << NC::fmtBold << L"Tag Types:" << NC::fmtBoldEnd;
|
||||
w << (it != itsURLHandlers.begin() ? ", " : " ") << *it;
|
||||
w << "\n\n";
|
||||
w << NC::fmtBold << "Tag Types:" << NC::fmtBoldEnd;
|
||||
for (auto it = itsTagTypes.begin(); it != itsTagTypes.end(); ++it)
|
||||
w << (it != itsTagTypes.begin() ? L", " : L" ") << *it;
|
||||
w << (it != itsTagTypes.begin() ? ", " : " ") << *it;
|
||||
|
||||
w.flush();
|
||||
w.refresh();
|
||||
|
||||
@@ -101,24 +101,24 @@ void SongInfo::PrepareSong(MPD::Song &s)
|
||||
TagLib::FileRef f(path_to_file.c_str());
|
||||
# endif // HAVE_TAGLIB_H
|
||||
|
||||
w << NC::fmtBold << Config.color1 << L"Filename: " << NC::fmtBoldEnd << Config.color2 << s.getName() << '\n' << NC::clEnd;
|
||||
w << NC::fmtBold << L"Directory: " << NC::fmtBoldEnd << Config.color2;
|
||||
w << NC::fmtBold << Config.color1 << "Filename: " << NC::fmtBoldEnd << Config.color2 << s.getName() << '\n' << NC::clEnd;
|
||||
w << NC::fmtBold << "Directory: " << NC::fmtBoldEnd << Config.color2;
|
||||
ShowTag(w, s.getDirectory());
|
||||
w << L"\n\n" << NC::clEnd;
|
||||
w << NC::fmtBold << L"Length: " << NC::fmtBoldEnd << Config.color2 << s.getLength() << '\n' << NC::clEnd;
|
||||
w << "\n\n" << NC::clEnd;
|
||||
w << NC::fmtBold << "Length: " << NC::fmtBoldEnd << Config.color2 << s.getLength() << '\n' << NC::clEnd;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (!f.isNull())
|
||||
{
|
||||
w << NC::fmtBold << L"Bitrate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << L" kbps\n" << NC::clEnd;
|
||||
w << NC::fmtBold << L"Sample rate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << L" Hz\n" << NC::clEnd;
|
||||
w << NC::fmtBold << L"Channels: " << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? L"Mono" : L"Stereo") << '\n' << NC::clDefault;
|
||||
w << NC::fmtBold << "Bitrate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps\n" << NC::clEnd;
|
||||
w << NC::fmtBold << "Sample rate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz\n" << NC::clEnd;
|
||||
w << NC::fmtBold << "Channels: " << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << '\n' << NC::clDefault;
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
w << NC::clDefault;
|
||||
|
||||
for (const Metadata *m = Tags; m->Name; ++m)
|
||||
{
|
||||
w << NC::fmtBold << '\n' << ToWString(m->Name) << L": " << NC::fmtBoldEnd;
|
||||
w << NC::fmtBold << '\n' << m->Name << ": " << NC::fmtBoldEnd;
|
||||
ShowTag(w, s.getTags(m->Get, Config.tags_separator));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,18 +140,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
BasicBuffer<CharT> &operator<<(char c)
|
||||
BasicBuffer<CharT> &operator<<(CharT c)
|
||||
{
|
||||
m_string += c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BasicBuffer<CharT> &operator<<(wchar_t wc)
|
||||
{
|
||||
m_string += wc;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
BasicBuffer<CharT> &operator<<(const CharT *s)
|
||||
{
|
||||
m_string += s;
|
||||
|
||||
@@ -304,20 +304,20 @@ void TagEditor::enterPressed()
|
||||
// prepare additional windows
|
||||
|
||||
FParserLegend->clear();
|
||||
*FParserLegend << L"%a - artist\n";
|
||||
*FParserLegend << L"%A - album artist\n";
|
||||
*FParserLegend << L"%t - title\n";
|
||||
*FParserLegend << L"%b - album\n";
|
||||
*FParserLegend << L"%y - date\n";
|
||||
*FParserLegend << L"%n - track number\n";
|
||||
*FParserLegend << L"%g - genre\n";
|
||||
*FParserLegend << L"%c - composer\n";
|
||||
*FParserLegend << L"%p - performer\n";
|
||||
*FParserLegend << L"%d - disc\n";
|
||||
*FParserLegend << L"%C - comment\n\n";
|
||||
*FParserLegend << NC::fmtBold << L"Files:\n" << NC::fmtBoldEnd;
|
||||
*FParserLegend << "%a - artist\n";
|
||||
*FParserLegend << "%A - album artist\n";
|
||||
*FParserLegend << "%t - title\n";
|
||||
*FParserLegend << "%b - album\n";
|
||||
*FParserLegend << "%y - date\n";
|
||||
*FParserLegend << "%n - track number\n";
|
||||
*FParserLegend << "%g - genre\n";
|
||||
*FParserLegend << "%c - composer\n";
|
||||
*FParserLegend << "%p - performer\n";
|
||||
*FParserLegend << "%d - disc\n";
|
||||
*FParserLegend << "%C - comment\n\n";
|
||||
*FParserLegend << NC::fmtBold << "Files:\n" << NC::fmtBoldEnd;
|
||||
for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it)
|
||||
*FParserLegend << Config.color2 << L" * " << NC::clEnd << (*it)->getName() << '\n';
|
||||
*FParserLegend << Config.color2 << " * " << NC::clEnd << (*it)->getName() << '\n';
|
||||
FParserLegend->flush();
|
||||
|
||||
if (!Patterns.empty())
|
||||
@@ -378,7 +378,7 @@ void TagEditor::enterPressed()
|
||||
{
|
||||
if (FParserUsePreview)
|
||||
{
|
||||
*FParserPreview << NC::fmtBold << s.getName() << L":\n" << NC::fmtBoldEnd;
|
||||
*FParserPreview << NC::fmtBold << s.getName() << ":\n" << NC::fmtBoldEnd;
|
||||
*FParserPreview << ParseFilename(s, Config.pattern, FParserUsePreview) << '\n';
|
||||
}
|
||||
else
|
||||
@@ -398,12 +398,12 @@ void TagEditor::enterPressed()
|
||||
}
|
||||
if (!FParserUsePreview)
|
||||
s.setNewURI(new_file + extension);
|
||||
*FParserPreview << file << Config.color2 << L" -> " << NC::clEnd;
|
||||
*FParserPreview << file << Config.color2 << " -> " << NC::clEnd;
|
||||
if (new_file.empty())
|
||||
*FParserPreview << Config.empty_tags_color << Config.empty_tag << NC::clEnd;
|
||||
else
|
||||
*FParserPreview << new_file << extension;
|
||||
*FParserPreview << '\n' << '\n';
|
||||
*FParserPreview << "\n\n";
|
||||
if (!success)
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user