summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@gmail.com>2020-02-12 21:39:42 +0100
committerBenjamin Franzke <benjaminfranzke@gmail.com>2020-02-15 11:12:20 +0100
commit9cdfd67c90fec99151505518b8ee0b78e171d6fc (patch)
tree2465441ae63b60bf35498ecdde3c1ad4cf80ee94
parent4aa2b7230439dd1c5c357b685365e915f3171aa2 (diff)
downloadpa-sink-ctl-9cdfd67c90fec99151505518b8ee0b78e171d6fc.tar.gz
pa-sink-ctl-9cdfd67c90fec99151505518b8ee0b78e171d6fc.tar.bz2
pa-sink-ctl-9cdfd67c90fec99151505518b8ee0b78e171d6fc.zip
Support UTF-8 characters
Switch to ncursesw (using pkg-config) for UTF-8 support. Fallback to a X/Open Curses specification compatible curses implementation if ncursesw is not available. The fallback is intended for non-ncurses systems only. TODO: add proper check that the fallback X/Open Curses implementation is wide character (utf-8) capable. (Can't add right now, as we don't know about an incompatiblity)
-rw-r--r--configure.ac11
-rw-r--r--src/interface.c2
-rw-r--r--src/interface.h2
-rw-r--r--src/pa-sink-ctl.c2
4 files changed, 10 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index fc6ec3f..cfc0243 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
-AC_CHECK_HEADERS([ncurses.h sys/ioctl.h sys/signalfd.h unistd.h signal.h])
+AC_CHECK_HEADERS([sys/ioctl.h sys/signalfd.h unistd.h signal.h])
AC_CHECK_FUNCS([signalfd])
@@ -41,19 +41,20 @@ if test "x$ac_cv_func_signalfd" = "xno" -o "x$ac_cv_header_sys_signalfd_h" = "xn
fi
# Checks for libraries.
-AC_CHECK_LIB([ncurses], [newwin], [CURSES_LIBS=-lncurses], AC_MSG_ERROR([curses required]))
-
PKG_CHECK_MODULES(PULSE, [libpulse], [], AC_MSG_ERROR([libpulse required]))
PKG_CHECK_MODULES(PULSE_MAINLOOP, [libpulse-mainloop-glib], [], AC_MSG_ERROR([libpulse-mainloop-glib required]))
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= $glib_version], [], AC_MSG_ERROR([glib >= $glib_version required]))
+PKG_CHECK_MODULES(CURSES, [ncursesw], [],
+ AC_CHECK_LIB([curses], [newwin], [CURSES_LIBS=-lcurses], AC_MSG_ERROR([ncursesw or curses required]))
+ AC_CHECK_HEADERS([curses.h])
+ AC_SUBST(CURSES_LIBS)
+)
if test "x$GCC" = "xyes"; then
GCC_CFLAGS="-Wall -pedantic -std=c99 -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option -fvisibility=hidden"
fi
AC_SUBST(GCC_CFLAGS)
-AC_SUBST(CURSES_LIBS)
-
AC_DEFINE([_POSIX_C_SOURCE], [1], [Enable POSIX.1-1990 definitions])
AC_C_INLINE
diff --git a/src/interface.c b/src/interface.c
index c7d6d5e..3086ce1 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -24,7 +24,7 @@
#include <glib.h>
#include <pulse/pulseaudio.h>
-#include <ncurses.h>
+#include <curses.h>
#include "interface.h"
#include "ctl.h"
diff --git a/src/interface.h b/src/interface.h
index ef7cdc2..61ce990 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -22,7 +22,7 @@
#include <glib.h>
#include <pulse/pulseaudio.h>
-#include <ncurses.h>
+#include <curses.h>
#define SELECTED_MAIN_CTL -1
#define H_MSG_BOX 3
diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c
index 4e17337..5c0f7fc 100644
--- a/src/pa-sink-ctl.c
+++ b/src/pa-sink-ctl.c
@@ -21,6 +21,7 @@
#include <pulse/pulseaudio.h>
#include <pulse/glib-mainloop.h>
#include <string.h>
+#include <locale.h>
#include "ctl.h"
#include "interface.h"
@@ -570,6 +571,7 @@ main(int argc, char** argv)
pa_mainloop_api *mainloop_api = NULL;
pa_glib_mainloop *m = NULL;
+ setlocale(LC_ALL, "");
memset(&ctx, 0, sizeof ctx);
ctx.sink_list = NULL;