From d5e2d315fd138327e98c579fba2021f5edf1eec2 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 8 Sep 2012 17:50:01 +0200 Subject: [PATCH] use wstrings uncoditionally where needed --- configure.in | 2 +- src/actions.cpp | 28 +++++++++++----------- src/browser.cpp | 10 ++++---- src/browser.h | 2 +- src/clock.cpp | 4 ++-- src/clock.h | 2 +- src/display.cpp | 52 ++++++++++++++++++++--------------------- src/help.cpp | 16 ++++++------- src/help.h | 2 +- src/helpers.cpp | 20 ++++++++-------- src/helpers.h | 8 +++---- src/lastfm.cpp | 10 ++++---- src/lastfm.h | 4 ++-- src/lastfm_service.cpp | 4 ++-- src/lyrics.cpp | 14 +++++------ src/lyrics.h | 2 +- src/media_library.cpp | 4 ++-- src/media_library.h | 2 +- src/outputs.cpp | 4 ++-- src/outputs.h | 2 +- src/playlist.cpp | 6 ++--- src/playlist.h | 2 +- src/playlist_editor.cpp | 4 ++-- src/playlist_editor.h | 2 +- src/screen.h | 2 +- src/scrollpad.cpp | 6 ++--- src/scrollpad.h | 10 ++++---- src/search_engine.cpp | 4 ++-- src/search_engine.h | 2 +- src/sel_items_adder.cpp | 2 +- src/sel_items_adder.h | 2 +- src/server_info.cpp | 28 +++++++++++----------- src/server_info.h | 2 +- src/settings.cpp | 20 ++++++++-------- src/settings.h | 8 +++---- src/song.cpp | 12 +++++----- src/song_info.cpp | 20 ++++++++-------- src/song_info.h | 2 +- src/status.cpp | 18 +++++++------- src/tag_editor.cpp | 36 ++++++++++++++-------------- src/tag_editor.h | 2 +- src/tiny_tag_editor.cpp | 6 ++--- src/tiny_tag_editor.h | 2 +- src/visualizer.cpp | 4 ++-- src/visualizer.h | 2 +- src/window.h | 21 ----------------- 46 files changed, 196 insertions(+), 221 deletions(-) diff --git a/configure.in b/configure.in index e4218fea..e0fc623b 100644 --- a/configure.in +++ b/configure.in @@ -155,7 +155,7 @@ dnl ======================== if test "$pdcurses" = "no" ; then if test "$unicode" = "yes" ; then curses_config_bin="ncursesw6-config ncursesw5-config" - AC_DEFINE([_UTF8], [1], [enables unicode support]) + AC_DEFINE([NCMPCPP_UNICODE], [1], [enables unicode support]) else curses_config_bin="ncurses6-config ncurses5-config" fi diff --git a/src/actions.cpp b/src/actions.cpp index 626d05cb..2fb38aa5 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -800,7 +800,7 @@ void Delete::Run() question = "Delete "; question += itemTypeToString(item.type); question += " \""; - question += Shorten(TO_WSTRING(name), COLS-question.size()-10); + question += Shorten(ToWString(name), COLS-question.size()-10); question += "\"?"; } bool yes = AskYesNoQuestion(question, TraceMpdStatus); @@ -815,12 +815,12 @@ void Delete::Run() if (myBrowser->deleteItem(i)) { const char msg[] = "\"%s\" deleted"; - ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString(name), COLS-const_strlen(msg)).c_str()); } else { const char msg[] = "Couldn't delete \"%s\": %s"; - ShowMessage(msg, Shorten(TO_WSTRING(name), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); + ShowMessage(msg, Shorten(ToWString(name), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); success = false; break; } @@ -845,7 +845,7 @@ void Delete::Run() else { question = "Delete playlist \""; - question += Shorten(TO_WSTRING(myPlaylistEditor->Playlists->current().value()), COLS-question.size()-10); + question += Shorten(ToWString(myPlaylistEditor->Playlists->current().value()), COLS-question.size()-10); question += "\"?"; } bool yes = AskYesNoQuestion(question, TraceMpdStatus); @@ -1385,7 +1385,7 @@ void EditLibraryTag::Run() if (!TagEditor::WriteTags(es)) { const char msg[] = "Error while updating tags in \"%s\""; - ShowMessage(msg, Shorten(TO_WSTRING(es.getURI()), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString(es.getURI()), COLS-const_strlen(msg)).c_str()); success = false; break; } @@ -1431,7 +1431,7 @@ void EditLibraryAlbum::Run() if (f.isNull()) { const char msg[] = "Error while opening file \"%s\""; - ShowMessage(msg, Shorten(TO_WSTRING((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str()); success = 0; break; } @@ -1439,7 +1439,7 @@ void EditLibraryAlbum::Run() if (!f.save()) { const char msg[] = "Error while writing tags in \"%s\""; - ShowMessage(msg, Shorten(TO_WSTRING((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString((*myLibrary->Songs)[i].value().getURI()), COLS-const_strlen(msg)).c_str()); success = 0; break; } @@ -1492,7 +1492,7 @@ void EditDirectoryName::Run() if (rename_result == 0) { const char msg[] = "Directory renamed to \"%s\""; - ShowMessage(msg, Shorten(TO_WSTRING(new_dir), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str()); if (!myBrowser->isLocal()) Mpd.UpdateDirectory(locale_to_utf_cpy(getSharedDirectory(old_dir, new_dir))); myBrowser->GetDirectory(myBrowser->CurrentDir()); @@ -1500,7 +1500,7 @@ void EditDirectoryName::Run() else { const char msg[] = "Couldn't rename \"%s\": %s"; - ShowMessage(msg, Shorten(TO_WSTRING(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); + ShowMessage(msg, Shorten(ToWString(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); } } } @@ -1519,13 +1519,13 @@ void EditDirectoryName::Run() if (rename(full_old_dir.c_str(), full_new_dir.c_str()) == 0) { const char msg[] = "Directory renamed to \"%s\""; - ShowMessage(msg, Shorten(TO_WSTRING(new_dir), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str()); Mpd.UpdateDirectory(myTagEditor->CurrentDir()); } else { const char msg[] = "Couldn't rename \"%s\": %s"; - ShowMessage(msg, Shorten(TO_WSTRING(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); + ShowMessage(msg, Shorten(ToWString(old_dir), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); } } } @@ -1559,7 +1559,7 @@ void EditPlaylistName::Run() if (Mpd.Rename(locale_to_utf_cpy(old_name), locale_to_utf_cpy(new_name))) { const char msg[] = "Playlist renamed to \"%s\""; - ShowMessage(msg, Shorten(TO_WSTRING(new_name), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString(new_name), COLS-const_strlen(msg)).c_str()); if (myBrowser->Main() && !myBrowser->isLocal()) myBrowser->GetDirectory("/"); if (myPlaylistEditor->Main()) @@ -1932,7 +1932,7 @@ void Find::Run() ShowMessage("Searching..."); Screen *s = static_cast *>(myScreen); s->Main()->removeFormatting(); - ShowMessage("%s", findme.empty() || s->Main()->setFormatting(NC::fmtReverse, TO_WSTRING(findme), NC::fmtReverseEnd, 0) ? "Done!" : "No matching patterns found"); + ShowMessage("%s", findme.empty() || s->Main()->setFormatting(NC::fmtReverse, ToWString(findme), NC::fmtReverseEnd, 0) ? "Done!" : "No matching patterns found"); s->Main()->flush(); } @@ -2060,7 +2060,7 @@ void AddRandomItems::Run() while (answer != 's' && answer != 'a' && answer != 'b'); UnlockStatusbar(); - mpd_tag_type tag_type; + mpd_tag_type tag_type = MPD_TAG_ARTIST; std::string tag_type_str ; if (answer != 's') { diff --git a/src/browser.cpp b/src/browser.cpp index c8030547..4bd72b90 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -119,10 +119,10 @@ void Browser::SwitchTo() DrawHeader(); } -std::basic_string Browser::Title() +std::wstring Browser::Title() { - std::basic_string result = U("Browse: "); - result += Scroller(TO_WSTRING(itsBrowsedDir), itsScrollBeginning, COLS-result.length()-(Config.new_design ? 2 : Global::VolumeState.length())); + std::wstring result = L"Browse: "; + result += Scroller(ToWString(itsBrowsedDir), itsScrollBeginning, COLS-result.length()-(Config.new_design ? 2 : Global::VolumeState.length())); return result; } @@ -550,12 +550,12 @@ void Browser::ClearDirectory(const std::string &path) const if (remove(full_path.c_str()) == 0) { const char msg[] = "Deleting \"%s\"..."; - ShowMessage(msg, Shorten(TO_WSTRING(full_path), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString(full_path), COLS-const_strlen(msg)).c_str()); } else { const char msg[] = "Couldn't remove \"%s\": %s"; - ShowMessage(msg, Shorten(TO_WSTRING(full_path), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); + ShowMessage(msg, Shorten(ToWString(full_path), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); } } closedir(dir); diff --git a/src/browser.h b/src/browser.h index 42fd9de7..2f61b94f 100644 --- a/src/browser.h +++ b/src/browser.h @@ -34,7 +34,7 @@ class Browser : public Screen< NC::Menu >, public Filterable, public virtual void Resize() OVERRIDE; virtual void SwitchTo() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/clock.cpp b/src/clock.cpp index 3146fcf7..eb4dba51 100644 --- a/src/clock.cpp +++ b/src/clock.cpp @@ -110,9 +110,9 @@ void Clock::SwitchTo() w->display(); } -std::basic_string Clock::Title() +std::wstring Clock::Title() { - return U("Clock"); + return L"Clock"; } void Clock::Update() diff --git a/src/clock.h b/src/clock.h index f9736c19..4849d3a2 100644 --- a/src/clock.h +++ b/src/clock.h @@ -34,7 +34,7 @@ class Clock : public Screen virtual void Resize(); virtual void SwitchTo(); - virtual std::basic_string Title(); + virtual std::wstring Title(); virtual void Update(); virtual void Scroll(NC::Where) { } diff --git a/src/display.cpp b/src/display.cpp index b7e6fa14..e6925164 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -33,42 +33,42 @@ using Global::myScreen; namespace {// -const my_char_t *toColumnName(char c) +const wchar_t *toColumnName(char c) { switch (c) { case 'l': - return U("Time"); + return L"Time"; case 'f': - return U("Filename"); + return L"Filename"; case 'D': - return U("Directory"); + return L"Directory"; case 'a': - return U("Artist"); + return L"Artist"; case 'A': - return U("Album Artist"); + return L"Album Artist"; case 't': - return U("Title"); + return L"Title"; case 'b': - return U("Album"); + return L"Album"; case 'y': - return U("Date"); + return L"Date"; case 'n': case 'N': - return U("Track"); + return L"Track"; case 'g': - return U("Genre"); + return L"Genre"; case 'c': - return U("Composer"); + return L"Composer"; case 'p': - return U("Performer"); + return L"Performer"; case 'd': - return U("Disc"); + return L"Disc"; case 'C': - return U("Comment"); + return L"Comment"; case 'P': - return U("Priority"); + return L"Priority"; default: - return U("?"); + return L"?"; } } @@ -125,9 +125,9 @@ void showSongs(NC::Menu &menu, const MPD::Song &s, HasSongs &screen, const st } else if (*it == 'R') // right align { - NC::basic_buffer buf; - buf << U(" "); - String2Buffer(TO_WSTRING(line.substr(it-line.begin()+1)), buf); + NC::WBuffer buf; + buf << L" "; + String2Buffer(ToWString(line.substr(it-line.begin()+1)), buf); if (discard_colors) buf.removeFormatting(); if (is_now_playing) @@ -215,16 +215,16 @@ void showSongsInColumns(NC::Menu &menu, const MPD::Song &s, HasSongs &screen) if (remained_width-width < 0 || width < 0 /* this one may come from (*) */) break; - std::basic_string tag; + std::wstring tag; for (size_t i = 0; i < it->type.length(); ++i) { MPD::Song::GetFunction get = charToGetFunction(it->type[i]); - tag = TO_WSTRING(get ? s.getTags(get) : ""); + tag = ToWString(get ? s.getTags(get) : ""); if (!tag.empty()) break; } if (tag.empty() && it->display_empty_tag) - tag = TO_WSTRING(Config.empty_tag); + tag = ToWString(Config.empty_tag); NC::Window::cut(tag, width); if (!discard_colors && it->color != NC::clDefault) @@ -302,7 +302,7 @@ std::string Display::Columns(size_t list_width) if (remained_width-width < 0 || width < 0 /* this one may come from (*) */) break; - std::basic_string name; + std::wstring name; if (it->name.empty()) { for (size_t j = 0; j < it->type.length(); ++j) @@ -320,11 +320,11 @@ std::string Display::Columns(size_t list_width) if (it->right_alignment) { result += std::string(x_off, KEY_SPACE); - result += TO_STRING(name); + result += ToString(name); } else { - result += TO_STRING(name); + result += ToString(name); result += std::string(x_off, KEY_SPACE); } diff --git a/src/help.cpp b/src/help.cpp index b340891e..7f19218a 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -133,9 +133,9 @@ void Help::SwitchTo() DrawHeader(); } -std::basic_string Help::Title() +std::wstring Help::Title() { - return U("Help"); + return L"Help"; } std::string Help::DisplayKeys(const ActionType at) @@ -156,25 +156,25 @@ std::string Help::DisplayKeys(const ActionType at) void Help::Section(const char *type, const char *title) { - *w << U("\n ") << NC::fmtBold << TO_WSTRING(type) << U(" - "); - *w << TO_WSTRING(title) << NC::fmtBoldEnd << '\n' << '\n'; + *w << L"\n " << NC::fmtBold << ToWString(type) << L" - "; + *w << ToWString(title) << NC::fmtBoldEnd << L"\n\n"; } void Help::KeyDesc(const ActionType at, const char *desc) { - *w << U(" ") << DisplayKeys(at) << U(" : ") << TO_WSTRING(desc) << '\n'; + *w << L" " << DisplayKeys(at) << L" : " << ToWString(desc) << '\n'; } void Help::MouseDesc(std::string action, const char *desc, bool indent) { action.resize(31 - (indent ? 2 : 0), ' '); - *w << U(" ") << (indent ? U(" ") : U("")) << TO_WSTRING(action); - *w << U(": ") << TO_WSTRING(desc) << '\n'; + *w << L" " << (indent ? L" " : L"") << ToWString(action); + *w << L": " << ToWString(desc) << '\n'; } void Help::MouseColumn(const char *column) { - *w << NC::fmtBold << U(" ") << TO_WSTRING(column) << U(" column:\n") << NC::fmtBoldEnd; + *w << NC::fmtBold << L" " << ToWString(column) << L" column:\n" << NC::fmtBoldEnd; } void Help::GetKeybindings() diff --git a/src/help.h b/src/help.h index b15a192a..a52102cd 100644 --- a/src/help.h +++ b/src/help.h @@ -30,7 +30,7 @@ class Help : public Screen virtual void Resize() OVERRIDE; virtual void SwitchTo() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/helpers.cpp b/src/helpers.cpp index 11249fbd..d770268c 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -104,7 +104,7 @@ void ParseArgv(int argc, char **argv) # ifdef HAVE_TAGLIB_H << " taglib" # endif -# ifdef _UTF8 +# ifdef NCMPCPP_UNICODE << " unicode" # endif << std::endl; @@ -290,17 +290,17 @@ void markSongsInPlaylist(std::shared_ptr pl) pl->setBold(i, myPlaylist->checkForSong(*s)); } -std::basic_string Scroller(const std::basic_string &str, size_t &pos, size_t width) +std::wstring Scroller(const std::wstring &str, size_t &pos, size_t width) { - std::basic_string s(str); + std::wstring s(str); if (!Config.header_text_scrolling) return s; - std::basic_string result; + std::wstring result; size_t len = NC::Window::length(s); if (len > width) { - s += U(" ** "); + s += L" ** "; len = 0; auto b = s.begin(), e = s.end(); for (auto it = b+pos; it < e && len < width; ++it) @@ -323,14 +323,14 @@ std::basic_string Scroller(const std::basic_string &str, s return result; } -std::string Shorten(const std::basic_string &s, size_t max_length) +std::string Shorten(const std::wstring &s, size_t max_length) { if (s.length() <= max_length) - return TO_STRING(s); + return ToString(s); if (max_length < 2) return ""; - std::basic_string result(s, 0, max_length/2-!(max_length%2)); - result += U(".."); + std::wstring result(s, 0, max_length/2-!(max_length%2)); + result += L".."; result += s.substr(s.length()-max_length/2+1); - return TO_STRING(result); + return ToString(result); } diff --git a/src/helpers.h b/src/helpers.h index 86a39235..733fd319 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -321,11 +321,11 @@ void ParseArgv(int, char **); template struct StringConverter { const char *operator()(const char *s) { return s; } }; -template <> struct StringConverter< NC::basic_buffer > { +template <> struct StringConverter { std::wstring operator()(const char *s) { return ToWString(s); } }; template <> struct StringConverter { - std::basic_string operator()(const char *s) { return TO_WSTRING(s); } + std::wstring operator()(const char *s) { return ToWString(s); } }; template @@ -461,8 +461,8 @@ std::string Timestamp(time_t t); void markSongsInPlaylist(std::shared_ptr pl); -std::basic_string Scroller(const std::basic_string &str, size_t &pos, size_t width); +std::wstring Scroller(const std::wstring &str, size_t &pos, size_t width); -std::string Shorten(const std::basic_string &s, size_t max_length); +std::string Shorten(const std::wstring &s, size_t max_length); #endif diff --git a/src/lastfm.cpp b/src/lastfm.cpp index 319fa3c2..e8d5c425 100644 --- a/src/lastfm.cpp +++ b/src/lastfm.cpp @@ -58,7 +58,7 @@ void Lastfm::Resize() hasToBeResized = 0; } -std::basic_string Lastfm::Title() +std::wstring Lastfm::Title() { return itsTitle; } @@ -153,7 +153,7 @@ void Lastfm::Load() } else { - *w << U("Fetching informations... "); + *w << L"Fetching informations... "; pthread_create(&itsDownloader, 0, DownloadWrapper, this); isDownloadInProgress = 1; } @@ -164,8 +164,8 @@ void Lastfm::SetTitleAndFolder() { if (dynamic_cast(itsService.get())) { - itsTitle = U("Artist info - "); - itsTitle += TO_WSTRING(itsArgs.find("artist")->second); + itsTitle = L"Artist info - "; + itsTitle += ToWString(itsArgs.find("artist")->second); itsFolder = Config.ncmpcpp_directory + "artists"; } } @@ -211,7 +211,7 @@ void Lastfm::Refetch() if (remove(itsFilename.c_str()) && errno != ENOENT) { const char msg[] = "Couldn't remove \"%s\": %s"; - ShowMessage(msg, Shorten(TO_WSTRING(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); + ShowMessage(msg, Shorten(ToWString(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); return; } Load(); diff --git a/src/lastfm.h b/src/lastfm.h index 9d58f49a..38ea9aab 100644 --- a/src/lastfm.h +++ b/src/lastfm.h @@ -40,7 +40,7 @@ class Lastfm : public Screen virtual void SwitchTo() OVERRIDE; virtual void Resize() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE; @@ -61,7 +61,7 @@ class Lastfm : public Screen virtual bool isLockable() OVERRIDE { return false; } private: - std::basic_string itsTitle; + std::wstring itsTitle; std::string itsArtist; std::string itsFilename; diff --git a/src/lastfm_service.cpp b/src/lastfm_service.cpp index ebfc58ad..5f380c83 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.setFormatting(NC::fmtBold, U("\n\nSimilar artists:\n"), NC::fmtBoldEnd, false); - w.setFormatting(Config.color2, U("\n * "), NC::clEnd, true); + w.setFormatting(NC::fmtBold, L"\n\nSimilar artists:\n", NC::fmtBoldEnd, false); + w.setFormatting(Config.color2, L"\n * ", NC::clEnd, true); // below is used so format won't be removed using removeFormatting() by accident. w.forgetFormatting(); } diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 90177ddf..8fbb3ead 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -147,10 +147,10 @@ void Lyrics::SwitchTo() } } -std::basic_string Lyrics::Title() +std::wstring Lyrics::Title() { - std::basic_string result = U("Lyrics: "); - result += Scroller(TO_WSTRING(itsSong.toString("{%a - %t}")), itsScrollBegin, COLS-result.length()-(Config.new_design ? 2 : Global::VolumeState.length())); + std::wstring result = L"Lyrics: "; + result += Scroller(ToWString(itsSong.toString("{%a - %t}")), itsScrollBegin, COLS-result.length()-(Config.new_design ? 2 : Global::VolumeState.length())); return result; } @@ -253,10 +253,10 @@ void *Lyrics::Download() bool fetcher_defined = itsFetcher && *itsFetcher; for (LyricsFetcher **plugin = fetcher_defined ? itsFetcher : lyricsPlugins; *plugin != 0; ++plugin) { - *w << U("Fetching lyrics from ") << NC::fmtBold << TO_WSTRING((*plugin)->name()) << NC::fmtBoldEnd << U("... "); + *w << L"Fetching lyrics from " << NC::fmtBold << ToWString((*plugin)->name()) << NC::fmtBoldEnd << L"... "; result = (*plugin)->fetch(artist, title); if (result.first == false) - *w << NC::clRed << TO_WSTRING(result.second) << NC::clEnd << '\n'; + *w << NC::clRed << ToWString(result.second) << NC::clEnd << '\n'; else break; if (fetcher_defined) @@ -272,7 +272,7 @@ void *Lyrics::Download() *w << result.second; } else - *w << '\n' << U("Lyrics weren't found."); + *w << '\n' << L"Lyrics weren't found."; isReadyToTake = 1; pthread_exit(0); @@ -406,7 +406,7 @@ void Lyrics::Refetch() if (remove(itsFilename.c_str()) && errno != ENOENT) { const char msg[] = "Couldn't remove \"%s\": %s"; - ShowMessage(msg, Shorten(TO_WSTRING(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); + ShowMessage(msg, Shorten(ToWString(itsFilename), COLS-const_strlen(msg)-25).c_str(), strerror(errno)); return; } Load(); diff --git a/src/lyrics.h b/src/lyrics.h index 8d6ca6c8..f0ee6985 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -41,7 +41,7 @@ class Lyrics : public Screen virtual void Resize() OVERRIDE; virtual void SwitchTo() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE; diff --git a/src/media_library.cpp b/src/media_library.cpp index 2156b6bf..2e4d23a9 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -242,9 +242,9 @@ void MediaLibrary::SwitchTo() Refresh(); } -std::basic_string MediaLibrary::Title() +std::wstring MediaLibrary::Title() { - return U("Media library"); + return L"Media library"; } void MediaLibrary::Update() diff --git a/src/media_library.h b/src/media_library.h index 2b285d70..e4f2720c 100644 --- a/src/media_library.h +++ b/src/media_library.h @@ -30,7 +30,7 @@ class MediaLibrary : public Screen, public Filterable, public HasSon virtual void SwitchTo() OVERRIDE; virtual void Resize() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Refresh() OVERRIDE; virtual void Update() OVERRIDE; diff --git a/src/outputs.cpp b/src/outputs.cpp index f25579e9..3a0a4804 100644 --- a/src/outputs.cpp +++ b/src/outputs.cpp @@ -77,9 +77,9 @@ void Outputs::Resize() hasToBeResized = 0; } -std::basic_string Outputs::Title() +std::wstring Outputs::Title() { - return U("Outputs"); + return L"Outputs"; } void Outputs::EnterPressed() diff --git a/src/outputs.h b/src/outputs.h index 499baf92..6ebfe482 100644 --- a/src/outputs.h +++ b/src/outputs.h @@ -37,7 +37,7 @@ class Outputs : public Screen< NC::Menu > virtual void SwitchTo() OVERRIDE; virtual void Resize() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/playlist.cpp b/src/playlist.cpp index dd809eef..9b749cd1 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -147,12 +147,12 @@ void Playlist::Resize() hasToBeResized = 0; } -std::basic_string Playlist::Title() +std::wstring Playlist::Title() { - std::basic_string result = U("Playlist "); + std::wstring result = L"Playlist "; if (ReloadTotalLength || ReloadRemaining) itsBufferedStats = TotalLength(); - result += Scroller(TO_WSTRING(itsBufferedStats), itsScrollBegin, COLS-result.length()-(Config.new_design ? 2 : Global::VolumeState.length())); + result += Scroller(ToWString(itsBufferedStats), itsScrollBegin, COLS-result.length()-(Config.new_design ? 2 : Global::VolumeState.length())); return result; } diff --git a/src/playlist.h b/src/playlist.h index 5035a476..b3729666 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -37,7 +37,7 @@ class Playlist : public Screen, public Filterable, public HasSongs, virtual void SwitchTo() OVERRIDE; virtual void Resize() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index efd3f9cb..530256be 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -101,9 +101,9 @@ void PlaylistEditor::Resize() hasToBeResized = 0; } -std::basic_string PlaylistEditor::Title() +std::wstring PlaylistEditor::Title() { - return U("Playlist editor"); + return L"Playlist editor"; } void PlaylistEditor::Refresh() diff --git a/src/playlist_editor.h b/src/playlist_editor.h index 8ced9375..70b15760 100644 --- a/src/playlist_editor.h +++ b/src/playlist_editor.h @@ -30,7 +30,7 @@ class PlaylistEditor : public Screen, public Filterable, public HasS virtual void SwitchTo() OVERRIDE; virtual void Resize() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Refresh() OVERRIDE; virtual void Update() OVERRIDE; diff --git a/src/screen.h b/src/screen.h index 3e8a2dbc..47719eae 100644 --- a/src/screen.h +++ b/src/screen.h @@ -58,7 +58,7 @@ class BasicScreen virtual void Resize() = 0; /// @return title of the screen - virtual std::basic_string Title() = 0; + virtual std::wstring Title() = 0; /// If the screen contantly has to update itself /// somehow, it should be called by this function. diff --git a/src/scrollpad.cpp b/src/scrollpad.cpp index 202e32f8..fe1edbd3 100644 --- a/src/scrollpad.cpp +++ b/src/scrollpad.cpp @@ -43,7 +43,7 @@ void Scrollpad::flush() { m_real_height = 1; - std::basic_string s = m_buffer.str(); + std::wstring s = m_buffer.str(); size_t x = 0; int x_pos = 0; @@ -86,7 +86,7 @@ void Scrollpad::flush() std::swap(s, m_buffer.m_string); } -bool Scrollpad::setFormatting(short val_b, const std::basic_string &s, short val_e, bool case_sensitive, bool for_each) +bool Scrollpad::setFormatting(short val_b, const std::wstring &s, short val_e, bool case_sensitive, bool for_each) { bool result = m_buffer.setFormatting(val_b, s, val_e, case_sensitive, for_each); if (result) @@ -191,12 +191,10 @@ void Scrollpad::reset() m_beginning = 0; } -#ifdef _UTF8 Scrollpad &Scrollpad::operator<<(const std::string &s) { m_buffer << ToWString(s); return *this; } -#endif // _UTF8 } diff --git a/src/scrollpad.h b/src/scrollpad.h index 04d1c8e7..9a419ab7 100644 --- a/src/scrollpad.h +++ b/src/scrollpad.h @@ -56,7 +56,7 @@ struct Scrollpad: public Window /// given format for all occurences of given string or stops after first occurence /// @return true if at least one occurence of the string was found, false otherwise /// @see basic_buffer::setFormatting() - bool setFormatting(short val_b, const std::basic_string &s, + bool setFormatting(short val_b, const std::wstring &s, short val_e, bool case_sensitive, bool for_each = 1); /// Removes all format flags and colors from stored text @@ -70,7 +70,7 @@ struct Scrollpad: public Window /// @return text stored in internal buffer /// - const std::basic_string &content() { return m_buffer.str(); } + const std::wstring &content() { return m_buffer.str(); } /// Refreshes the window /// @see Window::Refresh() @@ -109,12 +109,10 @@ struct Scrollpad: public Window m_buffer << obj; return *this; } -# ifdef _UTF8 Scrollpad &operator<<(const std::string &s); -# endif // _UTF8 private: - basic_buffer m_buffer; + WBuffer m_buffer; size_t m_beginning; @@ -122,7 +120,7 @@ private: bool m_found_case_sensitive; short m_found_value_begin; short m_found_value_end; - std::basic_string m_found_pattern; + std::wstring m_found_pattern; size_t m_real_height; }; diff --git a/src/search_engine.cpp b/src/search_engine.cpp index 66ae6d7b..33d493f2 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -152,9 +152,9 @@ void SearchEngine::SwitchTo() markSongsInPlaylist(getProxySongList()); } -std::basic_string SearchEngine::Title() +std::wstring SearchEngine::Title() { - return U("Search engine"); + return L"Search engine"; } void SearchEngine::EnterPressed() diff --git a/src/search_engine.h b/src/search_engine.h index f11e0190..a4ad17c8 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -80,7 +80,7 @@ class SearchEngine : public Screen< NC::Menu >, public Filterable, publi virtual void Resize() OVERRIDE; virtual void SwitchTo() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/sel_items_adder.cpp b/src/sel_items_adder.cpp index 2d83cfae..bd96a874 100644 --- a/src/sel_items_adder.cpp +++ b/src/sel_items_adder.cpp @@ -145,7 +145,7 @@ void SelectedItemsAdder::Refresh() itsPlaylistSelector->display(); } -std::basic_string SelectedItemsAdder::Title() +std::wstring SelectedItemsAdder::Title() { return myOldScreen->Title(); } diff --git a/src/sel_items_adder.h b/src/sel_items_adder.h index 83d90a37..a4f4e3f2 100644 --- a/src/sel_items_adder.h +++ b/src/sel_items_adder.h @@ -33,7 +33,7 @@ class SelectedItemsAdder : public Screen< NC::Menu > virtual void Resize() OVERRIDE; virtual void Refresh() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/server_info.cpp b/src/server_info.cpp index 1ad30f6f..fe1ba6db 100644 --- a/src/server_info.cpp +++ b/src/server_info.cpp @@ -85,7 +85,7 @@ void ServerInfo::Resize() hasToBeResized = 0; } -std::basic_string ServerInfo::Title() +std::wstring ServerInfo::Title() { return myOldScreen->Title(); } @@ -103,28 +103,28 @@ void ServerInfo::Update() w->clear(); - *w << NC::fmtBold << U("Version: ") << NC::fmtBoldEnd << U("0.") << Mpd.Version() << U(".*\n"); - *w << NC::fmtBold << U("Uptime: ") << NC::fmtBoldEnd; + *w << NC::fmtBold << L"Version: " << NC::fmtBoldEnd << L"0." << Mpd.Version() << L".*\n"; + *w << NC::fmtBold << L"Uptime: " << NC::fmtBoldEnd; ShowTime(*w, stats.uptime(), 1); *w << '\n'; - *w << NC::fmtBold << U("Time playing: ") << NC::fmtBoldEnd << MPD::Song::ShowTime(stats.playTime()) << '\n'; + *w << NC::fmtBold << L"Time playing: " << NC::fmtBoldEnd << MPD::Song::ShowTime(stats.playTime()) << '\n'; *w << '\n'; - *w << NC::fmtBold << U("Total playtime: ") << NC::fmtBoldEnd; + *w << NC::fmtBold << L"Total playtime: " << NC::fmtBoldEnd; ShowTime(*w, stats.dbPlayTime(), 1); *w << '\n'; - *w << NC::fmtBold << U("Artist names: ") << NC::fmtBoldEnd << stats.artists() << '\n'; - *w << NC::fmtBold << U("Album names: ") << NC::fmtBoldEnd << stats.albums() << '\n'; - *w << NC::fmtBold << U("Songs in database: ") << NC::fmtBoldEnd << stats.songs() << '\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 << '\n'; - *w << NC::fmtBold << U("Last DB update: ") << NC::fmtBoldEnd << Timestamp(stats.dbUpdateTime()) << '\n'; + *w << NC::fmtBold << L"Last DB update: " << NC::fmtBoldEnd << Timestamp(stats.dbUpdateTime()) << '\n'; *w << '\n'; - *w << NC::fmtBold << U("URL Handlers:") << NC::fmtBoldEnd; + *w << NC::fmtBold << L"URL Handlers:" << NC::fmtBoldEnd; for (auto it = itsURLHandlers.begin(); it != itsURLHandlers.end(); ++it) - *w << (it != itsURLHandlers.begin() ? U(", ") : U(" ")) << *it; - *w << U("\n\n"); - *w << NC::fmtBold << U("Tag Types:") << NC::fmtBoldEnd; + *w << (it != itsURLHandlers.begin() ? L", " : L" ") << *it; + *w << L"\n\n"; + *w << NC::fmtBold << L"Tag Types:" << NC::fmtBoldEnd; for (auto it = itsTagTypes.begin(); it != itsTagTypes.end(); ++it) - *w << (it != itsTagTypes.begin() ? U(", ") : U(" ")) << *it; + *w << (it != itsTagTypes.begin() ? L", " : L" ") << *it; w->flush(); w->refresh(); diff --git a/src/server_info.h b/src/server_info.h index d66ac9b7..ac256b06 100644 --- a/src/server_info.h +++ b/src/server_info.h @@ -30,7 +30,7 @@ class ServerInfo : public Screen virtual void SwitchTo() OVERRIDE; virtual void Resize() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE; diff --git a/src/settings.cpp b/src/settings.cpp index 7f529db3..2e7337ba 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -173,8 +173,8 @@ void Configuration::SetDefaults() new_header_first_line = "{$b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b}"; new_header_second_line = "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}"; browser_playlist_prefix << NC::clRed << "(playlist)" << NC::clEnd << ' '; - progressbar = U("=>\0"); - visualizer_chars = U("◆│"); + progressbar = L"=>\0"; + visualizer_chars = L"◆│"; pattern = "%n - %t"; selected_item_prefix << NC::clMagenta; selected_item_suffix << NC::clEnd; @@ -335,7 +335,7 @@ void Configuration::Read() { name = GetOptionName(cl); v = getEnclosedString(cl, '"', '"', 0); - + if (name == "ncmpcpp_directory") { if (!v.empty()) @@ -513,7 +513,7 @@ void Configuration::Read() } else if (name == "progressbar_look") { - std::basic_string pb = TO_WSTRING(v); + std::wstring pb = ToWString(v); if (pb.length() < 2 || pb.length() > 3) { std::cerr << "Warning: length of progressbar_look should be either "; @@ -526,7 +526,7 @@ void Configuration::Read() } else if (name == "visualizer_look") { - std::basic_string vc = TO_WSTRING(v); + std::wstring vc = ToWString(v); if (vc.length() != 2) { std::cerr << "Warning: length of visualizer_look should be 2, but it's " << vc.length() << ", discarding.\n"; @@ -545,7 +545,7 @@ void Configuration::Read() { selected_item_prefix.clear(); String2Buffer(v, selected_item_prefix); - selected_item_prefix_length = NC::Window::length(TO_WSTRING(selected_item_prefix.str())); + selected_item_prefix_length = NC::Window::length(ToWString(selected_item_prefix.str())); } } else if (name == "selected_item_suffix") @@ -554,7 +554,7 @@ void Configuration::Read() { selected_item_suffix.clear(); String2Buffer(v, selected_item_suffix); - selected_item_suffix_length = NC::Window::length(TO_WSTRING(selected_item_suffix.str())); + selected_item_suffix_length = NC::Window::length(ToWString(selected_item_suffix.str())); } } else if (name == "now_playing_prefix") @@ -563,7 +563,7 @@ void Configuration::Read() { now_playing_prefix.clear(); String2Buffer(v, now_playing_prefix); - now_playing_prefix_length = NC::Window::length(TO_WSTRING(now_playing_prefix.str())); + now_playing_prefix_length = NC::Window::length(ToWString(now_playing_prefix.str())); } } else if (name == "now_playing_suffix") @@ -571,7 +571,7 @@ void Configuration::Read() if (!v.empty()) { now_playing_suffix.clear(); - String2Buffer(TO_WSTRING(v), now_playing_suffix); + String2Buffer(ToWString(v), now_playing_suffix); now_playing_suffix_length = NC::Window::length(now_playing_suffix.str()); } } @@ -977,7 +977,7 @@ void Configuration::GenerateColumns() size_t tag_type_colon_pos = tag_type.find(':'); if (tag_type_colon_pos != std::string::npos) { - col.name = TO_WSTRING(tag_type.substr(tag_type_colon_pos+1)); + col.name = ToWString(tag_type.substr(tag_type_colon_pos+1)); tag_type.resize(tag_type_colon_pos); } diff --git a/src/settings.h b/src/settings.h index a9084c55..da17f82e 100644 --- a/src/settings.h +++ b/src/settings.h @@ -35,7 +35,7 @@ struct Column { Column() : stretch_limit(-1), right_alignment(0), display_empty_tag(1) { } - std::basic_string name; + std::wstring name; std::string type; int width; int stretch_limit; @@ -80,8 +80,8 @@ struct Configuration std::string new_header_first_line; std::string new_header_second_line; std::string lastfm_preferred_language; - std::basic_string progressbar; - std::basic_string visualizer_chars; + std::wstring progressbar; + std::wstring visualizer_chars; std::string pattern; @@ -91,7 +91,7 @@ struct Configuration NC::Buffer selected_item_prefix; NC::Buffer selected_item_suffix; NC::Buffer now_playing_prefix; - NC::basic_buffer now_playing_suffix; + NC::WBuffer now_playing_suffix; NC::Color color1; NC::Color color2; diff --git a/src/song.cpp b/src/song.cpp index 215ad4d5..330157c6 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -39,16 +39,16 @@ size_t calc_hash(const char* s, unsigned seed = 0) } // temporary hack, it won't work properly with wide characters -std::string Shorten(const std::basic_string &s, size_t max_length) +std::string Shorten(const std::wstring &s, size_t max_length) { if (s.length() <= max_length) - return TO_STRING(s); + return ToString(s); if (max_length < 2) return ""; - std::basic_string result(s, 0, max_length/2-!(max_length%2)); - result += U(".."); + std::wstring result(s, 0, max_length/2-!(max_length%2)); + result += L".."; result += s.substr(s.length()-max_length/2+1); - return TO_STRING(result); + return ToString(result); } } @@ -373,7 +373,7 @@ std::string Song::ParseFormat(std::string::const_iterator &it, const std::string { if (delimiter) { - const std::basic_string &s = TO_WSTRING(tag); + std::wstring s = ToWString(tag); if (NC::Window::length(s) > delimiter) tag = Shorten(s, delimiter); } diff --git a/src/song_info.cpp b/src/song_info.cpp index 6e349080..d4d2411c 100644 --- a/src/song_info.cpp +++ b/src/song_info.cpp @@ -64,9 +64,9 @@ void SongInfo::Resize() hasToBeResized = 0; } -std::basic_string SongInfo::Title() +std::wstring SongInfo::Title() { - return U("Song info"); + return L"Song info"; } void SongInfo::SwitchTo() @@ -115,24 +115,24 @@ void SongInfo::PrepareSong(MPD::Song &s) TagLib::FileRef f(path_to_file.c_str()); # endif // HAVE_TAGLIB_H - *w << NC::fmtBold << Config.color1 << U("Filename: ") << NC::fmtBoldEnd << Config.color2 << s.getName() << '\n' << NC::clEnd; - *w << NC::fmtBold << U("Directory: ") << NC::fmtBoldEnd << Config.color2; + *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; ShowTag(*w, s.getDirectory()); - *w << U("\n\n") << NC::clEnd; - *w << NC::fmtBold << U("Length: ") << NC::fmtBoldEnd << Config.color2 << s.getLength() << '\n' << NC::clEnd; + *w << L"\n\n" << NC::clEnd; + *w << NC::fmtBold << L"Length: " << NC::fmtBoldEnd << Config.color2 << s.getLength() << '\n' << NC::clEnd; # ifdef HAVE_TAGLIB_H if (!f.isNull()) { - *w << NC::fmtBold << U("Bitrate: ") << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << U(" kbps\n") << NC::clEnd; - *w << NC::fmtBold << U("Sample rate: ") << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << U(" Hz\n") << NC::clEnd; - *w << NC::fmtBold << U("Channels: ") << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? U("Mono") : U("Stereo")) << '\n' << NC::clDefault; + *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; } # endif // HAVE_TAGLIB_H *w << NC::clDefault; for (const Metadata *m = Tags; m->Name; ++m) { - *w << NC::fmtBold << '\n' << TO_WSTRING(m->Name) << U(": ") << NC::fmtBoldEnd; + *w << NC::fmtBold << '\n' << ToWString(m->Name) << L": " << NC::fmtBoldEnd; ShowTag(*w, s.getTags(m->Get)); } } diff --git a/src/song_info.h b/src/song_info.h index 3f58c2f9..f4735d45 100644 --- a/src/song_info.h +++ b/src/song_info.h @@ -38,7 +38,7 @@ class SongInfo : public Screen virtual void SwitchTo() OVERRIDE; virtual void Resize() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/status.cpp b/src/status.cpp index 1df25011..7418663c 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -443,9 +443,9 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *) tracklength += " kbps"; } - NC::basic_buffer first, second; - String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.new_header_first_line, "$"))), first); - String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.new_header_second_line, "$"))), second); + NC::WBuffer first, second; + String2Buffer(ToWString(utf_to_locale_cpy(np.toString(Config.new_header_first_line, "$"))), first); + String2Buffer(ToWString(utf_to_locale_cpy(np.toString(Config.new_header_second_line, "$"))), second); size_t first_len = NC::Window::length(first.str()); size_t first_margin = (std::max(tracklength.length()+1, VolumeState.length()))*2; @@ -458,11 +458,11 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *) if (!Global::SeekingInProgress) *wHeader << NC::XY(0, 0) << wclrtoeol << tracklength; *wHeader << NC::XY(first_start, 0); - first.write(*wHeader, first_line_scroll_begin, COLS-tracklength.length()-VolumeState.length()-1, U(" ** ")); + first.write(*wHeader, first_line_scroll_begin, COLS-tracklength.length()-VolumeState.length()-1, L" ** "); *wHeader << NC::XY(0, 1) << wclrtoeol << NC::fmtBold << player_state << NC::fmtBoldEnd; *wHeader << NC::XY(second_start, 1); - second.write(*wHeader, second_line_scroll_begin, COLS-player_state.length()-8-2, U(" ** ")); + second.write(*wHeader, second_line_scroll_begin, COLS-player_state.length()-8-2, L" ** "); *wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << Config.volume_color << VolumeState << NC::clEnd; @@ -495,10 +495,10 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *) tracklength += MPD::Song::ShowTime(Mpd.GetElapsedTime()); tracklength += "]"; } - NC::basic_buffer np_song; - String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.song_status_format, "$"))), np_song); + NC::WBuffer np_song; + String2Buffer(ToWString(utf_to_locale_cpy(np.toString(Config.song_status_format, "$"))), np_song); *wFooter << NC::XY(0, 1) << wclrtoeol << NC::fmtBold << player_state << NC::fmtBoldEnd; - np_song.write(*wFooter, playing_song_scroll_begin, wFooter->getWidth()-player_state.length()-tracklength.length(), U(" ** ")); + np_song.write(*wFooter, playing_song_scroll_begin, wFooter->getWidth()-player_state.length()-tracklength.length(), L" ** "); *wFooter << NC::fmtBold << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << tracklength << NC::fmtBoldEnd; } if (!block_progressbar_update) @@ -649,7 +649,7 @@ void DrawHeader() return; if (Config.new_design) { - std::basic_string title = myScreen->Title(); + std::wstring title = myScreen->Title(); *wHeader << NC::XY(0, 3) << wclrtoeol; *wHeader << NC::fmtBold << Config.alternative_ui_separator_color; mvwhline(wHeader->raw(), 2, 0, 0, COLS); diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 43da902f..16111b77 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -201,9 +201,9 @@ void TagEditor::Resize() hasToBeResized = 0; } -std::basic_string TagEditor::Title() +std::wstring TagEditor::Title() { - return U("Tag editor"); + return L"Tag editor"; } void TagEditor::SwitchTo() @@ -333,20 +333,20 @@ void TagEditor::EnterPressed() // prepare additional windows FParserLegend->clear(); - *FParserLegend << U("%a - artist\n"); - *FParserLegend << U("%A - album artist\n"); - *FParserLegend << U("%t - title\n"); - *FParserLegend << U("%b - album\n"); - *FParserLegend << U("%y - date\n"); - *FParserLegend << U("%n - track number\n"); - *FParserLegend << U("%g - genre\n"); - *FParserLegend << U("%c - composer\n"); - *FParserLegend << U("%p - performer\n"); - *FParserLegend << U("%d - disc\n"); - *FParserLegend << U("%C - comment\n\n"); - *FParserLegend << NC::fmtBold << U("Files:\n") << NC::fmtBoldEnd; + *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; for (auto it = EditedSongs.begin(); it != EditedSongs.end(); ++it) - *FParserLegend << Config.color2 << U(" * ") << NC::clEnd << (*it)->getName() << '\n'; + *FParserLegend << Config.color2 << L" * " << NC::clEnd << (*it)->getName() << '\n'; FParserLegend->flush(); if (!Patterns.empty()) @@ -407,7 +407,7 @@ void TagEditor::EnterPressed() { if (FParserUsePreview) { - *FParserPreview << NC::fmtBold << s.getName() << U(":\n") << NC::fmtBoldEnd; + *FParserPreview << NC::fmtBold << s.getName() << L":\n" << NC::fmtBoldEnd; *FParserPreview << ParseFilename(s, Config.pattern, FParserUsePreview) << '\n'; } else @@ -427,7 +427,7 @@ void TagEditor::EnterPressed() } if (!FParserUsePreview) s.setNewURI(new_file + extension); - *FParserPreview << file << Config.color2 << U(" -> ") << NC::clEnd; + *FParserPreview << file << Config.color2 << L" -> " << NC::clEnd; if (new_file.empty()) *FParserPreview << Config.empty_tags_color << Config.empty_tag << NC::clEnd; else @@ -597,7 +597,7 @@ void TagEditor::EnterPressed() if (!WriteTags(**it)) { const char msg[] = "Error while writing tags in \"%s\""; - ShowMessage(msg, Shorten(TO_WSTRING((*it)->getURI()), COLS-const_strlen(msg)).c_str()); + ShowMessage(msg, Shorten(ToWString((*it)->getURI()), COLS-const_strlen(msg)).c_str()); success = 0; break; } diff --git a/src/tag_editor.h b/src/tag_editor.h index f53c91a7..e3a098a4 100644 --- a/src/tag_editor.h +++ b/src/tag_editor.h @@ -41,7 +41,7 @@ class TagEditor : public Screen, public Filterable, public HasSongs, virtual void Resize(); virtual void SwitchTo(); - virtual std::basic_string Title(); + virtual std::wstring Title(); virtual void Refresh(); virtual void Update(); diff --git a/src/tiny_tag_editor.cpp b/src/tiny_tag_editor.cpp index 065b2ba2..f628cab0 100644 --- a/src/tiny_tag_editor.cpp +++ b/src/tiny_tag_editor.cpp @@ -92,15 +92,15 @@ void TinyTagEditor::SwitchTo() full_path += itsEdited.getURI(); std::string message = "Couldn't read file \""; - message += Shorten(TO_WSTRING(full_path), COLS-message.length()-3); + message += Shorten(ToWString(full_path), COLS-message.length()-3); message += "\"!"; ShowMessage("%s", message.c_str()); } } -std::basic_string TinyTagEditor::Title() +std::wstring TinyTagEditor::Title() { - return U("Tiny tag editor"); + return L"Tiny tag editor"; } void TinyTagEditor::EnterPressed() diff --git a/src/tiny_tag_editor.h b/src/tiny_tag_editor.h index 5e482c25..b1fc66c2 100644 --- a/src/tiny_tag_editor.h +++ b/src/tiny_tag_editor.h @@ -38,7 +38,7 @@ class TinyTagEditor : public Screen< NC::Menu > virtual void Resize() OVERRIDE; virtual void SwitchTo() OVERRIDE; - virtual std::basic_string Title() OVERRIDE; + virtual std::wstring Title() OVERRIDE; virtual void Update() OVERRIDE { } diff --git a/src/visualizer.cpp b/src/visualizer.cpp index d8936b6b..f9576bb0 100644 --- a/src/visualizer.cpp +++ b/src/visualizer.cpp @@ -102,9 +102,9 @@ void Visualizer::Resize() hasToBeResized = 0; } -std::basic_string Visualizer::Title() +std::wstring Visualizer::Title() { - return U("Music visualizer"); + return L"Music visualizer"; } void Visualizer::Update() diff --git a/src/visualizer.h b/src/visualizer.h index 8082be1a..68e90854 100644 --- a/src/visualizer.h +++ b/src/visualizer.h @@ -38,7 +38,7 @@ class Visualizer : public Screen virtual void SwitchTo(); virtual void Resize(); - virtual std::basic_string Title(); + virtual std::wstring Title(); virtual void Update(); virtual void Scroll(NC::Where) { } diff --git a/src/window.h b/src/window.h index 936ea03e..c06a725a 100644 --- a/src/window.h +++ b/src/window.h @@ -102,18 +102,6 @@ # define BUTTON2_PRESSED (NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) | (1U << 27)) #endif // USE_PDCURSES -#ifdef _UTF8 -# define my_char_t wchar_t -# define U(x) L##x -# define TO_STRING(x) ToString(x) -# define TO_WSTRING(x) ToWString(x) -#else -# define my_char_t char -# define U(x) x -# define TO_STRING(x) (x) -# define TO_WSTRING(x) (x) -#endif - // workaraund for win32 #ifdef WIN32 # define wcwidth(x) int(!iscntrl(x)) @@ -431,21 +419,12 @@ struct Window /// @return real length of wide string static size_t length(const std::wstring &ws); - /// Fallback for Length() for wide strings used if unicode support is disabled - /// @param s string that real length has to be measured - /// @return standard std::string::length() result since it's only fallback - static size_t length(const std::string &s) { return s.length(); } - /// Cuts string so it fits desired length on the screen. Note that it uses /// wcwidth to check real width of all characters it contains. If string /// fits requested length it's not modified at all. /// @param ws wide string to be cut /// @param max_len maximal length of string static void cut(std::wstring &ws, size_t max_len); - - /// Variant for std::string, it just falls back to std::string::resize - static void cut(std::string &s, size_t max_len) { s.resize(max_len); } - protected: /// Sets colors of window (interal use only) /// @param fg foregound color