window: use simpler functions than wprintw if possible
This commit is contained in:
@@ -1109,27 +1109,33 @@ Window &Window::operator<<(const XY &coords)
|
|||||||
|
|
||||||
Window &Window::operator<<(const char *s)
|
Window &Window::operator<<(const char *s)
|
||||||
{
|
{
|
||||||
for (const char *c = s; *c != '\0'; ++c)
|
waddstr(m_window, s);
|
||||||
wprintw(m_window, "%c", *c);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window &Window::operator<<(char c)
|
Window &Window::operator<<(char c)
|
||||||
{
|
{
|
||||||
wprintw(m_window, "%c", c);
|
waddch(m_window, c);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window &Window::operator<<(const wchar_t *ws)
|
Window &Window::operator<<(const wchar_t *ws)
|
||||||
{
|
{
|
||||||
for (const wchar_t *wc = ws; *wc != L'\0'; ++wc)
|
# ifdef NCMPCPP_UNICODE
|
||||||
wprintw(m_window, "%lc", *wc);
|
waddwstr(m_window, ws);
|
||||||
|
# else
|
||||||
|
wprintw(m_window, "%ls", ws);
|
||||||
|
# endif // NCMPCPP_UNICODE
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window &Window::operator<<(wchar_t wc)
|
Window &Window::operator<<(wchar_t wc)
|
||||||
{
|
{
|
||||||
|
# ifdef NCMPCPP_UNICODE
|
||||||
|
waddnwstr(m_window, &wc, 1);
|
||||||
|
# else
|
||||||
wprintw(m_window, "%lc", wc);
|
wprintw(m_window, "%lc", wc);
|
||||||
|
# endif // NCMPCPP_UNICODE
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1147,18 +1153,17 @@ Window &Window::operator<<(double d)
|
|||||||
|
|
||||||
Window &Window::operator<<(const std::string &s)
|
Window &Window::operator<<(const std::string &s)
|
||||||
{
|
{
|
||||||
// for some reason passing whole string at once with "%s" doesn't work
|
waddnstr(m_window, s.c_str(), s.length());
|
||||||
// (string is cut in the middle, probably due to limitation of ncurses'
|
|
||||||
// internal buffer?), so we need to pass characters in a loop.
|
|
||||||
for (auto it = s.begin(); it != s.end(); ++it)
|
|
||||||
wprintw(m_window, "%c", *it);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window &Window::operator<<(const std::wstring &ws)
|
Window &Window::operator<<(const std::wstring &ws)
|
||||||
{
|
{
|
||||||
for (auto it = ws.begin(); it != ws.end(); ++it)
|
# ifdef NCMPCPP_UNICODE
|
||||||
wprintw(m_window, "%lc", *it);
|
waddnwstr(m_window, ws.c_str(), ws.length());
|
||||||
|
# else
|
||||||
|
wprintw(m_window, "%lc", ws.c_str());
|
||||||
|
# endif // NCMPCPP_UNICODE
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user