diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2012-10-06 02:51:07 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2012-10-06 02:51:07 +0200 |
commit | 43924f88e1bb5b6ae8420d25d95f4f4d57c5461b (patch) | |
tree | a60800c59818407a7ea50926aee902fc94cc75bf /src | |
parent | eda2ea37a9725a954accb1c65be2e1d79b659cc0 (diff) |
scrollpad: use std::string as container
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.cpp | 2 | ||||
-rw-r--r-- | src/help.cpp | 12 | ||||
-rw-r--r-- | src/helpers.h | 3 | ||||
-rw-r--r-- | src/lastfm.cpp | 2 | ||||
-rw-r--r-- | src/lastfm_service.cpp | 4 | ||||
-rw-r--r-- | src/lyrics.cpp | 6 | ||||
-rw-r--r-- | src/scrollpad.cpp | 6 | ||||
-rw-r--r-- | src/scrollpad.h | 7 | ||||
-rw-r--r-- | src/server_info.cpp | 26 | ||||
-rw-r--r-- | src/song_info.cpp | 16 | ||||
-rw-r--r-- | src/strbuffer.h | 10 | ||||
-rw-r--r-- | src/tag_editor.cpp | 32 |
12 files changed, 55 insertions, 71 deletions
diff --git a/src/actions.cpp b/src/actions.cpp index 3a99ad90..4a8bcc92 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -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(); } diff --git a/src/help.cpp b/src/help.cpp index 50fe45cf..9bbc6c87 100644 --- a/src/help.cpp +++ b/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() diff --git a/src/helpers.h b/src/helpers.h index 1e2c7b5d..ca7abf20 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -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) diff --git a/src/lastfm.cpp b/src/lastfm.cpp index 32183d37..85a68333 100644 --- a/src/lastfm.cpp +++ b/src/lastfm.cpp @@ -139,7 +139,7 @@ void Lastfm::Load() } else { - w << L"Fetching informations... "; + w << "Fetching informations... "; pthread_create(&itsDownloader, 0, DownloadWrapper, this); isDownloadInProgress = 1; } diff --git a/src/lastfm_service.cpp b/src/lastfm_service.cpp index 34dea81b..cb30635e 100644 --- a/src/lastfm_service.cpp +++ b/src/lastfm_service.cpp @@ -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) diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 42bd7b4a..77b2df41 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -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); diff --git a/src/scrollpad.cpp b/src/scrollpad.cpp index d8f22675..ed69e719 100644 --- a/src/scrollpad.cpp +++ b/src/scrollpad.cpp @@ -231,10 +231,4 @@ void Scrollpad::reset() m_beginning = 0; } -Scrollpad &Scrollpad::operator<<(const std::string &s) -{ - m_buffer << ToWString(s); - return *this; -} - } diff --git a/src/scrollpad.h b/src/scrollpad.h index 68a4f73d..01d9c093 100644 --- a/src/scrollpad.h +++ b/src/scrollpad.h @@ -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; diff --git a/src/server_info.cpp b/src/server_info.cpp index 762cb228..7223a72d 100644 --- a/src/server_info.cpp +++ b/src/server_info.cpp @@ -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(); diff --git a/src/song_info.cpp b/src/song_info.cpp index 1964acd2..01b907ca 100644 --- a/src/song_info.cpp +++ b/src/song_info.cpp @@ -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)); } } diff --git a/src/strbuffer.h b/src/strbuffer.h index 8c31dea3..b89ad63c 100644 --- a/src/strbuffer.h +++ b/src/strbuffer.h @@ -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; diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 4b82e9ed..69570307 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -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; } |