]> git.sesse.net Git - vlc/commitdiff
ncurses: fallback on libncurses if libncursesw isn't available (macosx)
authorRafaël Carré <funman@videolan.org>
Thu, 13 Sep 2007 21:58:05 +0000 (21:58 +0000)
committerRafaël Carré <funman@videolan.org>
Thu, 13 Sep 2007 21:58:05 +0000 (21:58 +0000)
it is now enabled by default if headers & library are present

configure.ac
modules/gui/ncurses.c

index 1f852d036fb270caf733eb3d6fcd2012fa21b84a..0ad27e25eaf76d6c4f804b46d59813ec686d216e 100644 (file)
@@ -5310,12 +5310,20 @@ dnl
 dnl  ncurses module
 dnl
 AC_ARG_ENABLE(ncurses,
-  [  --enable-ncurses        ncurses interface support (default disabled)],
-  [if test "${enable_ncurses}" = "yes"; then
-     AC_CHECK_HEADERS(ncursesw/curses.h,[
-       VLC_ADD_PLUGINS([ncurses])
-       VLC_ADD_LDFLAGS([ncurses],[-lncursesw])
-     ])
+  [  --disable-ncurses        ncurses interface support (default enabled)],
+  [if test "${enable_ncurses}" != "no"; then
+     AC_CHECK_HEADERS(ncursesw/curses.h,
+       [AC_CHECK_LIB( ncursesw, mvprintw,
+         [VLC_ADD_PLUGINS([ncurses])
+         VLC_ADD_LDFLAGS([ncurses],[-lncursesw])])
+       ],
+       [AC_CHECK_HEADER(curses.h,
+         [AC_CHECK_LIB(ncurses, mvprintw,
+           [VLC_ADD_PLUGINS([ncurses])
+           VLC_ADD_LDFLAGS([ncurses],[-lncurses])]
+         )]
+       )]
+     )  
    fi])
 
 dnl
index c4c1f580d06ee3786252892fd4c1e43cd5748b57..81313ec4060ac3fb71c4f24e9d19d739f1a7ad2b 100644 (file)
 #include <errno.h>                                                 /* ENOMEM */
 #include <time.h>
 
+#ifdef HAVE_NCURSESW_CURSES_H
 #include <ncursesw/curses.h>
+#else
+#include <curses.h>
+#endif
 
 #include <vlc_interface.h>
 #include <vlc_vout.h>
@@ -1125,9 +1129,11 @@ static void mvnprintw( int y, int x, int w, const char *p_fmt, ... )
     va_list  vl_args;
     char    *p_buf = NULL;
     int      i_len;
+#ifdef HAVE_NCURSESW_CURSES_H
     size_t   i_char_len;    /* UCS character length */
     size_t   i_width;       /* Display width */
     wchar_t *psz_wide;      /* wchar_t representation of p_buf */
+#endif
 
     va_start( vl_args, p_fmt );
     vasprintf( &p_buf, p_fmt, vl_args );
@@ -1137,6 +1143,7 @@ static void mvnprintw( int y, int x, int w, const char *p_fmt, ... )
         return;
 
     i_len = strlen( p_buf );
+#ifdef HAVE_NCURSESW_CURSES_H
     psz_wide = (wchar_t *) malloc( sizeof( wchar_t ) * ( i_len + 1 ) );
 
     i_char_len = mbstowcs( psz_wide, p_buf, i_len );
@@ -1149,9 +1156,11 @@ static void mvnprintw( int y, int x, int w, const char *p_fmt, ... )
         if( i_width == -1 ) /* a non printable character was encountered */
             i_width = i_len;
     }
-
     if( i_width > w )
-    { /* FIXME: ellipsize psz_wide while keeping the width in mind */
+#else
+    if( i_len > w )
+#endif
+    { /* FIXME: ncursesw: ellipsize psz_wide while keeping the width in mind */
         char *psz_local;
         int i_cut = i_len - w;
         int x1 = i_len/2 - i_cut/2;
@@ -1177,7 +1186,11 @@ static void mvnprintw( int y, int x, int w, const char *p_fmt, ... )
         char *psz_local = ToLocale( p_buf );
         mvprintw( y, x, "%s", psz_local );
         LocaleFree( p_buf );
+#ifdef HAVE_NCURSESW_CURSES_H
         mvhline( y, x + i_width, ' ', w - i_width );
+#else
+        mvhline( y, x + i_len, ' ', w - i_len );
+#endif
     }
 }
 static void MainBoxWrite( intf_thread_t *p_intf, int l, int x, const char *p_fmt, ... )