use wstrings uncoditionally where needed

This commit is contained in:
Andrzej Rybczak
2012-09-08 17:50:01 +02:00
parent cf06d9fa8d
commit d5e2d315fd
46 changed files with 196 additions and 221 deletions

View File

@@ -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

View File

@@ -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<NC::Scrollpad> *s = static_cast<Screen<NC::Scrollpad> *>(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')
{

View File

@@ -119,10 +119,10 @@ void Browser::SwitchTo()
DrawHeader();
}
std::basic_string<my_char_t> Browser::Title()
std::wstring Browser::Title()
{
std::basic_string<my_char_t> 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);

View File

@@ -34,7 +34,7 @@ class Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public
virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -110,9 +110,9 @@ void Clock::SwitchTo()
w->display();
}
std::basic_string<my_char_t> Clock::Title()
std::wstring Clock::Title()
{
return U("Clock");
return L"Clock";
}
void Clock::Update()

View File

@@ -34,7 +34,7 @@ class Clock : public Screen<NC::Window>
virtual void Resize();
virtual void SwitchTo();
virtual std::basic_string<my_char_t> Title();
virtual std::wstring Title();
virtual void Update();
virtual void Scroll(NC::Where) { }

View File

@@ -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<T> &menu, const MPD::Song &s, HasSongs &screen, const st
}
else if (*it == 'R') // right align
{
NC::basic_buffer<my_char_t> 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<T> &menu, const MPD::Song &s, HasSongs &screen)
if (remained_width-width < 0 || width < 0 /* this one may come from (*) */)
break;
std::basic_string<my_char_t> 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<my_char_t> 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);
}

View File

@@ -133,9 +133,9 @@ void Help::SwitchTo()
DrawHeader();
}
std::basic_string<my_char_t> 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()

View File

@@ -30,7 +30,7 @@ class Help : public Screen<NC::Scrollpad>
virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -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<ProxySongList> pl)
pl->setBold(i, myPlaylist->checkForSong(*s));
}
std::basic_string<my_char_t> Scroller(const std::basic_string<my_char_t> &str, size_t &pos, size_t width)
std::wstring Scroller(const std::wstring &str, size_t &pos, size_t width)
{
std::basic_string<my_char_t> s(str);
std::wstring s(str);
if (!Config.header_text_scrolling)
return s;
std::basic_string<my_char_t> 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<my_char_t> Scroller(const std::basic_string<my_char_t> &str, s
return result;
}
std::string Shorten(const std::basic_string<my_char_t> &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<my_char_t> 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);
}

View File

@@ -321,11 +321,11 @@ void ParseArgv(int, char **);
template <typename T> struct StringConverter {
const char *operator()(const char *s) { return s; }
};
template <> struct StringConverter< NC::basic_buffer<wchar_t> > {
template <> struct StringConverter<NC::WBuffer> {
std::wstring operator()(const char *s) { return ToWString(s); }
};
template <> struct StringConverter<NC::Scrollpad> {
std::basic_string<my_char_t> operator()(const char *s) { return TO_WSTRING(s); }
std::wstring operator()(const char *s) { return ToWString(s); }
};
template <typename CharT>
@@ -461,8 +461,8 @@ std::string Timestamp(time_t t);
void markSongsInPlaylist(std::shared_ptr<ProxySongList> pl);
std::basic_string<my_char_t> Scroller(const std::basic_string<my_char_t> &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<my_char_t> &s, size_t max_length);
std::string Shorten(const std::wstring &s, size_t max_length);
#endif

View File

@@ -58,7 +58,7 @@ void Lastfm::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> 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<ArtistInfo *>(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();

View File

@@ -40,7 +40,7 @@ class Lastfm : public Screen<NC::Scrollpad>
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE;
@@ -61,7 +61,7 @@ class Lastfm : public Screen<NC::Scrollpad>
virtual bool isLockable() OVERRIDE { return false; }
private:
std::basic_string<my_char_t> itsTitle;
std::wstring itsTitle;
std::string itsArtist;
std::string itsFilename;

View File

@@ -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();
}

View File

@@ -147,10 +147,10 @@ void Lyrics::SwitchTo()
}
}
std::basic_string<my_char_t> Lyrics::Title()
std::wstring Lyrics::Title()
{
std::basic_string<my_char_t> 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();

View File

@@ -41,7 +41,7 @@ class Lyrics : public Screen<NC::Scrollpad>
virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE;

View File

@@ -242,9 +242,9 @@ void MediaLibrary::SwitchTo()
Refresh();
}
std::basic_string<my_char_t> MediaLibrary::Title()
std::wstring MediaLibrary::Title()
{
return U("Media library");
return L"Media library";
}
void MediaLibrary::Update()

View File

@@ -30,7 +30,7 @@ class MediaLibrary : public Screen<NC::Window>, public Filterable, public HasSon
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Refresh() OVERRIDE;
virtual void Update() OVERRIDE;

View File

@@ -77,9 +77,9 @@ void Outputs::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> Outputs::Title()
std::wstring Outputs::Title()
{
return U("Outputs");
return L"Outputs";
}
void Outputs::EnterPressed()

View File

