Changeset 3890f30a863e18a1a8ca7114c2285ddcdf0349f9

Show
Ignore:
Timestamp:
18/11/07 21:47:58 (1 year ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1195418878 +0000
git-parent:

[a89d3bb46ca0b352eba3790ca2a856802722be9b]

git-author:
Rafaël Carré <funman@videolan.org> 1195418878 +0000
Message:

ncurses: various bugfixes

  • Workaround KEY_END not working with $TERM=xterm on FreeBSD
  • Don't abort when printing strings with unprintable characters ( for example when the user presses ctrl+something in FIND or OPEN boxes )
  • Show a '*' in front of the current node
  • Add files in the correct node

This is how nodes do work in ncurses: When you select an item with 'Enter',

  • if it's a leaf, then start playing it, and set the current node to the toplevel parent of that leaf (example: local playlist, or media library)
  • if it's an empty node, then stop the playlist, and set the current node to be that one, so you can add items to it
  • if it's a node with children, set the current node to that one, and start playing the next children of that one

The "current node" means that the playlist will never reach items which aren't direct or indirect children of that node, and so it will stop after the last one has been reached

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/ncurses.c

    rff6ab8f r3890f30  
    541541                p_sys->i_box_plidx = 0; 
    542542                break; 
     543#ifdef __FreeBSD__ 
     544/* workaround for FreeBSD + xterm: 
     545 * see http://www.nabble.com/curses-vs.-xterm-key-mismatch-t3574377.html */ 
     546            case KEY_SELECT: 
     547#endif 
    543548            case KEY_END: 
    544549                p_sys->i_box_plidx = p_sys->p_playlist->items.i_size - 1; 
     
    601606                                      VLC_TRUE, p_parent, p_item ); 
    602607                } 
     608                else if( p_sys->pp_plist[p_sys->i_box_plidx]->p_item->i_children 
     609                        == 0 ) 
     610                {   /* We only want to set the current node */ 
     611                    vlc_object_lock( p_sys->p_playlist ); 
     612 
     613                    p_sys->p_playlist->request.p_node =  
     614                        p_sys->pp_plist[p_sys->i_box_plidx]->p_item; 
     615                    p_sys->p_playlist->request.i_skip = 0; 
     616                    p_sys->p_playlist->request.p_item = 
     617                        p_sys->p_playlist->status.p_item; 
     618                    p_sys->p_playlist->request.b_request = VLC_TRUE; 
     619                    p_sys->p_playlist->request.i_status = PLAYLIST_STOPPED; 
     620 
     621                    vlc_object_unlock( p_sys->p_playlist ); 
     622                } 
    603623                else 
    604                 {   /* FIXME doesn't work if the node is empty */ 
     624                { 
    605625                    playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY, 
    606626                        VLC_TRUE, 
     
    636656                p_sys->i_box_bidx = 0; 
    637657                break; 
     658#ifdef __FreeBSD__ 
     659            case KEY_SELECT: 
     660#endif 
    638661            case KEY_END: 
    639662                p_sys->i_box_bidx = p_sys->i_dir_entries - 1; 
     
    670693                    playlist_item_t *p_parent = p_sys->p_playlist->status.p_node; 
    671694                    if( !p_parent ) 
    672                         p_parent = p_sys->p_playlist->p_root_onelevel; 
    673  
    674                     while( p_parent->p_parent
     695                        p_parent = p_sys->p_playlist->p_local_onelevel; 
     696 
     697                    while( p_parent->p_parent && p_parent->p_parent->p_parent
    675698                        p_parent = p_parent->p_parent; 
    676699 
    677700                    playlist_Add( p_sys->p_playlist, psz_uri, NULL, 
    678701                                  PLAYLIST_APPEND, PLAYLIST_END, 
    679                                   p_parent == p_sys->p_playlist->p_root_onelevel 
     702                                  p_parent->p_input ==  
     703                                    p_sys->p_playlist->p_local_onelevel->p_input 
    680704                                  , VLC_FALSE ); 
    681705                    p_sys->i_box_type = BOX_PLAYLIST; 
     
    714738                p_sys->i_box_start = 0; 
    715739                return 1; 
     740#ifdef __FreeBSD__ 
     741            case KEY_SELECT: 
     742#endif 
    716743            case KEY_END: 
    717744                p_sys->i_box_start = p_sys->i_box_lines_total - 1; 
     
    749776                ManageSlider( p_intf ); 
    750777                return 1; 
     778#ifdef __FreeBSD__ 
     779            case KEY_SELECT: 
     780#endif 
    751781            case KEY_END: 
    752782                p_sys->f_slider = 99.9; 
     
    835865                { 
    836866                    playlist_item_t *p_parent = p_sys->p_playlist->status.p_node; 
     867 
    837868                    if( !p_parent ) 
    838                         p_parent = p_sys->p_playlist->p_root_onelevel; 
    839  
    840                     while( p_parent->p_parent
     869                        p_parent = p_sys->p_playlist->p_local_onelevel; 
     870 
     871                    while( p_parent->p_parent && p_parent->p_parent->p_parent
    841872                        p_parent = p_parent->p_parent; 
    842873 
    843874                    playlist_Add( p_playlist, p_sys->psz_open_chain, NULL, 
    844875                                  PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END, 
    845                                   p_parent == p_sys->p_playlist->p_root_onelevel 
     876                                  p_parent->p_input ==  
     877                                    p_sys->p_playlist->p_local_onelevel->p_input 
    846878                                  , VLC_FALSE ); 
    847879                    p_sys->b_box_plidx_follow = VLC_TRUE; 
     
    11931225        i_width = wcswidth( psz_wide, i_char_len ); 
    11941226        if( i_width == (size_t)-1 ) 
     1227        { 
    11951228            /* a non printable character was encountered */ 
    1196             abort(); 
     1229            unsigned int i; 
     1230            int i_cwidth; 
     1231            i_width = 0; 
     1232            for( i = 0 ; i < i_char_len ; i++ ) 
     1233            { 
     1234                i_cwidth = wcwidth( psz_wide[i] ); 
     1235                if( i_cwidth != -1 ) 
     1236                    i_width += i_cwidth; 
     1237            } 
     1238        } 
    11971239    } 
    11981240    if( i_width > (size_t)w ) 
     
    17911833        { 
    17921834            vlc_bool_t b_selected = ( p_sys->i_box_plidx == i_item ); 
    1793             int c = ( PlaylistIsPlaying( p_intf, 
    1794                           p_sys->pp_plist[i_item]->p_item ) ) ? '>' : ' '; 
     1835            int c = ' '; 
     1836            if( p_sys->pp_plist[i_item]->p_item->p_input == 
     1837                        p_sys->p_playlist->status.p_node->p_input ) 
     1838                c = '*'; 
     1839            else if( PlaylistIsPlaying( p_intf, 
     1840                        p_sys->pp_plist[i_item]->p_item ) ) 
     1841                c = '>'; 
    17951842 
    17961843            if( y >= y_end ) break;