From 5c62072713531dd4dd70aac73e675a884a4eaed7 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Fri, 16 Dec 2016 07:11:51 +0100 Subject: [PATCH] Require ncursesw --- NEWS | 1 + configure.ac | 49 +++++++++++++++++++------------------------ src/configuration.cpp | 3 --- src/window.cpp | 26 ++++++++++++----------- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/NEWS b/NEWS index 3819b092..0f96b059 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ ncmpcpp-0.8 (????-??-??) * Support for fetching lyrics for selected items in background was added. * Application will now exit if stdin is closed. * Configuration variable 'visualizer_sample_multiplier' was deprecated and will be removed in 0.9. +* Wide character version of ncurses is now required. ncmpcpp-0.7.7 (2016-10-31) * Fixed compilation on 32bit platforms. diff --git a/configure.ac b/configure.ac index 5e82924d..6fc5722e 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,6 @@ AM_PROG_LIBTOOL AC_ARG_ENABLE(outputs, AS_HELP_STRING([--enable-outputs], [Enable outputs screen @<:@default=no@:>@]), [outputs=$enableval], [outputs=no]) AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music visualizer screen @<:@default=no@:>@]), [visualizer=$enableval], [visualizer=no]) AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no]) -AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support @<:@default=yes@:>@]), [unicode=$enableval], [unicode=yes]) AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto]) AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto]) @@ -184,34 +183,30 @@ AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread", AC_MSG_ERROR([pthread library is required]) ) -dnl ======================== -dnl = checking for ncurses = -dnl ======================== -if test "$unicode" = "yes" ; then - curses_config_bin="ncursesw6-config ncursesw5-config" - AC_DEFINE([NCMPCPP_UNICODE], [1], [enables unicode support]) -else - curses_config_bin="ncurses6-config ncurses5-config" -fi - -AC_PATH_PROGS(CURSES_CONFIG, $curses_config_bin) -if test "$CURSES_CONFIG" != "" ; then - CPPFLAGS="$CPPFLAGS `$CURSES_CONFIG --cflags`" - LIBS="$LIBS `$CURSES_CONFIG --libs`" -fi -AC_CHECK_LIB(ncursesw, initscr, - curses_lib=ncursesw, - curses_lib=ncurses -) - -AC_CHECK_LIB($curses_lib, initscr, - if test "$CURSES_CONFIG" = "" ; then - LIBS="$LIBS -l$curses_lib" - fi +dnl ========================= +dnl = checking for ncursesw = +dnl ========================= +AH_TEMPLATE([NCURSES_WADDWSTR], [ncursesw has waddwstr function]) +AH_TEMPLATE([NCURSES_WADDNWSTR], [ncursesw has waddnwstr function]) +PKG_CHECK_MODULES([ncursesw], [ncursesw], [ + AC_SUBST(ncursesw_CFLAGS) + AC_SUBST(ncursesw_LIBS) + CPPFLAGS="$CPPFLAGS $ncursesw_CFLAGS" + AC_CHECK_HEADERS([curses.h], + LIBS="$LIBS $ncursesw_LIBS" , - AC_MSG_ERROR([$curses_lib library is required]) + AC_MSG_ERROR([missing curses.h header]) ) -AC_CHECK_HEADERS([curses.h], , AC_MSG_ERROR([missing curses.h header])) + AC_CHECK_LIB(ncursesw, initscr, , AC_MSG_ERROR([ncursesw doesn't provide initscr])) + AC_CHECK_LIB(ncursesw, waddwstr, + AC_DEFINE([NCURSES_WADDWSTR], [1], []), + AC_DEFINE([NCURSES_WADDWSTR], [0], [])) + AC_CHECK_LIB(ncursesw, waddnwstr, + AC_DEFINE([NCURSES_WADDNWSTR], [1], []), + AC_DEFINE([NCURSES_WADDNWSTR], [0], [])) +], + AC_MSG_ERROR([ncursesw is required!]) +) dnl ====================== dnl = checking for fftw3 = diff --git a/src/configuration.cpp b/src/configuration.cpp index b5ef96e1..b179f38e 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -128,9 +128,6 @@ bool configure(int argc, char **argv) << " ncurses" # ifdef HAVE_TAGLIB_H << " taglib" - # endif - # ifdef NCMPCPP_UNICODE - << " unicode" # endif << "\n"; return false; diff --git a/src/window.cpp b/src/window.cpp index aead6e75..de5e2954 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1335,29 +1335,31 @@ Window &Window::operator<<(const char *s) Window &Window::operator<<(char c) { - // the following causes problems: https://github.com/arybczak/ncmpcpp/issues/21 - // waddnstr(m_window, &c, 1); - wprintw(m_window, "%c", c); + // Might cause problem similar to + // https://github.com/arybczak/ncmpcpp/issues/21, enable for testing as the + // code in the ticket supposed to be culprit was rewritten. + waddnstr(m_window, &c, 1); + //wprintw(m_window, "%c", c); return *this; } Window &Window::operator<<(const wchar_t *ws) { -# ifdef NCMPCPP_UNICODE +#if NCURSES_WADDWSTR waddwstr(m_window, ws); -# else +#else wprintw(m_window, "%ls", ws); -# endif // NCMPCPP_UNICODE +#endif // NCURSES_WADDWSTR return *this; } Window &Window::operator<<(wchar_t wc) { -# ifdef NCMPCPP_UNICODE +#if NCURSES_WADDNWSTR waddnwstr(m_window, &wc, 1); -# else +#else wprintw(m_window, "%lc", wc); -# endif // NCMPCPP_UNICODE +#endif // NCURSES_WADDNWSTR return *this; } @@ -1381,11 +1383,11 @@ Window &Window::operator<<(const std::string &s) Window &Window::operator<<(const std::wstring &ws) { -# ifdef NCMPCPP_UNICODE +#if NCURSES_WADDNWSTR waddnwstr(m_window, ws.c_str(), ws.length()); -# else +#else wprintw(m_window, "%lc", ws.c_str()); -# endif // NCMPCPP_UNICODE +#endif // NCURSES_WADDNWSTR return *this; }