@@ -37,7 +37,7 @@ class Outputs : public Screen< NC::Menu<MPD::Output> >
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -147,12 +147,12 @@ void Playlist::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> Playlist::Title()
std::wstring Playlist::Title()
{
std::basic_string<my_char_t> 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;
}

View File

@@ -37,7 +37,7 @@ class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs,
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -101,9 +101,9 @@ void PlaylistEditor::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> PlaylistEditor::Title()
std::wstring PlaylistEditor::Title()
{
return U("Playlist editor");
return L"Playlist editor";
}
void PlaylistEditor::Refresh()

View File

@@ -30,7 +30,7 @@ class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasS
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Refresh() OVERRIDE;
virtual void Update() OVERRIDE;

View File

@@ -58,7 +58,7 @@ class BasicScreen
virtual void Resize() = 0;
/// @return title of the screen
virtual std::basic_string<my_char_t> Title() = 0;
virtual std::wstring Title() = 0;
/// If the screen contantly has to update itself
/// somehow, it should be called by this function.

View File

@@ -43,7 +43,7 @@ void Scrollpad::flush()
{
m_real_height = 1;
std::basic_string<my_char_t> 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<my_char_t> &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
}

View File

@@ -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<my_char_t> &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<my_char_t> &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<my_char_t> 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<my_char_t> m_found_pattern;
std::wstring m_found_pattern;
size_t m_real_height;
};

View File

@@ -152,9 +152,9 @@ void SearchEngine::SwitchTo()
markSongsInPlaylist(getProxySongList());
}
std::basic_string<my_char_t> SearchEngine::Title()
std::wstring SearchEngine::Title()
{
return U("Search engine");
return L"Search engine";
}
void SearchEngine::EnterPressed()

View File

@@ -80,7 +80,7 @@ class SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, publi
virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -145,7 +145,7 @@ void SelectedItemsAdder::Refresh()
itsPlaylistSelector->display();
}
std::basic_string<my_char_t> SelectedItemsAdder::Title()
std::wstring SelectedItemsAdder::Title()
{
return myOldScreen->Title();
}

View File

@@ -33,7 +33,7 @@ class SelectedItemsAdder : public Screen< NC::Menu<std::string> >
virtual void Resize() OVERRIDE;
virtual void Refresh() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -85,7 +85,7 @@ void ServerInfo::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> 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();

View File

@@ -30,7 +30,7 @@ class ServerInfo : public Screen<NC::Scrollpad>
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE;

View File

@@ -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;
@@ -513,7 +513,7 @@ void Configuration::Read()
}
else if (name == "progressbar_look")
{
std::basic_string<my_char_t> 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<my_char_t> 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);
}

View File

@@ -35,7 +35,7 @@ struct Column
{
Column() : stretch_limit(-1), right_alignment(0), display_empty_tag(1) { }
std::basic_string<my_char_t> 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<my_char_t> progressbar;
std::basic_string<my_char_t> 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<my_char_t> now_playing_suffix;
NC::WBuffer now_playing_suffix;
NC::Color color1;
NC::Color color2;

View File

@@ -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<my_char_t> &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<my_char_t> 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<my_char_t> &s = TO_WSTRING(tag);
std::wstring s = ToWString(tag);
if (NC::Window::length(s) > delimiter)
tag = Shorten(s, delimiter);
}

View File

@@ -64,9 +64,9 @@ void SongInfo::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> 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));
}
}

View File

@@ -38,7 +38,7 @@ class SongInfo : public Screen<NC::Scrollpad>
virtual void SwitchTo() OVERRIDE;
virtual void Resize() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -443,9 +443,9 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
tracklength += " kbps";
}
NC::basic_buffer<my_char_t> 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<my_char_t> 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<my_char_t> 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);

View File

@@ -201,9 +201,9 @@ void TagEditor::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> 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;
}

View File

@@ -41,7 +41,7 @@ class TagEditor : public Screen<NC::Window>, public Filterable, public HasSongs,
virtual void Resize();
virtual void SwitchTo();
virtual std::basic_string<my_char_t> Title();
virtual std::wstring Title();
virtual void Refresh();
virtual void Update();

View File

@@ -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<my_char_t> TinyTagEditor::Title()
std::wstring TinyTagEditor::Title()
{
return U("Tiny tag editor");
return L"Tiny tag editor";
}
void TinyTagEditor::EnterPressed()

View File

@@ -38,7 +38,7 @@ class TinyTagEditor : public Screen< NC::Menu<NC::Buffer> >
virtual void Resize() OVERRIDE;
virtual void SwitchTo() OVERRIDE;
virtual std::basic_string<my_char_t> Title() OVERRIDE;
virtual std::wstring Title() OVERRIDE;
virtual void Update() OVERRIDE { }

View File

@@ -102,9 +102,9 @@ void Visualizer::Resize()
hasToBeResized = 0;
}
std::basic_string<my_char_t> Visualizer::Title()
std::wstring Visualizer::Title()
{
return U("Music visualizer");
return L"Music visualizer";
}
void Visualizer::Update()

View File

@@ -38,7 +38,7 @@ class Visualizer : public Screen<NC::Window>
virtual void SwitchTo();
virtual void Resize();
virtual std::basic_string<my_char_t> Title();
virtual std::wstring Title();
virtual void Update();
virtual void Scroll(NC::Where) { }

View File

@@ -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