allow for unicode characters in progressbar_look

This commit is contained in:
Andrzej Rybczak
2009-08-26 18:13:33 +02:00
parent 6f88f9aeb2
commit bc1a8a2d1a
5 changed files with 14 additions and 9 deletions

View File

@@ -98,6 +98,8 @@ namespace
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
setlocale(LC_ALL, "");
CreateConfigDir(); CreateConfigDir();
DefaultConfiguration(Config); DefaultConfiguration(Config);
DefaultKeys(Key); DefaultKeys(Key);
@@ -1136,8 +1138,9 @@ int main(int argc, char *argv[])
int howlong = wFooter->GetWidth()*progressbar_size; int howlong = wFooter->GetWidth()*progressbar_size;
mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth()); mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth());
mvwhline(wFooter->Raw(), 0, 0, Config.progressbar[0], howlong); for (int i = 0; i < howlong; ++i)
mvwaddch(wFooter->Raw(), 0, howlong, Config.progressbar[1]); *wFooter << Config.progressbar[0];
*wFooter << Config.progressbar[1];
*wFooter << fmtBoldEnd; *wFooter << fmtBoldEnd;
wFooter->Refresh(); wFooter->Refresh();
} }

View File

@@ -24,6 +24,7 @@
# include <sys/stat.h> # include <sys/stat.h>
#endif // WIN32 #endif // WIN32
#include <fstream> #include <fstream>
#include <stdexcept>
#include "global.h" #include "global.h"
#include "helpers.h" #include "helpers.h"
@@ -251,7 +252,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.new_header_first_line = "{$b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b}"; conf.new_header_first_line = "{$b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b}";
conf.new_header_second_line = "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}"; conf.new_header_second_line = "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}";
conf.browser_playlist_prefix << clRed << "(playlist)" << clEnd << ' '; conf.browser_playlist_prefix << clRed << "(playlist)" << clEnd << ' ';
conf.progressbar = "=>"; conf.progressbar = U("=>");
conf.pattern = "%n - %t"; conf.pattern = "%n - %t";
conf.selected_item_prefix << clMagenta; conf.selected_item_prefix << clMagenta;
conf.selected_item_suffix << clEnd; conf.selected_item_suffix << clEnd;
@@ -624,8 +625,9 @@ void ReadConfiguration(ncmpcpp_config &conf)
} }
else if (cl.find("progressbar_look") != std::string::npos) else if (cl.find("progressbar_look") != std::string::npos)
{ {
if (v.length() == 2) conf.progressbar = TO_WSTRING(v);
conf.progressbar = v; if (conf.progressbar.length() != 2)
throw std::runtime_error("the length of progressbar_look is not two characters long!");
} }
else if (cl.find("default_tag_editor_pattern") != std::string::npos) else if (cl.find("default_tag_editor_pattern") != std::string::npos)
{ {

View File

@@ -139,7 +139,7 @@ struct ncmpcpp_config
std::string execute_on_song_change; std::string execute_on_song_change;
std::string new_header_first_line; std::string new_header_first_line;
std::string new_header_second_line; std::string new_header_second_line;
std::string progressbar; std::basic_string<my_char_t> progressbar;
std::string pattern; std::string pattern;

View File

@@ -502,8 +502,9 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth()); mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth());
if (np.GetTotalLength()) if (np.GetTotalLength())
{ {
mvwhline(wFooter->Raw(), 0, 0, Config.progressbar[0], howlong); for (int i = 0; i < howlong; ++i)
mvwaddch(wFooter->Raw(), 0, howlong, Config.progressbar[1]); *wFooter << Config.progressbar[0];
*wFooter << Config.progressbar[1];
} }
wFooter->SetColor(Config.statusbar_color); wFooter->SetColor(Config.statusbar_color);
} }

View File

@@ -37,7 +37,6 @@ void NCurses::InitScreen(GNUC_UNUSED const char *window_title, bool enable_color
COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
}; };
setlocale(LC_ALL, "");
# ifdef XCURSES # ifdef XCURSES
Xinitscr(1, const_cast<char **>(&window_title)); Xinitscr(1, const_cast<char **>(&window_title));
# else # else