1 /*****************************************************************************
2 * ncurses.c : NCurses interface for vlc
3 *****************************************************************************
4 * Copyright © 2001-2010 the VideoLAN team
7 * Authors: Sam Hocevar <sam@zoy.org>
8 * Laurent Aimar <fenrir@via.ecp.fr>
9 * Yoann Peronneau <yoann@videolan.org>
10 * Derk-Jan Hartman <hartman at videolan dot org>
11 * Rafaël Carré <funman@videolanorg>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
29 * Note that when we use wide characters (and link with libncursesw),
30 * we assume that an UTF8 locale is used (or compatible, such as ASCII).
31 * Other characters encodings are not supported.
34 /*****************************************************************************
36 *****************************************************************************/
41 #include <vlc_common.h>
42 #include <vlc_plugin.h>
45 # define _XOPEN_SOURCE_EXTENDED 1
51 #include <vlc_interface.h>
54 #include <vlc_charset.h>
55 #include <vlc_input.h>
57 #include <vlc_playlist.h>
63 #ifdef HAVE_SYS_STAT_H
64 # include <sys/stat.h>
67 #define SEARCH_CHAIN_SIZE 20
68 #define OPEN_CHAIN_SIZE 50
70 /*****************************************************************************
72 *****************************************************************************/
73 static int Open ( vlc_object_t * );
74 static void Close ( vlc_object_t * );
76 /*****************************************************************************
78 *****************************************************************************/
80 #define BROWSE_TEXT N_("Filebrowser starting point")
81 #define BROWSE_LONGTEXT N_( \
82 "This option allows you to specify the directory the ncurses filebrowser " \
83 "will show you initially.")
86 set_shortname( "Ncurses" )
87 set_description( N_("Ncurses interface") )
88 set_capability( "interface", 10 )
89 set_category( CAT_INTERFACE )
90 set_subcategory( SUBCAT_INTERFACE_MAIN )
91 set_callbacks( Open, Close )
92 add_shortcut( "curses" )
93 add_directory( "browse-dir", NULL, BROWSE_TEXT, BROWSE_LONGTEXT, false )
96 /*****************************************************************************
97 * intf_sys_t: description and status of ncurses interface
98 *****************************************************************************/
141 playlist_item_t *p_item;
146 input_thread_t *p_input;
147 playlist_t *p_playlist;
150 bool b_color_started;
160 int i_box_lines_total;
163 int i_box_plidx; /* Playlist index */
164 int b_box_plidx_follow;
165 int i_box_bidx; /* browser index */
167 playlist_item_t *p_node; /* current node */
171 msg_subscription_t* p_sub; /* message bank subscription */
173 char *psz_search_chain; /* for playlist searching */
174 char *psz_old_search; /* for searching next */
177 char *psz_open_chain;
178 #ifndef HAVE_NCURSESW
179 char psz_partial_keys[7];
182 char *psz_current_dir;
184 struct dir_entry_t **pp_dir_entries;
185 bool b_show_hidden_files;
187 int i_current_view; /* playlist view */
188 struct pl_item_t **pp_plist;
190 bool b_need_update; /* for playlist view */
193 /*****************************************************************************
195 *****************************************************************************/
197 static int comp_dir_entries( const void *pp_dir_entry1,
198 const void *pp_dir_entry2 )
200 struct dir_entry_t *p_dir_entry1 = *(struct dir_entry_t**)pp_dir_entry1;
201 struct dir_entry_t *p_dir_entry2 = *(struct dir_entry_t**)pp_dir_entry2;
202 if ( p_dir_entry1->b_file == p_dir_entry2->b_file ) {
203 return strcasecmp( p_dir_entry1->psz_path, p_dir_entry2->psz_path );
207 return ( p_dir_entry1->b_file ? 1 : -1 );
211 static void ReadDir( intf_thread_t *p_intf )
213 intf_sys_t *p_sys = p_intf->p_sys;
217 if( p_sys->psz_current_dir && *p_sys->psz_current_dir )
222 p_current_dir = vlc_opendir( p_sys->psz_current_dir );
224 if( p_current_dir == NULL )
226 /* something went bad, get out of here ! */
227 msg_Warn( p_intf, "cannot open directory `%s' (%m)",
228 p_sys->psz_current_dir );
232 /* Clean the old shit */
233 for( i = 0; i < p_sys->i_dir_entries; i++ )
235 struct dir_entry_t *p_dir_entry = p_sys->pp_dir_entries[i];
236 free( p_dir_entry->psz_path );
237 REMOVE_ELEM( p_sys->pp_dir_entries, p_sys->i_dir_entries, i );
240 p_sys->pp_dir_entries = NULL;
241 p_sys->i_dir_entries = 0;
243 /* while we still have entries in the directory */
244 while( ( psz_entry = vlc_readdir( p_current_dir ) ) != NULL )
246 #if defined( S_ISDIR )
247 struct stat stat_data;
249 struct dir_entry_t *p_dir_entry;
252 if( p_sys->b_show_hidden_files == false &&
253 ( strlen( psz_entry ) && psz_entry[0] == '.' ) &&
254 strcmp( psz_entry, ".." ) )
260 if( asprintf( &psz_uri, "%s/%s", p_sys->psz_current_dir,
267 if( !( p_dir_entry = malloc( sizeof( struct dir_entry_t) ) ) )
274 #if defined( S_ISDIR )
275 if( !vlc_stat( psz_uri, &stat_data )
276 && S_ISDIR(stat_data.st_mode) )
277 /*#elif defined( DT_DIR )
278 if( p_dir_content->d_type & DT_DIR )*/
283 p_dir_entry->psz_path = strdup( psz_entry );
284 p_dir_entry->b_file = false;
285 INSERT_ELEM( p_sys->pp_dir_entries, p_sys->i_dir_entries,
286 p_sys->i_dir_entries, p_dir_entry );
290 p_dir_entry->psz_path = strdup( psz_entry );
291 p_dir_entry->b_file = true;
292 INSERT_ELEM( p_sys->pp_dir_entries, p_sys->i_dir_entries,
293 p_sys->i_dir_entries, p_dir_entry );
301 qsort( p_sys->pp_dir_entries, p_sys->i_dir_entries,
302 sizeof(struct dir_entry_t*), &comp_dir_entries );
304 closedir( p_current_dir );
309 msg_Dbg( p_intf, "no current dir set" );
314 /*****************************************************************************
316 *****************************************************************************/
318 static void PlaylistDestroy( intf_thread_t *p_intf )
320 intf_sys_t *p_sys = p_intf->p_sys;
322 while( p_sys->i_plist_entries )
324 struct pl_item_t *p_pl_item = p_sys->pp_plist[0];
325 free( p_pl_item->psz_display );
326 REMOVE_ELEM( p_sys->pp_plist, p_sys->i_plist_entries, 0 );
329 p_sys->pp_plist = NULL;
332 static void PlaylistAddNode( intf_thread_t *p_intf, playlist_item_t *p_node,
333 int i, const char *c )
335 intf_sys_t *p_sys = p_intf->p_sys;
336 playlist_item_t *p_child;
339 for( k = 0; k < p_node->i_children; k++ )
342 p_child = p_node->pp_children[k];
343 char *psz_name = input_item_GetTitleFbName( p_child->p_input );
347 if( asprintf( &psz_display, "%s%c-%s", c,
348 k == p_node->i_children - 1 ? '`' : '|', psz_name ) == -1 )
353 if( asprintf( &psz_display, " %s", psz_name ) == -1 )
357 struct pl_item_t *p_pl_item = malloc( sizeof( struct pl_item_t ) );
360 p_pl_item->psz_display = psz_display;
361 p_pl_item->p_item = p_child;
362 INSERT_ELEM( p_sys->pp_plist, p_sys->i_plist_entries,
363 p_sys->i_plist_entries, p_pl_item );
366 if( p_child->i_children > 0 )
369 if( asprintf( &psz_tmp, "%s%c ", c,
370 k == p_node->i_children - 1 ? ' ' : '|' ) == -1 )
372 PlaylistAddNode( p_intf, p_child, i,
373 strlen( c ) ? psz_tmp : " " );
379 static playlist_item_t *PlaylistGetRoot( intf_thread_t *p_intf )
381 intf_sys_t *p_sys = p_intf->p_sys;
382 playlist_t *p_playlist = pl_Get( p_intf );
383 playlist_item_t *p_item;
385 switch( p_sys->i_current_view )
388 p_item = p_playlist->p_root_category;
391 p_item = p_playlist->p_root_onelevel;
396 static void PlaylistRebuild( intf_thread_t *p_intf )
398 intf_sys_t *p_sys = p_intf->p_sys;
399 playlist_t *p_playlist = pl_Get( p_intf );
403 /* First clear the old one */
404 PlaylistDestroy( p_intf );
406 /* Build the new one */
407 PlaylistAddNode( p_intf, PlaylistGetRoot( p_intf ), 0, "" );
409 p_sys->b_need_update = false;
414 static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
415 vlc_value_t oval, vlc_value_t nval, void *param )
417 VLC_UNUSED(p_this); VLC_UNUSED(psz_variable);
418 VLC_UNUSED(oval); VLC_UNUSED(nval);
419 intf_thread_t *p_intf = (intf_thread_t *)param;
420 playlist_t *p_playlist = pl_Get( p_intf );
421 p_intf->p_sys->b_need_update = true;
422 p_intf->p_sys->p_node = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
427 /* This function have to be called with the playlist locked */
428 static inline bool PlaylistIsPlaying( playlist_t *p_playlist,
429 playlist_item_t *p_item )
431 playlist_item_t *p_played_item = playlist_CurrentPlayingItem( p_playlist );
432 return( p_item != NULL && p_played_item != NULL &&
433 p_item->p_input != NULL && p_played_item->p_input != NULL &&
434 p_item->p_input->i_id == p_played_item->p_input->i_id );
437 static int SubSearchPlaylist( intf_thread_t *p_intf, char *psz_searchstring,
438 int i_start, int i_stop )
440 intf_sys_t *p_sys = p_intf->p_sys;
443 for( i = i_start + 1; i < i_stop; i++ )
445 if( strcasestr( p_sys->pp_plist[i]->psz_display,
446 psz_searchstring ) != NULL )
456 static void SearchPlaylist( intf_thread_t *p_intf, char *psz_searchstring )
461 intf_sys_t *p_sys = p_intf->p_sys;
463 if( p_sys->i_before_search >= 0 )
465 i_first = p_sys->i_before_search;
468 if( ( ! psz_searchstring ) || strlen( psz_searchstring ) <= 0 )
470 p_sys->i_box_plidx = p_sys->i_before_search;
474 i_max = p_sys->i_plist_entries;
476 i_item = SubSearchPlaylist( p_intf, psz_searchstring, i_first + 1, i_max );
479 i_item = SubSearchPlaylist( p_intf, psz_searchstring, 0, i_first );
482 if( i_item < 0 || i_item >= i_max ) return;
484 p_sys->i_box_plidx = i_item;
487 static void FindIndex( intf_thread_t *p_intf, playlist_t *p_playlist )
489 intf_sys_t *p_sys = p_intf->p_sys;
492 if( p_sys->i_box_plidx < p_sys->i_plist_entries && p_sys->i_box_plidx >= 0 )
494 playlist_item_t *p_item = p_sys->pp_plist[p_sys->i_box_plidx]->p_item;
496 if( ( p_item->i_children == 0 && p_item == p_sys->p_node ) ||
497 PlaylistIsPlaying( p_playlist, p_item ) )
504 for( i = 0; i < p_sys->i_plist_entries; i++ )
506 playlist_item_t *p_item = p_sys->pp_plist[i]->p_item;
507 if( ( p_item->i_children == 0 && p_item == p_sys->p_node ) ||
508 PlaylistIsPlaying( p_playlist, p_sys->pp_plist[i]->p_item ) )
510 p_sys->i_box_plidx = i;
517 static void start_color_and_pairs( intf_thread_t *p_intf )
519 assert( p_intf->p_sys->b_color && !p_intf->p_sys->b_color_started );
523 p_intf->p_sys->b_color = false;
524 msg_Warn( p_intf, "Terminal doesn't support colors" );
530 /* Available colors: BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE */
532 /* untested, in all my terminals, !can_change_color() --funman */
533 if( can_change_color() )
534 init_color( COLOR_YELLOW, 960, 500, 0 ); /* YELLOW -> ORANGE */
537 init_pair( C_TITLE, COLOR_YELLOW, COLOR_BLACK );
539 /* jamaican playlist */
540 init_pair( C_PLAYLIST_1, COLOR_GREEN, COLOR_BLACK );
541 init_pair( C_PLAYLIST_2, COLOR_YELLOW, COLOR_BLACK );
542 init_pair( C_PLAYLIST_3, COLOR_RED, COLOR_BLACK );
544 /* used in DrawBox() */
545 init_pair( C_BOX, COLOR_CYAN, COLOR_BLACK );
546 /* Source, State, Position, Volume, Chapters, etc...*/
547 init_pair( C_STATUS, COLOR_BLUE, COLOR_BLACK );
549 /* VLC messages, keep the order from highest priority to lowest */
552 init_pair( C_INFO, COLOR_BLACK, COLOR_WHITE );
554 init_pair( C_ERROR, COLOR_RED, COLOR_BLACK );
556 init_pair( C_WARNING, COLOR_YELLOW, COLOR_BLACK );
558 init_pair( C_DEBUG, COLOR_WHITE, COLOR_BLACK );
560 /* Category title (help, info, metadata) */
561 init_pair( C_CATEGORY, COLOR_MAGENTA, COLOR_BLACK );
563 /* Folder (BOX_BROWSE) */
564 init_pair( C_FOLDER, COLOR_RED, COLOR_BLACK );
566 p_intf->p_sys->b_color_started = true;
569 /****************************************************************************
571 ****************************************************************************/
573 static void DrawBox( WINDOW *win, int y, int x, int h, int w, const char *title, bool b_color )
581 wcolor_set( win, C_BOX, NULL );
582 if( title == NULL ) title = "";
583 i_len = strlen( title );
585 if( i_len > w - 2 ) i_len = w - 2;
587 mvwaddch( win, y, x, ACS_ULCORNER );
588 mvwhline( win, y, x+1, ACS_HLINE, ( w-i_len-2)/2 );
589 mvwprintw( win,y, x+1+(w-i_len-2)/2, "%s", title );
590 mvwhline( win, y, x+(w-i_len)/2+i_len, ACS_HLINE, w - 1 - ((w-i_len)/2+i_len) );
591 mvwaddch( win, y, x+w-1,ACS_URCORNER );
593 for( i = 0; i < h-2; i++ )
595 mvwaddch( win, y+i+1, x, ACS_VLINE );
596 mvwaddch( win, y+i+1, x+w-1, ACS_VLINE );
599 mvwaddch( win, y+h-1, x, ACS_LLCORNER );
600 mvwhline( win, y+h-1, x+1, ACS_HLINE, w - 2 );
601 mvwaddch( win, y+h-1, x+w-1, ACS_LRCORNER );
603 wcolor_set( win, C_DEFAULT, NULL );
607 static void DrawEmptyLine( WINDOW *win, int y, int x, int w )
611 mvwhline( win, y, x, ' ', w );
615 static void DrawLine( WINDOW *win, int y, int x, int w )
619 attrset( A_REVERSE );
620 mvwhline( win, y, x, ' ', w );
621 attroff( A_REVERSE );
625 static void mvnprintw( int y, int x, int w, const char *p_fmt, ... )
634 va_start( vl_args, p_fmt );
635 if( vasprintf( &p_buf, p_fmt, vl_args ) == -1 )
639 i_len = strlen( p_buf );
642 wchar_t psz_wide[i_len + 1];
645 size_t i_char_len = mbstowcs( psz_wide, p_buf, i_len );
647 size_t i_width; /* number of columns */
649 if( i_char_len == (size_t)-1 )
650 /* an invalid character was encountered */
657 i_width = wcswidth( psz_wide, i_char_len );
658 if( i_width == (size_t)-1 )
660 /* a non printable character was encountered */
664 for( i = 0 ; i < i_char_len ; i++ )
666 i_cwidth = wcwidth( psz_wide[i] );
672 if( i_width > (size_t)w )
674 int i_total_width = 0;
676 while( i_total_width < w )
678 i_total_width += wcwidth( psz_wide[i] );
679 if( w > 7 && i_total_width >= w/2 )
683 i_total_width -= wcwidth( psz_wide[i] ) - 2;
686 /* we require this check only if at least one character
687 * 4 or more columns wide exists (which i doubt) */
689 i_total_width -= wcwidth( psz_wide[i-1] ) - 1;
692 /* find the widest string */
693 int j, i_2nd_width = 0;
694 for( j = i_char_len - 1; i_2nd_width < w - i_total_width; j-- )
695 i_2nd_width += wcwidth( psz_wide[j] );
697 /* we already have i_total_width columns filled, and we can't
698 * have more than w columns */
699 if( i_2nd_width > w - i_total_width )
702 wmemmove( &psz_wide[i+2], &psz_wide[j+1], i_char_len - j - 1 );
703 psz_wide[i + 2 + i_char_len - j - 1] = '\0';
708 if( w <= 7 ) /* we don't add the '...' else we lose too much chars */
711 size_t i_wlen = wcslen( psz_wide ) * 6 + 1; /* worst case */
712 char psz_ellipsized[i_wlen];
713 wcstombs( psz_ellipsized, psz_wide, i_wlen );
714 mvprintw( y, x, "%s", psz_ellipsized );
718 mvprintw( y, x, "%s", p_buf );
719 mvhline( y, x + i_width, ' ', w - i_width );
725 int i_cut = i_len - w;
726 int x1 = i_len/2 - i_cut/2;
731 memmove( &p_buf[x1], &p_buf[x2], i_len - x2 );
740 char *psz_local = ToLocale( p_buf );
741 mvprintw( y, x, "%s", psz_local );
746 char *psz_local = ToLocale( p_buf );
747 mvprintw( y, x, "%s", psz_local );
749 mvhline( y, x + i_len, ' ', w - i_len );
755 static void MainBoxWrite( intf_thread_t *p_intf, int l, int x, const char *p_fmt, ... )
757 intf_sys_t *p_sys = p_intf->p_sys;
762 if( l < p_sys->i_box_start || l - p_sys->i_box_start >= p_sys->i_box_lines )
767 va_start( vl_args, p_fmt );
768 if( vasprintf( &p_buf, p_fmt, vl_args ) == -1 )
772 mvnprintw( p_sys->i_box_y + l - p_sys->i_box_start, x, COLS - x - 1, "%s", p_buf );
776 static void DumpObject( intf_thread_t *p_intf, int *l, vlc_object_t *p_obj, int i_level )
778 char *psz_name = vlc_object_get_name( p_obj );
781 MainBoxWrite( p_intf, (*l)++, 1 + 2 * i_level, "%s \"%s\" (%p)",
782 p_obj->psz_object_type, psz_name, p_obj );
786 MainBoxWrite( p_intf, (*l)++, 1 + 2 * i_level, "%s (%o)",
787 p_obj->psz_object_type, p_obj );
789 vlc_list_t *list = vlc_list_children( p_obj );
790 for( int i = 0; i < list->i_count ; i++ )
792 MainBoxWrite( p_intf, *l, 1 + 2 * i_level,
793 i == list->i_count - 1 ? "`-" : "|-" );
794 DumpObject( p_intf, l, list->p_values[i].p_object, i_level + 1 );
796 vlc_list_release( list );
799 static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
801 intf_sys_t *p_sys = p_intf->p_sys;
802 input_thread_t *p_input = p_sys->p_input;
803 playlist_t *p_playlist = pl_Get( p_intf );
809 attrset( A_REVERSE );
810 int i_len = strlen( "VLC media player "PACKAGE_VERSION );
811 int mid = ( COLS - i_len ) / 2;
814 int i_size = ( COLS > i_len + 1 ) ? COLS : i_len + 1;
815 char psz_title[i_size];
816 memset( psz_title, ' ', mid );
818 wcolor_set( p_sys->w, C_TITLE, NULL );
819 strlcpy( &psz_title[mid], "VLC media player "PACKAGE_VERSION, i_size );
820 mvnprintw( y, 0, COLS, "%s", psz_title );
821 attroff( A_REVERSE );
825 wcolor_set( p_sys->w, C_STATUS, NULL );
829 if( asprintf( &psz_state, "%s%s%s",
830 var_GetBool( p_playlist, "repeat" ) ? _( "[Repeat] " ) : "",
831 var_GetBool( p_playlist, "random" ) ? _( "[Random] " ) : "",
832 var_GetBool( p_playlist, "loop" ) ? _( "[Loop]" ) : "" ) == -1 )
835 if( p_input && !p_input->b_dead )
837 char buf1[MSTRTIME_MAX_SIZE];
838 char buf2[MSTRTIME_MAX_SIZE];
842 char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
843 mvnprintw( y++, 0, COLS, _(" Source : %s"), psz_uri );
847 var_Get( p_input, "state", &val );
848 if( val.i_int == PLAYING_S )
850 mvnprintw( y++, 0, COLS, _(" State : Playing %s"), psz_state );
852 else if( val.i_int == OPENING_S )
854 mvnprintw( y++, 0, COLS, _(" State : Opening/Connecting %s"), psz_state );
856 else if( val.i_int == PAUSE_S )
858 mvnprintw( y++, 0, COLS, _(" State : Paused %s"), psz_state );
861 if( val.i_int != INIT_S && val.i_int != END_S )
863 audio_volume_t i_volume;
866 var_Get( p_input, "time", &val );
867 secstotimestr( buf1, val.i_time / CLOCK_FREQ );
869 var_Get( p_input, "length", &val );
870 secstotimestr( buf2, val.i_time / CLOCK_FREQ );
872 mvnprintw( y++, 0, COLS, _(" Position : %s/%s (%.2f%%)"), buf1, buf2, p_sys->f_slider );
875 aout_VolumeGet( p_playlist, &i_volume );
876 mvnprintw( y++, 0, COLS, _(" Volume : %i%%"), i_volume*200/AOUT_VOLUME_MAX );
879 if( !var_Get( p_input, "title", &val ) )
881 int i_title_count = var_CountChoices( p_input, "title" );
882 if( i_title_count > 0 )
883 mvnprintw( y++, 0, COLS, _(" Title : %"PRId64"/%d"),
884 val.i_int, i_title_count );
888 if( !var_Get( p_input, "chapter", &val ) )
890 int i_chapter_count = var_CountChoices( p_input, "chapter" );
891 if( i_chapter_count > 0 )
892 mvnprintw( y++, 0, COLS, _(" Chapter : %"PRId64"/%d"),
893 val.i_int, i_chapter_count );
903 mvnprintw( y++, 0, COLS, _(" Source: <no current item> %s"), psz_state );
904 DrawEmptyLine( p_sys->w, y++, 0, COLS );
905 mvnprintw( y++, 0, COLS, _(" [ h for help ]") );
906 DrawEmptyLine( p_sys->w, y++, 0, COLS );
910 wcolor_set( p_sys->w, C_DEFAULT, NULL );
912 DrawBox( p_sys->w, y, 0, 3, COLS, "", p_sys->b_color );
913 DrawEmptyLine( p_sys->w, y+1, 1, COLS-2);
914 DrawLine( p_sys->w, y+1, 1, (int)(p_intf->p_sys->f_slider/100.0 * (COLS -2)) );
917 p_sys->i_box_y = y + 1;
918 p_sys->i_box_lines = LINES - y - 2;
923 if( p_sys->i_box_type == BOX_HELP )
927 DrawBox( p_sys->w, y++, 0, h, COLS, _(" Help "), p_sys->b_color );
930 wcolor_set( p_sys->w, C_CATEGORY, NULL );
931 MainBoxWrite( p_intf, l++, 1, _("[Display]") );
933 wcolor_set( p_sys->w, C_DEFAULT, NULL );
934 MainBoxWrite( p_intf, l++, 1, _(" h,H Show/Hide help box") );
935 MainBoxWrite( p_intf, l++, 1, _(" i Show/Hide info box") );
936 MainBoxWrite( p_intf, l++, 1, _(" m Show/Hide metadata box") );
937 MainBoxWrite( p_intf, l++, 1, _(" L Show/Hide messages box") );
938 MainBoxWrite( p_intf, l++, 1, _(" P Show/Hide playlist box") );
939 MainBoxWrite( p_intf, l++, 1, _(" B Show/Hide filebrowser") );
940 MainBoxWrite( p_intf, l++, 1, _(" x Show/Hide objects box") );
941 MainBoxWrite( p_intf, l++, 1, _(" S Show/Hide statistics box" ) );
942 MainBoxWrite( p_intf, l++, 1, _(" c Switch color on/off") );
943 MainBoxWrite( p_intf, l++, 1, _(" Esc Close Add/Search entry") );
944 MainBoxWrite( p_intf, l++, 1, "" );
947 wcolor_set( p_sys->w, C_CATEGORY, NULL );
948 MainBoxWrite( p_intf, l++, 1, _("[Global]") );
950 wcolor_set( p_sys->w, C_DEFAULT, NULL );
951 MainBoxWrite( p_intf, l++, 1, _(" q, Q, Esc Quit") );
952 MainBoxWrite( p_intf, l++, 1, _(" s Stop") );
953 MainBoxWrite( p_intf, l++, 1, _(" <space> Pause/Play") );
954 MainBoxWrite( p_intf, l++, 1, _(" f Toggle Fullscreen") );
955 MainBoxWrite( p_intf, l++, 1, _(" n, p Next/Previous playlist item") );
956 MainBoxWrite( p_intf, l++, 1, _(" [, ] Next/Previous title") );
957 MainBoxWrite( p_intf, l++, 1, _(" <, > Next/Previous chapter") );
958 MainBoxWrite( p_intf, l++, 1, _(" <right> Seek +1%%") );
959 MainBoxWrite( p_intf, l++, 1, _(" <left> Seek -1%%") );
960 MainBoxWrite( p_intf, l++, 1, _(" a Volume Up") );
961 MainBoxWrite( p_intf, l++, 1, _(" z Volume Down") );
962 MainBoxWrite( p_intf, l++, 1, "" );
965 wcolor_set( p_sys->w, C_CATEGORY, NULL );
966 MainBoxWrite( p_intf, l++, 1, _("[Playlist]") );
968 wcolor_set( p_sys->w, C_DEFAULT, NULL );
969 MainBoxWrite( p_intf, l++, 1, _(" r Toggle Random playing") );
970 MainBoxWrite( p_intf, l++, 1, _(" l Toggle Loop Playlist") );
971 MainBoxWrite( p_intf, l++, 1, _(" R Toggle Repeat item") );
972 MainBoxWrite( p_intf, l++, 1, _(" o Order Playlist by title") );
973 MainBoxWrite( p_intf, l++, 1, _(" O Reverse order Playlist by title") );
974 MainBoxWrite( p_intf, l++, 1, _(" g Go to the current playing item") );
975 MainBoxWrite( p_intf, l++, 1, _(" / Look for an item") );
976 MainBoxWrite( p_intf, l++, 1, _(" A Add an entry") );
977 MainBoxWrite( p_intf, l++, 1, _(" D, <del> Delete an entry") );
978 MainBoxWrite( p_intf, l++, 1, _(" <backspace> Delete an entry") );
979 MainBoxWrite( p_intf, l++, 1, _(" e Eject (if stopped)") );
980 MainBoxWrite( p_intf, l++, 1, "" );
983 wcolor_set( p_sys->w, C_CATEGORY, NULL );
984 MainBoxWrite( p_intf, l++, 1, _("[Filebrowser]") );
986 wcolor_set( p_sys->w, C_DEFAULT, NULL );
987 MainBoxWrite( p_intf, l++, 1, _(" <enter> Add the selected file to the playlist") );
988 MainBoxWrite( p_intf, l++, 1, _(" <space> Add the selected directory to the playlist") );
989 MainBoxWrite( p_intf, l++, 1, _(" . Show/Hide hidden files") );
990 MainBoxWrite( p_intf, l++, 1, "" );
993 wcolor_set( p_sys->w, C_CATEGORY, NULL );
994 MainBoxWrite( p_intf, l++, 1, _("[Boxes]") );
996 wcolor_set( p_sys->w, C_DEFAULT, NULL );
997 MainBoxWrite( p_intf, l++, 1, _(" <up>,<down> Navigate through the box line by line") );
998 MainBoxWrite( p_intf, l++, 1, _(" <pgup>,<pgdown> Navigate through the box page by page") );
999 MainBoxWrite( p_intf, l++, 1, "" );
1001 if( p_sys->b_color )
1002 wcolor_set( p_sys->w, C_CATEGORY, NULL );
1003 MainBoxWrite( p_intf, l++, 1, _("[Player]") );
1004 if( p_sys->b_color )
1005 wcolor_set( p_sys->w, C_DEFAULT, NULL );
1006 MainBoxWrite( p_intf, l++, 1, _(" <up>,<down> Seek +/-5%%") );
1007 MainBoxWrite( p_intf, l++, 1, "" );
1009 if( p_sys->b_color )
1010 wcolor_set( p_sys->w, C_CATEGORY, NULL );
1011 MainBoxWrite( p_intf, l++, 1, _("[Miscellaneous]") );
1012 if( p_sys->b_color )
1013 wcolor_set( p_sys->w, C_DEFAULT, NULL );
1014 MainBoxWrite( p_intf, l++, 1, _(" Ctrl-l Refresh the screen") );
1016 p_sys->i_box_lines_total = l;
1017 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
1019 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
1022 if( l - p_sys->i_box_start < p_sys->i_box_lines )
1024 y += l - p_sys->i_box_start;
1028 y += p_sys->i_box_lines;
1031 else if( p_sys->i_box_type == BOX_INFO )
1035 DrawBox( p_sys->w, y++, 0, h, COLS, _(" Information "), p_sys->b_color );
1040 vlc_mutex_lock( &input_GetItem(p_input)->lock );
1041 for( i = 0; i < input_GetItem(p_input)->i_categories; i++ )
1043 info_category_t *p_category = input_GetItem(p_input)->pp_categories[i];
1044 if( y >= y_end ) break;
1045 if( p_sys->b_color )
1046 wcolor_set( p_sys->w, C_CATEGORY, NULL );
1047 MainBoxWrite( p_intf, l++, 1, _(" [%s]"), p_category->psz_name );
1048 if( p_sys->b_color )
1049 wcolor_set( p_sys->w, C_DEFAULT, NULL );
1050 for( j = 0; j < p_category->i_infos; j++ )
1052 info_t *p_info = p_category->pp_infos[j];
1053 if( y >= y_end ) break;
1054 MainBoxWrite( p_intf, l++, 1, _(" %s: %s"), p_info->psz_name, p_info->psz_value );
1057 vlc_mutex_unlock( &input_GetItem(p_input)->lock );
1061 MainBoxWrite( p_intf, l++, 1, _("No item currently playing") );
1063 p_sys->i_box_lines_total = l;
1064 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
1066 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
1069 if( l - p_sys->i_box_start < p_sys->i_box_lines )
1071 y += l - p_sys->i_box_start;
1075 y += p_sys->i_box_lines;
1078 else if( p_sys->i_box_type == BOX_META )
1083 DrawBox( p_sys->w, y++, 0, h, COLS, _("Meta-information"),
1089 input_item_t *p_item = input_GetItem( p_input );
1090 vlc_mutex_lock( &p_item->lock );
1091 for( i=0; i<VLC_META_TYPE_COUNT; i++ )
1093 if( y >= y_end ) break;
1094 const char *psz_meta = vlc_meta_Get( p_item->p_meta, i );
1095 if( psz_meta && *psz_meta )
1097 const char *psz_meta_title;
1101 psz_meta_title = VLC_META_TITLE; break;
1103 psz_meta_title = VLC_META_ARTIST; break;
1105 psz_meta_title = VLC_META_GENRE ; break;
1107 psz_meta_title = VLC_META_COPYRIGHT; break;
1109 psz_meta_title = VLC_META_ALBUM; break;
1111 psz_meta_title = VLC_META_TRACK_NUMBER; break;
1113 psz_meta_title = VLC_META_DESCRIPTION; break;
1115 psz_meta_title = VLC_META_RATING; break;
1117 psz_meta_title = VLC_META_DATE; break;
1119 psz_meta_title = VLC_META_SETTING; break;
1121 psz_meta_title = VLC_META_URL; break;
1123 psz_meta_title = VLC_META_LANGUAGE; break;
1125 psz_meta_title = VLC_META_NOW_PLAYING; break;
1127 psz_meta_title = VLC_META_PUBLISHER; break;
1129 psz_meta_title = VLC_META_ENCODED_BY; break;
1131 psz_meta_title = VLC_META_ART_URL; break;
1133 psz_meta_title = VLC_META_TRACKID; break;
1135 psz_meta_title = ""; break;
1137 if( p_sys->b_color )
1138 wcolor_set( p_sys->w, C_CATEGORY, NULL );
1139 MainBoxWrite( p_intf, l++, 1, " [%s]", psz_meta_title );
1140 if( p_sys->b_color )
1141 wcolor_set( p_sys->w, C_DEFAULT, NULL );
1142 MainBoxWrite( p_intf, l++, 1, " %s", psz_meta );
1145 vlc_mutex_unlock( &p_item->lock );
1149 MainBoxWrite( p_intf, l++, 1, _("No item currently playing") );
1151 p_sys->i_box_lines_total = l;
1152 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
1154 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
1157 if( l - p_sys->i_box_start < p_sys->i_box_lines )
1159 y += l - p_sys->i_box_start;
1163 y += p_sys->i_box_lines;
1166 else if( p_sys->i_box_type == BOX_LOG )
1168 #warning Deprecated API
1174 DrawBox( p_sys->w, y++, 0, h, COLS, _(" Logs "), p_sys->b_color );
1177 i_start = p_intf->p_sys->p_sub->i_start;
1179 vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
1180 i_stop = *p_intf->p_sys->p_sub->pi_stop;
1181 vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
1185 static const char *ppsz_type[4] = { "", "error", "warning", "debug" };
1186 if( i_line >= h - 2 )
1192 if( i_stop < 0 ) i_stop += VLC_MSG_QSIZE;
1193 if( i_stop == i_start )
1197 if( p_sys->b_color )
1198 wcolor_set( p_sys->w,
1199 p_sys->p_sub->p_msg[i_stop].i_type + C_INFO,
1201 mvnprintw( y + h-2-i_line, 1, COLS - 2, " [%s] %s",
1202 ppsz_type[p_sys->p_sub->p_msg[i_stop].i_type],
1203 p_sys->p_sub->p_msg[i_stop].psz_msg );
1204 if( p_sys->b_color )
1205 wcolor_set( p_sys->w, C_DEFAULT, NULL );
1208 vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
1209 p_intf->p_sys->p_sub->i_start = i_stop;
1210 vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
1214 else if( p_sys->i_box_type == BOX_BROWSE )
1216 /* Filebrowser box */
1217 int i_start, i_stop;
1219 DrawBox( p_sys->w, y++, 0, h, COLS, _(" Browse "), p_sys->b_color );
1221 if( p_sys->i_box_bidx >= p_sys->i_dir_entries ) p_sys->i_box_plidx = p_sys->i_dir_entries - 1;
1222 if( p_sys->i_box_bidx < 0 ) p_sys->i_box_bidx = 0;
1224 if( p_sys->i_box_bidx < (h - 2)/2 )
1229 else if( p_sys->i_dir_entries - p_sys->i_box_bidx > (h - 2)/2 )
1231 i_start = p_sys->i_box_bidx - (h - 2)/2;
1232 i_stop = i_start + h - 2;
1236 i_stop = p_sys->i_dir_entries;
1237 i_start = p_sys->i_dir_entries - (h - 2);
1243 if( i_stop > p_sys->i_dir_entries )
1245 i_stop = p_sys->i_dir_entries;
1248 for( i_item = i_start; i_item < i_stop; i_item++ )
1250 bool b_selected = ( p_sys->i_box_bidx == i_item );
1252 if( y >= y_end ) break;
1255 attrset( A_REVERSE );
1257 if( p_sys->b_color && !p_sys->pp_dir_entries[i_item]->b_file )
1258 wcolor_set( p_sys->w, C_FOLDER, NULL );
1259 mvnprintw( y++, 1, COLS - 2, " %c %s", p_sys->pp_dir_entries[i_item]->b_file == true ? ' ' : '+',
1260 p_sys->pp_dir_entries[i_item]->psz_path );
1261 if( p_sys->b_color && !p_sys->pp_dir_entries[i_item]->b_file )
1262 wcolor_set( p_sys->w, C_DEFAULT, NULL );
1266 attroff( A_REVERSE );
1271 else if( p_sys->i_box_type == BOX_OBJECTS )
1274 DrawBox( p_sys->w, y++, 0, h, COLS, _(" Objects "), p_sys->b_color );
1275 DumpObject( p_intf, &l, VLC_OBJECT( p_intf->p_libvlc ), 0 );
1277 p_sys->i_box_lines_total = l;
1278 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
1279 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
1281 if( l - p_sys->i_box_start < p_sys->i_box_lines )
1282 y += l - p_sys->i_box_start;
1284 y += p_sys->i_box_lines;
1286 else if( p_sys->i_box_type == BOX_STATS )
1288 DrawBox( p_sys->w, y++, 0, h, COLS, _(" Stats "), p_sys->b_color );
1292 input_item_t *p_item = input_GetItem( p_input );
1294 vlc_mutex_lock( &p_item->lock );
1295 vlc_mutex_lock( &p_item->p_stats->lock );
1302 i_video = i_audio = 1;
1304 for( i = 0; i < p_item->i_es ; i++ )
1306 i_audio += ( p_item->es[i]->i_cat == AUDIO_ES );
1307 i_video += ( p_item->es[i]->i_cat == VIDEO_ES );
1312 #define SHOW_ACS(x,c) \
1313 if(l >= p_sys->i_box_start && l - p_sys->i_box_start < p_sys->i_box_lines) \
1314 mvaddch( p_sys->i_box_y - p_sys->i_box_start + l, x, c )
1317 if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL );
1318 MainBoxWrite( p_intf, l, 1, _("+-[Incoming]"));
1319 SHOW_ACS( 1, ACS_ULCORNER ); SHOW_ACS( 2, ACS_HLINE ); l++;
1320 if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL );
1321 MainBoxWrite( p_intf, l, 1, _("| input bytes read : %8.0f KiB"),
1322 (float)(p_item->p_stats->i_read_bytes)/1024 );
1323 SHOW_ACS( 1, ACS_VLINE ); l++;
1324 MainBoxWrite( p_intf, l, 1, _("| input bitrate : %6.0f kb/s"),
1325 (float)(p_item->p_stats->f_input_bitrate)*8000 );
1326 MainBoxWrite( p_intf, l, 1, _("| demux bytes read : %8.0f KiB"),
1327 (float)(p_item->p_stats->i_demux_read_bytes)/1024 );
1328 SHOW_ACS( 1, ACS_VLINE ); l++;
1329 MainBoxWrite( p_intf, l, 1, _("| demux bitrate : %6.0f kb/s"),
1330 (float)(p_item->p_stats->f_demux_bitrate)*8000 );
1331 SHOW_ACS( 1, ACS_VLINE ); l++;
1332 DrawEmptyLine( p_sys->w, p_sys->i_box_y + l - p_sys->i_box_start, 1, COLS - 2 );
1333 SHOW_ACS( 1, ACS_VLINE ); l++;
1338 if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL );
1339 MainBoxWrite( p_intf, l, 1, _("+-[Video Decoding]"));
1340 SHOW_ACS( 1, ACS_LTEE ); SHOW_ACS( 2, ACS_HLINE ); l++;
1341 if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL );
1342 MainBoxWrite( p_intf, l, 1, _("| video decoded : %"PRId64),
1343 p_item->p_stats->i_decoded_video );
1344 SHOW_ACS( 1, ACS_VLINE ); l++;
1345 MainBoxWrite( p_intf, l, 1, _("| frames displayed : %"PRId64),
1346 p_item->p_stats->i_displayed_pictures );
1347 SHOW_ACS( 1, ACS_VLINE ); l++;
1348 MainBoxWrite( p_intf, l, 1, _("| frames lost : %"PRId64),
1349 p_item->p_stats->i_lost_pictures );
1350 SHOW_ACS( 1, ACS_VLINE ); l++;
1351 DrawEmptyLine( p_sys->w, p_sys->i_box_y + l - p_sys->i_box_start, 1, COLS - 2 );
1352 SHOW_ACS( 1, ACS_VLINE ); l++;
1357 if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL );
1358 MainBoxWrite( p_intf, l, 1, _("+-[Audio Decoding]"));
1359 SHOW_ACS( 1, ACS_LTEE ); SHOW_ACS( 2, ACS_HLINE ); l++;
1360 if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL );
1361 MainBoxWrite( p_intf, l, 1, _("| audio decoded : %"PRId64),
1362 p_item->p_stats->i_decoded_audio );
1363 SHOW_ACS( 1, ACS_VLINE ); l++;
1364 MainBoxWrite( p_intf, l, 1, _("| buffers played : %"PRId64),
1365 p_item->p_stats->i_played_abuffers );
1366 SHOW_ACS( 1, ACS_VLINE ); l++;
1367 MainBoxWrite( p_intf, l, 1, _("| buffers lost : %"PRId64),
1368 p_item->p_stats->i_lost_abuffers );
1369 SHOW_ACS( 1, ACS_VLINE ); l++;
1370 DrawEmptyLine( p_sys->w, p_sys->i_box_y + l - p_sys->i_box_start, 1, COLS - 2 );
1371 SHOW_ACS( 1, ACS_VLINE ); l++;
1374 if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL );
1375 MainBoxWrite( p_intf, l, 1, _("+-[Streaming]"));
1376 SHOW_ACS( 1, ACS_LTEE ); SHOW_ACS( 2, ACS_HLINE ); l++;
1377 if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL );
1378 MainBoxWrite( p_intf, l, 1, _("| packets sent : %5i"), p_item->p_stats->i_sent_packets );
1379 SHOW_ACS( 1, ACS_VLINE ); l++;
1380 MainBoxWrite( p_intf, l, 1, _("| bytes sent : %8.0f KiB"),
1381 (float)(p_item->p_stats->i_sent_bytes)/1024 );
1382 SHOW_ACS( 1, ACS_VLINE ); l++;
1383 MainBoxWrite( p_intf, l, 1, _("\\ sending bitrate : %6.0f kb/s"),
1384 (float)(p_item->p_stats->f_send_bitrate*8)*1000 );
1385 SHOW_ACS( 1, ACS_LLCORNER ); l++;
1386 if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL );
1390 p_sys->i_box_lines_total = l;
1391 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
1392 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
1394 if( l - p_sys->i_box_start < p_sys->i_box_lines )
1395 y += l - p_sys->i_box_start;
1397 y += p_sys->i_box_lines;
1399 vlc_mutex_unlock( &p_item->p_stats->lock );
1400 vlc_mutex_unlock( &p_item->lock );
1404 else if( p_sys->i_box_type == BOX_PLAYLIST ||
1405 p_sys->i_box_type == BOX_SEARCH ||
1406 p_sys->i_box_type == BOX_OPEN )
1409 int i_start, i_stop, i_max = p_sys->i_plist_entries;
1413 switch( p_sys->i_current_view )
1416 psz_title = strdup( _(" Playlist (All, one level) ") );
1419 psz_title = strdup( _(" Playlist (By category) ") );
1422 psz_title = strdup( _(" Playlist (Manually added) ") );
1425 DrawBox( p_sys->w, y++, 0, h, COLS, psz_title, p_sys->b_color );
1428 if( p_sys->b_need_update || p_sys->pp_plist == NULL )
1430 PlaylistRebuild( p_intf );
1432 if( p_sys->b_box_plidx_follow )
1434 FindIndex( p_intf, p_playlist );
1437 if( p_sys->i_box_plidx < 0 ) p_sys->i_box_plidx = 0;
1438 if( p_sys->i_box_plidx < 0 ) p_sys->i_box_plidx = 0;
1439 if( p_sys->i_box_plidx >= i_max ) p_sys->i_box_plidx = i_max - 1;
1441 if( p_sys->i_box_plidx < (h - 2)/2 )
1446 else if( i_max - p_sys->i_box_plidx > (h - 2)/2 )
1448 i_start = p_sys->i_box_plidx - (h - 2)/2;
1449 i_stop = i_start + h - 2;
1454 i_start = i_max - (h - 2);
1460 if( i_stop > i_max )
1465 for( i_item = i_start; i_item < i_stop; i_item++ )
1467 bool b_selected = ( p_sys->i_box_plidx == i_item );
1468 playlist_item_t *p_item = p_sys->pp_plist[i_item]->p_item;
1469 playlist_item_t *p_node = p_sys->p_node;
1471 input_thread_t *p_input2 = playlist_CurrentInput( p_playlist );
1475 playlist_item_t *p_current_playing_item = playlist_CurrentPlayingItem(p_playlist);
1476 if( ( p_node && p_item->p_input == p_node->p_input ) ||
1477 ( !p_node && p_input2 && p_current_playing_item &&
1478 p_item->p_input == p_current_playing_item->p_input ) )
1480 else if( p_item == p_node || ( p_item != p_node &&
1481 PlaylistIsPlaying( p_playlist, p_item ) ) )
1486 vlc_object_release( p_input2 );
1488 if( y >= y_end ) break;
1491 attrset( A_REVERSE );
1493 if( p_sys->b_color )
1494 wcolor_set( p_sys->w, i_item % 3 + C_PLAYLIST_1, NULL );
1495 mvnprintw( y++, 1, COLS - 2, "%c%s", c,
1496 p_sys->pp_plist[i_item]->psz_display );
1497 if( p_sys->b_color )
1498 wcolor_set( p_sys->w, C_DEFAULT, NULL );
1501 attroff( A_REVERSE );
1510 if( p_sys->i_box_type == BOX_SEARCH )
1512 DrawEmptyLine( p_sys->w, 7, 1, COLS-2 );
1513 if( p_sys->psz_search_chain )
1515 if( *p_sys->psz_search_chain == '\0' &&
1516 p_sys->psz_old_search != NULL )
1518 /* Searching next entry */
1519 mvnprintw( 7, 1, COLS-2, _("Find: %s"), p_sys->psz_old_search );
1523 mvnprintw( 7, 1, COLS-2, _("Find: %s"), p_sys->psz_search_chain );
1527 if( p_sys->i_box_type == BOX_OPEN )
1529 if( p_sys->psz_open_chain )
1531 DrawEmptyLine( p_sys->w, 7, 1, COLS-2 );
1532 mvnprintw( 7, 1, COLS-2, _("Open: %s"), p_sys->psz_open_chain );
1538 DrawEmptyLine( p_sys->w, y++, 1, COLS - 2 );
1543 *t_last_refresh = time( 0 );
1546 static void ManageSlider( intf_thread_t *p_intf )
1548 intf_sys_t *p_sys = p_intf->p_sys;
1549 input_thread_t *p_input = p_sys->p_input;
1552 if( p_input == NULL )
1556 var_Get( p_input, "state", &val );
1557 if( val.i_int != PLAYING_S )
1562 var_Get( p_input, "position", &val );
1563 if( p_sys->f_slider == p_sys->f_slider_old )
1566 p_sys->f_slider_old = 100 * val.f_float;
1570 p_sys->f_slider_old = p_sys->f_slider;
1572 val.f_float = p_sys->f_slider / 100.0;
1573 var_Set( p_input, "position", val );
1578 /* following functions are local */
1579 #ifndef HAVE_NCURSESW
1580 static char *KeyToUTF8( int i_key, char *psz_part )
1583 int len = strlen( psz_part );
1586 /* overflow error - should not happen */
1587 memset( psz_part, 0, 6 );
1591 psz_part[len] = (char)i_key;
1593 psz_utf8 = FromLocaleDup( psz_part );
1595 /* Ugly check for incomplete bytes sequences
1596 * (in case of non-UTF8 multibyte local encoding) */
1598 for( psz = psz_utf8; *psz; psz++ )
1599 if( ( *psz == '?' ) && ( *psz_utf8 != '?' ) )
1601 /* incomplete bytes sequence detected
1602 * (VLC core inserted dummy question marks) */
1607 /* Check for incomplete UTF8 bytes sequence */
1608 if( EnsureUTF8( psz_utf8 ) == NULL )
1614 memset( psz_part, 0, 6 );
1619 static inline int RemoveLastUTF8Entity( char *psz, int len )
1621 while( len && ( (psz[--len] & 0xc0) == 0x80 ) );
1622 /* UTF8 continuation byte */
1628 static void Eject( intf_thread_t *p_intf )
1630 char *psz_device = NULL, *psz_parser, *psz_name;
1633 * Get the active input
1634 * Determine whether we can eject a media, ie it's a DVD, VCD or CD-DA
1635 * If it's neither of these, then return
1638 playlist_t * p_playlist = pl_Get( p_intf );
1641 if( playlist_CurrentPlayingItem(p_playlist) == NULL )
1647 psz_name = playlist_CurrentPlayingItem(p_playlist)->p_input->psz_name;
1651 if( !strncmp(psz_name, "dvd://", 6) )
1653 switch( psz_name[6] )
1657 psz_device = config_GetPsz( p_intf, "dvd" );
1660 /* Omit the first MRL-selector characters */
1661 psz_device = strdup( psz_name + strlen("dvd://" ) );
1665 else if( !strncmp(psz_name, "vcd://", 6) )
1667 switch( psz_name[6] )
1671 psz_device = config_GetPsz( p_intf, "vcd" );
1674 /* Omit the beginning MRL-selector characters */
1675 psz_device = strdup( psz_name + 6 );
1679 else if( !strncmp(psz_name, "cdda://", 7 ) )
1681 switch( psz_name[7] )
1685 psz_device = config_GetPsz( p_intf, "cd-audio" );
1688 /* Omit the beginning MRL-selector characters */
1689 psz_device = strdup( psz_name + 7 );
1695 psz_device = strdup( psz_name );
1701 if( psz_device == NULL )
1706 /* Remove what we have after @ */
1707 for( psz_parser = psz_device ; *psz_parser ; psz_parser++ )
1709 if( *psz_parser == '@' )
1716 /* If there's a stream playing, we aren't allowed to eject ! */
1717 if( p_intf->p_sys->p_input == NULL )
1719 msg_Dbg( p_intf, "ejecting %s", psz_device );
1721 intf_Eject( p_intf, psz_device );
1727 static void PlayPause( intf_thread_t *p_intf )
1729 input_thread_t *p_input = p_intf->p_sys->p_input;
1730 playlist_t *p_playlist = pl_Get( p_intf );
1735 var_Get( p_input, "state", &val );
1736 if( val.i_int != PAUSE_S )
1738 val.i_int = PAUSE_S;
1742 val.i_int = PLAYING_S;
1744 var_Set( p_input, "state", val );
1747 playlist_Play( p_playlist );
1750 static int HandleKey( intf_thread_t *p_intf, int i_key )
1752 intf_sys_t *p_sys = p_intf->p_sys;
1755 playlist_t *p_playlist = pl_Get( p_intf );
1757 if( p_sys->i_box_type == BOX_PLAYLIST )
1760 bool b_box_plidx_follow = false;
1764 /* Playlist Settings */
1766 var_ToggleBool( p_playlist, "random" );
1769 var_ToggleBool( p_playlist, "loop" );
1772 var_ToggleBool( p_playlist, "repeat" );
1777 playlist_RecursiveNodeSort( p_playlist,
1778 PlaylistGetRoot( p_intf ),
1779 SORT_TITLE_NODES_FIRST, ORDER_NORMAL );
1780 p_sys->b_need_update = true;
1783 playlist_RecursiveNodeSort( p_playlist,
1784 PlaylistGetRoot( p_intf ),
1785 SORT_TITLE_NODES_FIRST, ORDER_REVERSE );
1786 p_sys->b_need_update = true;
1791 switch( p_sys->i_current_view )
1794 p_sys->i_current_view = VIEW_ONELEVEL;
1797 p_sys->i_current_view = VIEW_CATEGORY;
1799 //p_sys->b_need_update = true;
1800 PlaylistRebuild( p_intf );
1803 /* Playlist navigation */
1805 FindIndex( p_intf, p_playlist );
1808 p_sys->i_box_plidx = 0;
1811 /* workaround for FreeBSD + xterm:
1812 * see http://www.nabble.com/curses-vs.-xterm-key-mismatch-t3574377.html */
1816 p_sys->i_box_plidx = p_playlist->items.i_size - 1;
1819 p_sys->i_box_plidx--;
1822 p_sys->i_box_plidx++;
1825 p_sys->i_box_plidx -= p_sys->i_box_lines;
1828 p_sys->i_box_plidx += p_sys->i_box_lines;
1835 playlist_item_t *p_item;
1838 p_item = p_sys->pp_plist[p_sys->i_box_plidx]->p_item;
1839 if( p_item->i_children == -1 )
1841 playlist_DeleteFromInput( p_playlist,
1842 p_item->p_input, pl_Locked );
1846 playlist_NodeDelete( p_playlist, p_item,
1850 PlaylistRebuild( p_intf );
1857 if( !p_sys->pp_plist[p_sys->i_box_plidx] )
1862 if( p_sys->pp_plist[p_sys->i_box_plidx]->p_item->i_children
1865 playlist_item_t *p_item, *p_parent;
1867 p_sys->pp_plist[p_sys->i_box_plidx]->p_item;
1870 p_parent = p_playlist->p_root_onelevel;
1871 while( p_parent->p_parent )
1872 p_parent = p_parent->p_parent;
1873 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
1874 pl_Unlocked, p_parent, p_item );
1876 else if( p_sys->pp_plist[p_sys->i_box_plidx]->p_item->i_children
1878 { /* We only want to set the current node */
1879 playlist_Stop( p_playlist );
1880 p_sys->p_node = p_sys->pp_plist[p_sys->i_box_plidx]->p_item;
1884 p_sys->p_node = p_sys->pp_plist[p_sys->i_box_plidx]->p_item;
1885 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked,
1886 p_sys->pp_plist[p_sys->i_box_plidx]->p_item, NULL );
1888 b_box_plidx_follow = true;
1897 int i_max = p_sys->i_plist_entries;
1898 if( p_sys->i_box_plidx >= i_max ) p_sys->i_box_plidx = i_max - 1;
1899 if( p_sys->i_box_plidx < 0 ) p_sys->i_box_plidx = 0;
1902 if( PlaylistIsPlaying( p_playlist,
1903 p_sys->pp_plist[p_sys->i_box_plidx]->p_item ) )
1904 b_box_plidx_follow = true;
1906 p_sys->b_box_plidx_follow = b_box_plidx_follow;
1910 if( p_sys->i_box_type == BOX_BROWSE )
1913 /* Browser navigation */
1917 p_sys->i_box_bidx = 0;
1923 p_sys->i_box_bidx = p_sys->i_dir_entries - 1;
1926 p_sys->i_box_bidx--;
1929 p_sys->i_box_bidx++;
1932 p_sys->i_box_bidx -= p_sys->i_box_lines;
1935 p_sys->i_box_bidx += p_sys->i_box_lines;
1937 case '.': /* Toggle show hidden files */
1938 p_sys->b_show_hidden_files = ( p_sys->b_show_hidden_files ==
1939 true ? false : true );
1947 if( p_sys->pp_dir_entries[p_sys->i_box_bidx]->b_file || i_key == ' ' )
1950 if( asprintf( &psz_uri, "%s://%s/%s",
1951 p_sys->pp_dir_entries[p_sys->i_box_bidx]->b_file ?
1952 "file" : "directory",
1953 p_sys->psz_current_dir,
1954 p_sys->pp_dir_entries[p_sys->i_box_bidx]->psz_path
1960 playlist_item_t *p_parent = p_sys->p_node;
1964 p_parent = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
1967 p_parent = p_playlist->p_local_onelevel;
1970 while( p_parent->p_parent && p_parent->p_parent->p_parent )
1971 p_parent = p_parent->p_parent;
1973 playlist_Add( p_playlist, psz_uri, NULL, PLAYLIST_APPEND,
1975 p_parent->p_input ==
1976 p_playlist->p_local_onelevel->p_input
1979 p_sys->i_box_type = BOX_PLAYLIST;
1984 if( asprintf( &(p_sys->psz_current_dir), "%s/%s", p_sys->psz_current_dir,
1985 p_sys->pp_dir_entries[p_sys->i_box_bidx]->psz_path ) != -1 )
1995 if( p_sys->i_box_bidx >= p_sys->i_dir_entries ) p_sys->i_box_bidx = p_sys->i_dir_entries - 1;
1996 if( p_sys->i_box_bidx < 0 ) p_sys->i_box_bidx = 0;
2000 else if( p_sys->i_box_type == BOX_HELP || p_sys->i_box_type == BOX_INFO ||
2001 p_sys->i_box_type == BOX_META || p_sys->i_box_type == BOX_STATS ||
2002 p_sys->i_box_type == BOX_OBJECTS )
2007 p_sys->i_box_start = 0;
2013 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
2016 if( p_sys->i_box_start > 0 ) p_sys->i_box_start--;
2019 if( p_sys->i_box_start < p_sys->i_box_lines_total - 1 )
2021 p_sys->i_box_start++;
2025 p_sys->i_box_start -= p_sys->i_box_lines;
2026 if( p_sys->i_box_start < 0 ) p_sys->i_box_start = 0;
2029 p_sys->i_box_start += p_sys->i_box_lines;
2030 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
2032 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
2039 else if( p_sys->i_box_type == BOX_NONE )
2044 p_sys->f_slider = 0;
2045 ManageSlider( p_intf );
2051 p_sys->f_slider = 99.9;
2052 ManageSlider( p_intf );
2055 p_sys->f_slider += 5.0;
2056 if( p_sys->f_slider >= 99.0 ) p_sys->f_slider = 99.0;
2057 ManageSlider( p_intf );
2060 p_sys->f_slider -= 5.0;
2061 if( p_sys->f_slider < 0.0 ) p_sys->f_slider = 0.0;
2062 ManageSlider( p_intf );
2069 else if( p_sys->i_box_type == BOX_SEARCH && p_sys->psz_search_chain )
2071 int i_chain_len = strlen( p_sys->psz_search_chain );
2081 if( i_chain_len > 0 )
2083 p_sys->psz_old_search = strdup( p_sys->psz_search_chain );
2085 else if( p_sys->psz_old_search )
2087 SearchPlaylist( p_intf, p_sys->psz_old_search );
2089 p_sys->i_box_type = BOX_PLAYLIST;
2091 case 0x1b: /* ESC */
2092 /* Alt+key combinations return 2 keys in the terminal keyboard:
2093 * ESC, and the 2nd key.
2094 * If some other key is available immediately (where immediately
2095 * means after wgetch() 1 second delay ), that means that the
2096 * ESC key was not pressed.
2098 * man 3X curs_getch says:
2100 * Use of the escape key by a programmer for a single
2101 * character function is discouraged, as it will cause a delay
2102 * of up to one second while the keypad code looks for a
2103 * following function-key sequence.
2106 if( wgetch( p_sys->w ) != ERR )
2111 p_sys->i_box_plidx = p_sys->i_before_search;
2112 p_sys->i_box_type = BOX_PLAYLIST;
2116 RemoveLastUTF8Entity( p_sys->psz_search_chain, i_chain_len );
2120 #ifdef HAVE_NCURSESW
2121 if( i_chain_len + 1 < SEARCH_CHAIN_SIZE )
2123 p_sys->psz_search_chain[i_chain_len] = (char) i_key;
2124 p_sys->psz_search_chain[i_chain_len + 1] = '\0';
2127 char *psz_utf8 = KeyToUTF8( i_key, p_sys->psz_partial_keys );
2129 if( psz_utf8 != NULL )
2131 if( i_chain_len + strlen( psz_utf8 ) < SEARCH_CHAIN_SIZE )
2133 strcpy( p_sys->psz_search_chain + i_chain_len,
2142 free( p_sys->psz_old_search );
2143 p_sys->psz_old_search = NULL;
2144 SearchPlaylist( p_intf, p_sys->psz_search_chain );
2147 else if( p_sys->i_box_type == BOX_OPEN && p_sys->psz_open_chain )
2149 int i_chain_len = strlen( p_sys->psz_open_chain );
2160 if( i_chain_len > 0 )
2162 playlist_item_t *p_parent = p_sys->p_node;
2166 p_parent = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
2168 p_parent = p_playlist->p_local_onelevel;
2170 while( p_parent->p_parent && p_parent->p_parent->p_parent )
2171 p_parent = p_parent->p_parent;
2174 playlist_Add( p_playlist, p_sys->psz_open_chain, NULL,
2175 PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END,
2176 p_parent->p_input ==
2177 p_playlist->p_local_onelevel->p_input
2180 p_sys->b_box_plidx_follow = true;
2182 p_sys->i_box_type = BOX_PLAYLIST;
2184 case 0x1b: /* ESC */
2185 if( wgetch( p_sys->w ) != ERR )
2190 p_sys->i_box_type = BOX_PLAYLIST;
2194 RemoveLastUTF8Entity( p_sys->psz_open_chain, i_chain_len );
2198 #ifdef HAVE_NCURSESW
2199 if( i_chain_len + 1 < OPEN_CHAIN_SIZE )
2201 p_sys->psz_open_chain[i_chain_len] = (char) i_key;
2202 p_sys->psz_open_chain[i_chain_len + 1] = '\0';
2205 char *psz_utf8 = KeyToUTF8( i_key, p_sys->psz_partial_keys );
2207 if( psz_utf8 != NULL )
2209 if( i_chain_len + strlen( psz_utf8 ) < OPEN_CHAIN_SIZE )
2211 strcpy( p_sys->psz_open_chain + i_chain_len,
2226 case 0x1b: /* ESC */
2227 if( wgetch( p_sys->w ) != ERR )
2235 libvlc_Quit( p_intf->p_libvlc );
2241 if( p_sys->i_box_type == BOX_INFO )
2242 p_sys->i_box_type = BOX_NONE;
2244 p_sys->i_box_type = BOX_INFO;
2245 p_sys->i_box_lines_total = 0;
2248 if( p_sys->i_box_type == BOX_META )
2249 p_sys->i_box_type = BOX_NONE;
2251 p_sys->i_box_type = BOX_META;
2252 p_sys->i_box_lines_total = 0;
2255 if( p_sys->i_box_type == BOX_LOG )
2256 p_sys->i_box_type = BOX_NONE;
2258 p_sys->i_box_type = BOX_LOG;
2261 if( p_sys->i_box_type == BOX_PLAYLIST )
2262 p_sys->i_box_type = BOX_NONE;
2264 p_sys->i_box_type = BOX_PLAYLIST;
2267 if( p_sys->i_box_type == BOX_BROWSE )
2268 p_sys->i_box_type = BOX_NONE;
2270 p_sys->i_box_type = BOX_BROWSE;
2273 if( p_sys->i_box_type == BOX_OBJECTS )
2274 p_sys->i_box_type = BOX_NONE;
2276 p_sys->i_box_type = BOX_OBJECTS;
2279 if( p_sys->i_box_type == BOX_STATS )
2280 p_sys->i_box_type = BOX_NONE;
2282 p_sys->i_box_type = BOX_STATS;
2285 p_sys->b_color = !p_sys->b_color;
2286 if( p_sys->b_color && !p_sys->b_color_started )
2287 start_color_and_pairs( p_intf );
2291 if( p_sys->i_box_type == BOX_HELP )
2292 p_sys->i_box_type = BOX_NONE;
2294 p_sys->i_box_type = BOX_HELP;
2295 p_sys->i_box_lines_total = 0;
2298 if( p_sys->i_box_type != BOX_SEARCH )
2300 if( p_sys->psz_search_chain )
2302 p_sys->psz_search_chain[0] = '\0';
2303 p_sys->b_box_plidx_follow = false;
2304 p_sys->i_before_search = p_sys->i_box_plidx;
2305 p_sys->i_box_type = BOX_SEARCH;
2309 case 'A': /* Open */
2310 if( p_sys->i_box_type != BOX_OPEN )
2312 if( p_sys->psz_open_chain )
2314 p_sys->psz_open_chain[0] = '\0';
2315 p_sys->i_box_type = BOX_OPEN;
2322 p_sys->f_slider += 1.0;
2323 if( p_sys->f_slider > 99.9 ) p_sys->f_slider = 99.9;
2324 ManageSlider( p_intf );
2328 p_sys->f_slider -= 1.0;
2329 if( p_sys->f_slider < 0.0 ) p_sys->f_slider = 0.0;
2330 ManageSlider( p_intf );
2333 /* Common control */
2336 bool fs = var_ToggleBool( p_playlist, "fullscreen" );
2337 if( p_intf->p_sys->p_input )
2339 vout_thread_t *p_vout = input_GetVout( p_intf->p_sys->p_input );
2342 var_SetBool( p_vout, "fullscreen", fs );
2343 vlc_object_release( p_vout );
2351 PlayPause( p_intf );
2355 playlist_Stop( p_playlist );
2363 if( p_sys->p_input )
2364 var_TriggerCallback( p_sys->p_input, "prev-title" );
2368 if( p_sys->p_input )
2369 var_TriggerCallback( p_sys->p_input, "next-title" );
2373 if( p_sys->p_input )
2374 var_TriggerCallback( p_sys->p_input, "prev-chapter" );
2378 if( p_sys->p_input )
2379 var_TriggerCallback( p_sys->p_input, "next-chapter" );
2383 playlist_Prev( p_playlist );
2388 playlist_Next( p_playlist );
2393 aout_VolumeUp( p_playlist, 1, NULL );
2398 aout_VolumeDown( p_playlist, 1, NULL );
2403 * ^l should clear and redraw the screen
2418 /*****************************************************************************
2419 * Run: ncurses thread
2420 *****************************************************************************/
2421 static void Run( intf_thread_t *p_intf )
2423 intf_sys_t *p_sys = p_intf->p_sys;
2424 playlist_t *p_playlist = pl_Get( p_intf );
2425 p_sys->p_playlist = p_playlist;
2428 time_t t_last_refresh;
2429 int canc = vlc_savecancel();
2432 * force drawing the interface for the first time
2434 t_last_refresh = ( time( 0 ) - 1);
2436 * force building of the playlist array
2438 PlaylistRebuild( p_intf );
2439 var_AddCallback( p_playlist, "intf-change", PlaylistChanged, p_intf );
2440 var_AddCallback( p_playlist, "playlist-item-append", PlaylistChanged, p_intf );
2442 while( vlc_object_alive( p_intf ) )
2444 msleep( INTF_IDLE_SLEEP );
2446 /* Update the input */
2447 if( p_sys->p_input == NULL )
2449 p_sys->p_input = playlist_CurrentInput( p_playlist );
2451 else if( p_sys->p_input->b_dead )
2453 vlc_object_release( p_sys->p_input );
2454 p_sys->p_input = NULL;
2455 p_sys->f_slider = p_sys->f_slider_old = 0.0;
2456 p_sys->b_box_cleared = false;
2460 if( p_sys->b_box_plidx_follow && playlist_CurrentPlayingItem(p_playlist) )
2463 FindIndex( p_intf, p_playlist );
2468 while( ( i_key = wgetch( p_sys->w ) ) != -1 )
2471 * HandleKey returns 1 if the screen needs to be redrawn
2473 if( HandleKey( p_intf, i_key ) )
2475 Redraw( p_intf, &t_last_refresh );
2479 if( p_sys->f_slider > 0.0001 && !p_sys->b_box_cleared )
2482 Redraw( p_intf, &t_last_refresh );
2483 p_sys->b_box_cleared = true;
2487 * redraw the screen every second
2489 if( (time(0) - t_last_refresh) >= 1 )
2491 ManageSlider( p_intf );
2492 Redraw( p_intf, &t_last_refresh );
2495 var_DelCallback( p_playlist, "intf-change", PlaylistChanged, p_intf );
2496 var_DelCallback( p_playlist, "playlist-item-append", PlaylistChanged, p_intf );
2497 vlc_restorecancel( canc );
2500 /*****************************************************************************
2501 * Open: initialize and create window
2502 *****************************************************************************/
2503 static int Open( vlc_object_t *p_this )
2505 intf_thread_t *p_intf = (intf_thread_t *)p_this;
2508 /* Allocate instance and initialize some members */
2509 p_sys = p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
2512 p_sys->p_node = NULL;
2513 p_sys->p_input = NULL;
2514 p_sys->f_slider = 0.0;
2515 p_sys->f_slider_old = 0.0;
2516 p_sys->i_box_type = BOX_PLAYLIST;
2517 p_sys->i_box_lines = 0;
2518 p_sys->i_box_start= 0;
2519 p_sys->i_box_lines_total = 0;
2520 p_sys->b_box_plidx_follow = true;
2521 p_sys->b_box_cleared = false;
2522 p_sys->i_box_plidx = 0;
2523 p_sys->i_box_bidx = 0;
2524 // FIXME p_sys->p_sub = msg_Subscribe( p_intf );
2525 p_sys->b_color = var_CreateGetBool( p_intf, "color" );
2526 p_sys->b_color_started = false;
2528 #ifndef HAVE_NCURSESW
2529 memset( p_sys->psz_partial_keys, 0, sizeof( p_sys->psz_partial_keys ) );
2532 /* Initialize the curses library */
2533 p_sys->w = initscr();
2535 if( p_sys->b_color )
2536 start_color_and_pairs( p_intf );
2538 keypad( p_sys->w, TRUE );
2539 /* Don't do NL -> CR/NL */
2541 /* Take input chars one at a time */
2545 /* Invisible cursor */
2547 /* Non blocking wgetch() */
2548 wtimeout( p_sys->w, 0 );
2552 /* exported function */
2553 p_intf->pf_run = Run;
2555 /* Stop printing errors to the console */
2556 freopen( "/dev/null", "wb", stderr );
2558 /* Set defaul playlist view */
2559 p_sys->i_current_view = VIEW_CATEGORY;
2560 p_sys->pp_plist = NULL;
2561 p_sys->i_plist_entries = 0;
2562 p_sys->b_need_update = false;
2564 /* Initialize search chain */
2565 p_sys->psz_search_chain = malloc( SEARCH_CHAIN_SIZE + 1 );
2566 p_sys->psz_old_search = NULL;
2567 p_sys->i_before_search = 0;
2569 /* Initialize open chain */
2570 p_sys->psz_open_chain = malloc( OPEN_CHAIN_SIZE + 1 );
2572 /* Initialize browser options */
2573 char* psz_tmp = var_CreateGetString( p_intf, "browse-dir" );
2574 if( psz_tmp && *psz_tmp )
2575 p_sys->psz_current_dir = psz_tmp;
2578 p_sys->psz_current_dir = config_GetUserDir( VLC_HOME_DIR );
2582 p_sys->i_dir_entries = 0;
2583 p_sys->pp_dir_entries = NULL;
2584 p_sys->b_show_hidden_files = false;
2590 /*****************************************************************************
2591 * Close: destroy interface window
2592 *****************************************************************************/
2593 static void Close( vlc_object_t *p_this )
2595 intf_thread_t *p_intf = (intf_thread_t *)p_this;
2596 intf_sys_t *p_sys = p_intf->p_sys;
2598 PlaylistDestroy( p_intf );
2600 while( p_sys->i_dir_entries )
2602 struct dir_entry_t *p_dir_entry = p_sys->pp_dir_entries[0];
2603 free( p_dir_entry->psz_path );
2604 REMOVE_ELEM( p_sys->pp_dir_entries, p_sys->i_dir_entries, 0 );
2605 free( p_dir_entry );
2607 p_sys->pp_dir_entries = NULL;
2609 free( p_sys->psz_current_dir );
2610 free( p_sys->psz_search_chain );
2611 free( p_sys->psz_old_search );
2612 free( p_sys->psz_open_chain );
2614 if( p_sys->p_input )
2616 vlc_object_release( p_sys->p_input );
2619 /* Close the ncurses interface */
2622 // FIXME msg_Unsubscribe( p_intf, p_sys->p_sub );
2624 /* Destroy structure */