]> git.sesse.net Git - vlc/blobdiff - modules/gui/ncurses.c
* Makefile.am: backport of 11352.
[vlc] / modules / gui / ncurses.c
index 6b3a5a331e25f12682cf379660f8ffca94b931d8..a5dfad6ff77d84f3a4996581608df7d8c584c512 100644 (file)
@@ -82,6 +82,7 @@ static int  PlaylistChanged( vlc_object_t *, const char *, vlc_value_t,
                              vlc_value_t, void * );
 static void FindIndex      ( intf_thread_t * );
 static void SearchPlaylist ( intf_thread_t *, char * );
+static int  SubSearchPlaylist( intf_thread_t *, char *, int, int );
 static void ManageSlider   ( intf_thread_t * );
 static void ReadDir        ( intf_thread_t * );
 
@@ -95,7 +96,8 @@ static void ReadDir        ( intf_thread_t * );
     "will show you initially.")
 
 vlc_module_begin();
-    set_description( _("ncurses interface") );
+    set_shortname( "Ncurses" );
+    set_description( _("Ncurses interface") );
     set_capability( "interface", 10 );
     set_category( CAT_INTERFACE );
     set_subcategory( SUBCAT_INTERFACE_GENERAL );
@@ -222,7 +224,7 @@ static int Open( vlc_object_t *p_this )
     var_Set( p_intf->p_vlc, "verbose", val );
 
     /* Set defaul playlist view */
-    p_sys->i_current_view = VIEW_SIMPLE;
+    p_sys->i_current_view = VIEW_CATEGORY;
     p_sys->pp_plist = NULL;
     p_sys->i_plist_entries = 0;
     p_sys->b_need_update = VLC_FALSE;
@@ -437,14 +439,11 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
             case 'v':
                 switch( p_sys->i_current_view )
                 {
-                    case VIEW_SIMPLE:
-                        p_sys->i_current_view = VIEW_CATEGORY;
-                        break;
                     case VIEW_CATEGORY:
                         p_sys->i_current_view = VIEW_ALL;
                         break;
                     default:
-                        p_sys->i_current_view = VIEW_SIMPLE;
+                        p_sys->i_current_view = VIEW_CATEGORY;
                 }
                 PlaylistRebuild( p_intf );
                 FindIndex( p_intf );
@@ -836,16 +835,31 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
         /* Common control */
         case 'f':
         {
-            vout_thread_t *p_vout;
             if( p_intf->p_sys->p_input )
             {
+                vout_thread_t *p_vout;
                 p_vout = vlc_object_find( p_intf->p_sys->p_input,
                                           VLC_OBJECT_VOUT, FIND_CHILD );
                 if( p_vout )
                 {
-                    p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
+                    var_Get( p_vout, "fullscreen", &val );
+                    val.b_bool = !val.b_bool;
+                    var_Set( p_vout, "fullscreen", val );
                     vlc_object_release( p_vout );
                 }
+                else
+                {
+                    playlist_t *p_playlist;
+                    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                  FIND_ANYWHERE );
+                    if( p_playlist )
+                    {
+                        var_Get( p_playlist, "fullscreen", &val );
+                        val.b_bool = !val.b_bool;
+                        var_Set( p_playlist, "fullscreen", val );
+                        vlc_object_release( p_playlist );
+                    }
+                }
             }
             return 0;
         }
@@ -968,15 +982,16 @@ static void ManageSlider( intf_thread_t *p_intf )
 
 static void SearchPlaylist( intf_thread_t *p_intf, char *psz_searchstring )
 {
-    bool b_ok = false;
-    int i_current;
+    int i_max;
     int i_first = 0 ;
     int i_item = -1;
     intf_sys_t *p_sys = p_intf->p_sys;
     playlist_t *p_playlist = p_sys->p_playlist;
 
     if( p_sys->i_before_search >= 0 )
+    {
         i_first = p_sys->i_before_search;
+    }
 
     if( ( ! psz_searchstring ) ||  strlen( psz_searchstring ) <= 0 )
     {
@@ -984,38 +999,55 @@ static void SearchPlaylist( intf_thread_t *p_intf, char *psz_searchstring )
         return;
     }
 
-    for( i_current = i_first + 1; i_current < p_playlist->i_size;
-         i_current++ )
+    i_max = p_sys->i_current_view == VIEW_ALL ?
+                p_playlist->i_size : p_sys->i_plist_entries;
+
+    i_item = SubSearchPlaylist( p_intf, psz_searchstring, i_first + 1, i_max );
+    if( i_item < 0 )
     {
-        if( strcasestr( p_playlist->pp_items[i_current]->input.psz_name,
-                        psz_searchstring ) != NULL
-            || strcasestr( p_playlist->pp_items[i_current]->input.psz_uri,
-                           psz_searchstring ) != NULL )
-        {
-            i_item = i_current;
-            b_ok = true;
-            break;
-        }
+        i_item = SubSearchPlaylist( p_intf, psz_searchstring, 0, i_first );
     }
-    if( !b_ok )
+
+    if( i_item < 0 || i_item >= i_max ) return;
+
+    p_sys->i_box_plidx = i_item;
+}
+
+static int SubSearchPlaylist( intf_thread_t *p_intf, char *psz_searchstring,
+                              int i_start, int i_stop )
+{
+    intf_sys_t *p_sys = p_intf->p_sys;
+    playlist_t *p_playlist = p_sys->p_playlist;
+    int i, i_item = -1;
+
+    if( p_sys->i_current_view == VIEW_ALL )
     {
-        for( i_current = 0; i_current < i_first; i_current++ )
+        for( i = i_start + 1; i < i_stop; i++ )
         {
-            if( strcasestr( p_playlist->pp_items[i_current]->input.psz_name,
+            if( strcasestr( p_playlist->pp_items[i]->input.psz_name,
                             psz_searchstring ) != NULL
-                || strcasestr( p_playlist->pp_items[i_current]->input.psz_uri,
+                || strcasestr( p_playlist->pp_items[i]->input.psz_uri,
                                psz_searchstring ) != NULL )
             {
-                i_item = i_current;
-                b_ok = true;
+                i_item = i;
+                break;
+            }
+        }
+    }
+    else
+    {
+        for( i = i_start + 1; i < i_stop; i++ )
+        {
+            if( strcasestr( p_sys->pp_plist[i]->psz_display,
+                            psz_searchstring ) != NULL )
+            {
+                i_item = i;
                 break;
             }
         }
     }
 
-    if( i_item < 0 || i_item >= p_playlist->i_size ) return;
-
-    p_sys->i_box_plidx = i_item;
+    return i_item;
 }
 
 
@@ -1420,9 +1452,7 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
         {
             PlaylistRebuild( p_intf );
         }
-        if( p_sys->b_box_plidx_follow &&
-            ( p_sys->pp_plist[p_sys->i_box_plidx]->p_item !=
-              p_sys->p_playlist->status.p_item ) )
+        if( p_sys->b_box_plidx_follow )
         {
             FindIndex( p_intf );
         }
@@ -1645,7 +1675,9 @@ static void FindIndex( intf_thread_t *p_intf )
     {
          p_sys->i_box_plidx = p_sys->p_playlist->i_index;
     }
-    else
+    else if( ( p_sys->i_box_plidx < p_sys->i_plist_entries &&
+               p_sys->pp_plist[p_sys->i_box_plidx]->p_item !=
+               p_sys->p_playlist->status.p_item ) )
     {
         for( i = 0; i < p_sys->i_plist_entries; i++ )
         {