Browse Source

* Fixed UTF-8 support in ncurses.

* Set ncurses's priority higher than slang.
tags/v0.99.beta14
Sam Hocevar sam 19 years ago
parent
commit
ec3b082509
3 changed files with 28 additions and 21 deletions
  1. +5
    -5
      caca/caca.c
  2. +22
    -15
      caca/driver_ncurses.c
  3. +1
    -1
      configure.ac

+ 5
- 5
caca/caca.c View File

@@ -161,14 +161,14 @@ static int caca_init_driver(caca_display_t *dp)
#if defined(USE_GL)
if(gl_install(dp) == 0) return 0;
#endif
/* slang has a higher priority than ncurses because though ncurses handles
* color a bit better across terminals, its UTF-8 supports seems broken. */
#if defined(USE_SLANG)
if(slang_install(dp) == 0) return 0;
#endif
/* ncurses has a higher priority than slang because it has better colour
* support across terminal types, despite being slightly slower. */
#if defined(USE_NCURSES)
if(ncurses_install(dp) == 0) return 0;
#endif
#if defined(USE_SLANG)
if(slang_install(dp) == 0) return 0;
#endif

return -1;
}


+ 22
- 15
caca/driver_ncurses.c View File

@@ -18,13 +18,13 @@
#include "config.h"
#include "common.h"

#if defined(USE_NCURSES)
#if defined USE_NCURSES

#if defined(HAVE_NCURSESW_NCURSES_H)
#if defined HAVE_NCURSESW_NCURSES_H
# include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSES_NCURSES_H)
#elif defined HAVE_NCURSES_NCURSES_H
# include <ncurses/ncurses.h>
#elif defined(HAVE_NCURSES_H)
#elif defined HAVE_NCURSES_H
# include <ncurses.h>
#else
# include <curses.h>
@@ -33,12 +33,15 @@
#include <stdlib.h>
#include <string.h>

#if defined(HAVE_SIGNAL_H)
#if defined HAVE_SIGNAL_H
# include <signal.h>
#endif
#if defined(HAVE_SYS_IOCTL_H)
#if defined HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if defined HAVE_LOCALE_H
# include <locale.h>
#endif

#include "caca.h"
#include "caca_internals.h"
@@ -49,11 +52,11 @@
* Local functions
*/

#if defined(HAVE_SIGNAL)
#if defined HAVE_SIGNAL
static RETSIGTYPE sigwinch_handler(int);
static caca_display_t *sigwinch_d; /* FIXME: we ought to get rid of this */
#endif
#if defined(HAVE_GETENV) && defined(HAVE_PUTENV)
#if defined HAVE_GETENV && defined HAVE_PUTENV
static void ncurses_check_terminal(void);
#endif
static void ncurses_write_utf32(uint32_t);
@@ -93,15 +96,19 @@ static int ncurses_init_graphics(caca_display_t *dp)

dp->drv.p = malloc(sizeof(struct driver_private));

#if defined(HAVE_GETENV) && defined(HAVE_PUTENV)
#if defined HAVE_GETENV && defined HAVE_PUTENV
ncurses_check_terminal();
#endif

#if defined(HAVE_SIGNAL)
#if defined HAVE_SIGNAL
sigwinch_d = dp;
signal(SIGWINCH, sigwinch_handler);
#endif

#if defined HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif

initscr();
keypad(stdscr, TRUE);
nonl();
@@ -207,12 +214,12 @@ static void ncurses_handle_resize(caca_display_t *dp)
{
struct winsize size;

#if defined(HAVE_SYS_IOCTL_H)
#if defined HAVE_SYS_IOCTL_H
if(ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0)
{
dp->resize.w = size.ws_col;
dp->resize.h = size.ws_row;
#if defined(HAVE_RESIZE_TERM)
#if defined HAVE_RESIZE_TERM
resize_term(dp->resize.h, dp->resize.w);
#else
resizeterm(*dp->resize.h, *dp->resize.w);
@@ -352,7 +359,7 @@ static int ncurses_get_event(caca_display_t *dp, caca_event_t *ev)
* XXX: following functions are local
*/

#if defined(HAVE_SIGNAL)
#if defined HAVE_SIGNAL
static RETSIGTYPE sigwinch_handler(int sig)
{
sigwinch_d->resize.resized = 1;
@@ -361,7 +368,7 @@ static RETSIGTYPE sigwinch_handler(int sig)
}
#endif

#if defined(HAVE_GETENV) && defined(HAVE_PUTENV)
#if defined HAVE_GETENV && defined HAVE_PUTENV
static void ncurses_check_terminal(void)
{
char *term, *colorterm, *other;
@@ -401,7 +408,7 @@ static void ncurses_check_terminal(void)

static void ncurses_write_utf32(uint32_t ch)
{
#if defined(HAVE_NCURSESW_NCURSES_H)
#if defined HAVE_NCURSESW_NCURSES_H
char buf[10];
int bytes;



+ 1
- 1
configure.ac View File

@@ -65,7 +65,7 @@ dnl conditional builds
AC_ARG_ENABLE(doc,
[ --enable-doc build documentation (needs doxygen and LaTeX)])

AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h)
AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h locale.h)
AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
AC_CHECK_FUNCS(usleep gettimeofday)



Loading…
Cancel
Save