diff options
author | Kalle Wallin <kaw@linux.se> | 2005-06-11 09:14:52 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2005-06-11 09:14:52 +0000 |
commit | aa1b75b13528c723952cc1c0cd0ca078bbaddbe4 (patch) | |
tree | 0f292ffb5c3da0ab9f6d48fea22d48c3fb3f50a9 | |
parent | 38880bd748572c2f3b05c6625ab1029ece2483c4 (diff) | |
download | mpd-aa1b75b13528c723952cc1c0cd0ca078bbaddbe4.tar.gz mpd-aa1b75b13528c723952cc1c0cd0ca078bbaddbe4.tar.xz mpd-aa1b75b13528c723952cc1c0cd0ca078bbaddbe4.zip |
support wide-char ncurses library (ncursesw)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | configure.ac | 42 | ||||
-rw-r--r-- | src/list_window.c | 2 | ||||
-rw-r--r-- | src/support.c | 10 | ||||
-rw-r--r-- | src/support.h | 6 | ||||
-rw-r--r-- | src/wreadln.c | 7 |
6 files changed, 48 insertions, 26 deletions
@@ -1,3 +1,10 @@ +2005-06-11: Kalle Wallin <kaw@linux.se> + * configure.ac: support wide-char ncurses library (--with-ncursesw) + +2005-06-06: Kalle Wallin <kaw@linux.se> + * Added Norwegian translations from Ole R. Thorsen + * Added an artist (browser) screen + 2005-06-03: Kalle Wallin <kaw@linux.se> * 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 cdcab65b7..72043d467 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 7bbc6e193..896662292 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 254c15eb1..ade5ee4eb 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 0a72e39b0..8b4a28c18 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 930cb5429..d817ee628 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<wrln_max_line_size-1 ) + if( cursor < my_strlen(line) && cursor<wrln_max_line_size-1 ) { cursor++; if( cursor+x0 >= x1 && start<cursor-width+1) @@ -79,7 +80,7 @@ wreadln(WINDOW *w, } /* move the cursor to the end of the line */ void cursor_move_to_eol(void) { - cursor = strlen(line); + cursor = my_strlen(line); if( cursor+x0 >= 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]; |