From: Kalle Wallin Date: Sat, 11 Jun 2005 09:14:52 +0000 (+0000) Subject: support wide-char ncurses library (ncursesw) X-Git-Tag: v0.12_alpha1~421 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=aa1b75b13528c723952cc1c0cd0ca078bbaddbe4;p=ncmpc.git support wide-char ncurses library (ncursesw) git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3325 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/ChangeLog b/ChangeLog index 85e7fd5..964bfcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-06-11: Kalle Wallin + * configure.ac: support wide-char ncurses library (--with-ncursesw) + +2005-06-06: Kalle Wallin + * Added Norwegian translations from Ole R. Thorsen + * Added an artist (browser) screen + 2005-06-03: Kalle Wallin * Seek time can now be defined in the conf file (seek-time) * Added a "hide cursor" feature #0000417 (hide-cursor) diff --git a/configure.ac b/configure.ac index cdcab65..72043d4 100644 --- a/configure.ac +++ b/configure.ac @@ -52,10 +52,22 @@ dnl Check for libraries dnl dnl ncurses -AC_CHECK_LIB([ncurses], +ncurses=ncurses +AC_ARG_WITH([ncurses], + AC_HELP_STRING([--with-ncurses], [compile/link with ncurses library]), + [ncurses=ncurses]) +AC_ARG_WITH(ncursesw, + AC_HELP_STRING([--with-ncursesw], [compile/link with wide-char ncurses library]), + [ncurses=ncursesw]) + +AC_CHECK_LIB([$ncurses], [initscr], - [LIBS="$LIBS -lncurses"], - [AC_MSG_ERROR(ncurses library is required)]) + [LIBS="$LIBS -l$ncurses"], + [AC_MSG_ERROR($ncurses library is required)]) + +if test "x$ncurses" = "xncursesw" ; then + AC_DEFINE(USE_NCURSESW, 1, [use wide-char ncurses library]) +fi dnl Check for glib-2.4 @@ -153,25 +165,13 @@ AC_ARG_ENABLE([mouse], [getmouse=yes]) AC_MSG_RESULT([$getmouse]) if test "x$getmouse" = "xyes" ; then - AC_CHECK_LIB([ncurses], + AC_CHECK_LIB([$ncurses], [getmouse], - [AC_DEFINE([HAVE_GETMOUSE], [1], [ncurses - getmouse()])], + [AC_DEFINE([HAVE_GETMOUSE], [1], [$ncurses - getmouse()])], []) fi -dnl artist screen -AC_MSG_CHECKING([whether to include the artist screen]) -AC_ARG_ENABLE([artist-screen], - AC_HELP_STRING([--enable-artist-screen], - [Enable artist screen (EXPERIMENTAL) @<:@default=no@:>@]), - [artist_screen="$enableval"], - [artist_screen=no]) -AC_MSG_RESULT([$artist_screen]) -if test "x$artist_screen" != "xyes" ; then - AC_DEFINE(DISABLE_ARTIST_SCREEN, 1, [Disable artist screen]) -fi - -dnl artist screen +dnl Optional screen - artist AC_MSG_CHECKING([whether to include the artist screen]) AC_ARG_ENABLE([artist-screen], AC_HELP_STRING([--enable-artist-screen], @@ -183,7 +183,7 @@ if test "x$artist_screen" != "xyes" ; then AC_DEFINE(DISABLE_ARTIST_SCREEN, 1, [Disable artist screen]) fi -dnl search screen +dnl Optional screen - search AC_MSG_CHECKING([whether to include the search screen]) AC_ARG_ENABLE([search-screen], AC_HELP_STRING([--enable-search-screen], @@ -211,9 +211,9 @@ dnl Optional screen - clock AC_MSG_CHECKING([whether to include the clock screen]) AC_ARG_ENABLE([clock-screen], AC_HELP_STRING([--enable-clock-screen], - [Enable clock screen @<:@default=no@:>@]), + [Enable clock screen @<:@default=yes@:>@]), [clock_screen="$enableval"], - [clock_screen=no]) + [clock_screen=yes]) AC_MSG_RESULT([$clock_screen]) if test "x$clock_screen" != "xyes" ; then AC_DEFINE(DISABLE_CLOCK_SCREEN, 1, [Disable clock screen]) diff --git a/src/list_window.c b/src/list_window.c index 7bbc6e1..8966622 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -193,7 +193,7 @@ list_window_paint(list_window_t *lw, if( label ) { int selected = lw->start+i == lw->selected; - size_t len = strlen(label); + size_t len = my_strlen(label); if( highlight ) colors_use(lw->w, COLOR_LIST_BOLD); diff --git a/src/support.c b/src/support.c index 254c15e..ade5ee4 100644 --- a/src/support.c +++ b/src/support.c @@ -35,6 +35,15 @@ extern void screen_status_printf(char *format, ...); static gboolean noconvert = TRUE; +size_t +my_strlen(char *str) +{ + if( g_utf8_validate(str,-1,NULL) ) + return g_utf8_strlen(str,-1); + else + return strlen(str); +} + char * remove_trailing_slash(char *path) { @@ -136,7 +145,6 @@ strscroll(char *str, char *separator, int width, scroll_state_t *st) } - void charset_init(gboolean disable) { diff --git a/src/support.h b/src/support.h index 0a72e39..8b4a28c 100644 --- a/src/support.h +++ b/src/support.h @@ -28,4 +28,10 @@ void charset_init(gboolean disable); char *utf8_to_locale(char *str); char *locale_to_utf8(char *str); +/* number of characters in str */ +size_t my_strlen(char *str); +/* number of bytes in str */ +size_t my_strsize(char *str); + + #endif diff --git a/src/wreadln.c b/src/wreadln.c index 930cb54..d817ee6 100644 --- a/src/wreadln.c +++ b/src/wreadln.c @@ -44,6 +44,7 @@ wrln_gcmp_pre_cb_t wrln_pre_completion_callback = NULL; wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL; extern void screen_bell(void); +extern size_t my_strlen(char *str); gchar * wreadln(WINDOW *w, @@ -61,7 +62,7 @@ wreadln(WINDOW *w, /* move the cursor one step to the right */ void cursor_move_right(void) { - if( cursor < strlen(line) && cursor= x1 && start= x1 ) start = cursor-width+1; } @@ -247,7 +248,7 @@ wreadln(WINDOW *w, break; case KEY_DC: /* handle delete key. As above */ case KEY_CTRL_D: - if( cursor <= strlen(line) - 1 ) + if( cursor <= my_strlen(line) - 1 ) { for (i = cursor; line[i] != 0; i++) line[i] = line[i + 1];