mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 13:23:26 +01:00
Merge pull request #2 from jin-eld/add-widechar-checks
Add widechar checks
This commit is contained in:
commit
9bea24a317
@ -15,7 +15,8 @@ toxic_SOURCES = $(top_srcdir)/src/main.c \
|
|||||||
$(top_srcdir)/src/dhtstatus.h \
|
$(top_srcdir)/src/dhtstatus.h \
|
||||||
$(top_srcdir)/src/dhtstatus.c
|
$(top_srcdir)/src/dhtstatus.c
|
||||||
|
|
||||||
toxic_CFLAGS = $(NCURSES_CFLAGS) \
|
toxic_CFLAGS = -I$(top_srcdir) \
|
||||||
|
$(NCURSES_CFLAGS) \
|
||||||
$(LIBSODIUM_CFLAGS) \
|
$(LIBSODIUM_CFLAGS) \
|
||||||
$(LIBTOXCORE_CFLAGS)
|
$(LIBTOXCORE_CFLAGS)
|
||||||
|
|
||||||
|
31
configure.ac
31
configure.ac
@ -108,12 +108,19 @@ AC_CHECK_FUNCS(
|
|||||||
# pkg-config based tests
|
# pkg-config based tests
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
|
NCURSES_WIDECHAR_SUPPORT="yes"
|
||||||
if test -n "$PKG_CONFIG"; then
|
if test -n "$PKG_CONFIG"; then
|
||||||
if test "$WIN32" != "xyes"; then
|
if test "$WIN32" != "xyes"; then
|
||||||
PKG_CHECK_MODULES([NCURSES], [ncursesw], [],
|
PKG_CHECK_MODULES([NCURSES], [ncursesw],
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
NCURSES_WIDECHAR_SUPPORT="no"
|
||||||
|
PKG_CHECK_MODULES([NCURSES], [ncurses],
|
||||||
|
[],
|
||||||
[
|
[
|
||||||
AC_MSG_ERROR([required library ncursesw was not found on your system: $NCURSES_PKG_ERRORS])
|
AC_MSG_ERROR([required library ncursesw was not found on your system: $NCURSES_PKG_ERRORS])
|
||||||
])
|
])
|
||||||
|
])
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
AC_MSG_WARN([pkg-config was not found on your sytem])
|
AC_MSG_WARN([pkg-config was not found on your sytem])
|
||||||
@ -129,6 +136,8 @@ if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then
|
|||||||
)
|
)
|
||||||
|
|
||||||
if test "x$WIN32" = "xyes"; then
|
if test "x$WIN32" = "xyes"; then
|
||||||
|
dnl Check if pdcurses provides wide char support
|
||||||
|
NCURSES_WIDECHAR_SUPPORT="no"
|
||||||
AC_CHECK_LIB([pdcurses], [clear],
|
AC_CHECK_LIB([pdcurses], [clear],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
@ -151,6 +160,14 @@ if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then
|
|||||||
[
|
[
|
||||||
unset ac_cv_lib_ncursesw_get_wch
|
unset ac_cv_lib_ncursesw_get_wch
|
||||||
AC_CHECK_LIB([ncursesw], [get_wch],
|
AC_CHECK_LIB([ncursesw], [get_wch],
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
NCURSES_WIDECHAR_SUPPORT="no"
|
||||||
|
AC_CHECK_LIB([ncurses], [clear],
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
unset ac_cv_lib_ncursesw_get_wch
|
||||||
|
AC_CHECK_LIB([ncurses], [clear],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
AC_MSG_ERROR([required library ncurses was not found on your system])
|
AC_MSG_ERROR([required library ncurses was not found on your system])
|
||||||
@ -161,6 +178,13 @@ if (test -z "$PKG_CONFIG") || (test "x$WIN32" = "xyes"); then
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-ltinfo
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -292,6 +316,11 @@ eval PACKAGE_DATADIR="${datadir}/${PACKAGE}"
|
|||||||
eval PACKAGE_DATADIR="${PACKAGE_DATADIR}"
|
eval PACKAGE_DATADIR="${PACKAGE_DATADIR}"
|
||||||
AC_DEFINE_UNQUOTED(PACKAGE_DATADIR, "$PACKAGE_DATADIR", [toxic data directory])
|
AC_DEFINE_UNQUOTED(PACKAGE_DATADIR, "$PACKAGE_DATADIR", [toxic data directory])
|
||||||
|
|
||||||
|
if test "x$NCURSES_WIDECHAR_SUPPORT" = "xyes"; then
|
||||||
|
AC_DEFINE([HAVE_WIDECHAR], [1], [ncurses wide char support available])
|
||||||
|
AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1],
|
||||||
|
[enable X/Open Portability Guide functionality])
|
||||||
|
fi
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
misc/Makefile
|
misc/Makefile
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
* Toxic -- Tox Curses Client
|
* Toxic -- Tox Curses Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -182,7 +186,11 @@ static void chat_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
|||||||
getmaxyx(self->window, y2, x2);
|
getmaxyx(self->window, y2, x2);
|
||||||
|
|
||||||
/* Add printable chars to buffer and print on input space */
|
/* Add printable chars to buffer and print on input space */
|
||||||
|
#if HAVE_WIDECHAR
|
||||||
if (iswprint(key)) {
|
if (iswprint(key)) {
|
||||||
|
#else
|
||||||
|
if (isprint(key)) {
|
||||||
|
#endif
|
||||||
if (ctx->pos != sizeof(ctx->line) - 1) {
|
if (ctx->pos != sizeof(ctx->line) - 1) {
|
||||||
mvwaddstr(self->window, y, x, wc_to_char(key));
|
mvwaddstr(self->window, y, x, wc_to_char(key));
|
||||||
ctx->line[ctx->pos++] = key;
|
ctx->line[ctx->pos++] = key;
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "dhtstatus.h"
|
#include "dhtstatus.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
* Toxic -- Tox Curses Client
|
* Toxic -- Tox Curses Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _XOPEN_SOURCE_EXTENDED
|
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
* Toxic -- Tox Curses Client
|
* Toxic -- Tox Curses Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#ifndef _windows_h
|
#ifndef _windows_h
|
||||||
#define _windows_h
|
#define _windows_h
|
||||||
|
|
||||||
#define _XOPEN_SOURCE_EXTENDED
|
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "friendlist.h"
|
#include "friendlist.h"
|
||||||
#include "prompt.h"
|
#include "prompt.h"
|
||||||
#include "dhtstatus.h"
|
#include "dhtstatus.h"
|
||||||
@ -234,7 +238,11 @@ void draw_active_window(Messenger *m)
|
|||||||
a->onDraw(a, m);
|
a->onDraw(a, m);
|
||||||
|
|
||||||
/* Handle input */
|
/* Handle input */
|
||||||
|
#ifdef HAVE_WIDECHAR
|
||||||
get_wch(&ch);
|
get_wch(&ch);
|
||||||
|
#else
|
||||||
|
ch = getch();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ch == '\t' || ch == KEY_BTAB)
|
if (ch == '\t' || ch == KEY_BTAB)
|
||||||
set_next_window((int) ch);
|
set_next_window((int) ch);
|
||||||
|
Loading…
Reference in New Issue
Block a user