Changeset 9bd7b3750efafe34f0df0d6c7965f69837b9177d

Show
Ignore:
Timestamp:
10/01/08 19:20:43 (11 months ago)
Author:
Rémi Duraffort <ivoire@videolan.org>
git-committer:
Rémi Duraffort <ivoire@videolan.org> 1199989243 +0000
git-parent:

[627fed2d229fed855c2d2f758dec6bcea586e143]

git-author:
Rémi Duraffort <ivoire@videolan.org> 1199989243 +0000
Message:

ncurses interface:

  • support colors if --color is enabled (it is by default)
  • use _() to permit translation of the interface
  • matches only ESC, and not special keys combinations (it was boring to have VLC exit when inadvertently hitting alt+something
  • do not use KeyToUTF8() at all when in wide characters mode, since we assume UTF-8 locale
  • display the help shortcut when the interface is stopped, rather than in the title

Patch by funman.

Files:

Legend:

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

    rc90ad6f r9bd7b37  
    22 * ncurses.c : NCurses interface for vlc 
    33 ***************************************************************************** 
    4  * Copyright (C) 2001-2007 the VideoLAN team 
     4 * Copyright © 2001-2007 the VideoLAN team 
    55 * $Id$ 
    66 * 
     
    2626 *****************************************************************************/ 
    2727 
     28/* 
     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. 
     32 */ 
     33 
    2834/***************************************************************************** 
    2935 * Preamble 
    3036 *****************************************************************************/ 
    3137#include <vlc/vlc.h> 
    32  
    33 #include <errno.h>                                                 /* ENOMEM */ 
    34 #include <time.h> 
    3538 
    3639#ifdef HAVE_NCURSESW 
     
    99102static void ReadDir        ( intf_thread_t * ); 
    100103 
     104static void start_color_and_pairs ( intf_thread_t * ); 
     105 
    101106/***************************************************************************** 
    102107 * Module descriptor 
     
    136141enum 
    137142{ 
     143    C_DEFAULT = 0, 
     144    C_TITLE, 
     145    C_PLAYLIST_1, 
     146    C_PLAYLIST_2, 
     147    C_PLAYLIST_3, 
     148    C_BOX, 
     149    C_STATUS, 
     150    C_INFO, 
     151    C_ERROR, 
     152    C_WARNING, 
     153    C_DEBUG, 
     154    C_CATEGORY, 
     155    C_FOLDER 
     156}; 
     157enum 
     158{ 
    138159    VIEW_CATEGORY, 
    139160    VIEW_ONELEVEL 
     
    152173{ 
    153174    input_thread_t *p_input; 
     175 
     176    vlc_bool_t      b_color; 
     177    vlc_bool_t      b_color_started; 
    154178 
    155179    float           f_slider; 
     
    179203 
    180204    char            *psz_open_chain; 
     205#ifndef HAVE_NCURSESW 
    181206    char             psz_partial_keys[7]; 
     207#endif 
    182208 
    183209    char            *psz_current_dir; 
     
    194220}; 
    195221 
    196 static void DrawBox( WINDOW *win, int y, int x, int h, int w, const char *title ); 
     222static void DrawBox( WINDOW *win, int y, int x, int h, int w, const char *title, vlc_bool_t b_color ); 
    197223static void DrawLine( WINDOW *win, int y, int x, int w ); 
    198224static void DrawEmptyLine( WINDOW *win, int y, int x, int w ); 
     
    222248    p_sys->i_box_bidx = 0; 
    223249    p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL ); 
     250    p_sys->b_color = p_this->p_libvlc->b_color; 
     251    p_sys->b_color_started = VLC_FALSE; 
     252 
     253#ifndef HAVE_NCURSESW 
    224254    memset( p_sys->psz_partial_keys, 0, sizeof( p_sys->psz_partial_keys ) ); 
     255#endif 
    225256 
    226257    /* Initialize the curses library */ 
    227258    p_sys->w = initscr(); 
     259 
     260    if( p_sys->b_color ) 
     261        start_color_and_pairs( p_intf ); 
     262 
    228263    keypad( p_sys->w, TRUE ); 
    229264    /* Don't do NL -> CR/NL */ 
     
    233268    /* Don't echo */ 
    234269    noecho(); 
    235  
    236     curs_set(0); 
    237     timeout(0); 
     270    /* Invisible cursor */ 
     271    curs_set( 0 ); 
     272    /* Non blocking wgetch() */ 
     273    wtimeout( p_sys->w, 0 ); 
    238274 
    239275    clear(); 
     
    387423            FindIndex( p_intf ); 
    388424        } 
    389  
    390         while( ( i_key = getch() ) != -1 ) 
     425     
     426        while( ( i_key = wgetch( p_sys->w ) ) != -1 ) 
    391427        { 
    392428            /* 
     
    418454 
    419455/* following functions are local */ 
     456static void start_color_and_pairs( intf_thread_t *p_intf ) 
     457{ 
     458    assert( p_intf->p_sys->b_color && !p_intf->p_sys->b_color_started ); 
     459 
     460    if( !has_colors() ) 
     461    { 
     462        p_intf->p_sys->b_color = VLC_FALSE; 
     463        msg_Warn( p_intf, "Terminal doesn't support colors" ); 
     464        return; 
     465    } 
     466 
     467    start_color(); 
     468 
     469    /* Available colors: BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE */ 
     470 
     471    /* untested, in all my terminals, !can_change_color() --funman */ 
     472    if( can_change_color() ) 
     473        init_color( COLOR_YELLOW, 960, 500, 0 ); /* YELLOW -> ORANGE */ 
     474 
     475    /* title */ 
     476    init_pair( C_TITLE, COLOR_YELLOW, COLOR_BLACK ); 
     477 
     478    /* jamaican playlist */ 
     479    init_pair( C_PLAYLIST_1, COLOR_GREEN, COLOR_BLACK ); 
     480    init_pair( C_PLAYLIST_2, COLOR_YELLOW, COLOR_BLACK ); 
     481    init_pair( C_PLAYLIST_3, COLOR_RED, COLOR_BLACK ); 
     482 
     483    /* used in DrawBox() */ 
     484    init_pair( C_BOX, COLOR_CYAN, COLOR_BLACK ); 
     485    /* Source, State, Position, Volume, Chapters, etc...*/ 
     486    init_pair( C_STATUS, COLOR_BLUE, COLOR_BLACK ); 
     487 
     488    /* VLC messages, keep the order from highest priority to lowest */ 
     489 
     490    /* infos */ 
     491    init_pair( C_INFO, COLOR_BLACK, COLOR_WHITE ); 
     492    /* errors */ 
     493    init_pair( C_ERROR, COLOR_RED, COLOR_BLACK ); 
     494    /* warnings */ 
     495    init_pair( C_WARNING, COLOR_YELLOW, COLOR_BLACK ); 
     496/* debug */ 
     497    init_pair( C_DEBUG, COLOR_WHITE, COLOR_BLACK ); 
     498 
     499    /* Category title (help, info, metadata) */ 
     500    init_pair( C_CATEGORY, COLOR_MAGENTA, COLOR_BLACK ); 
     501 
     502    /* Folder (BOX_BROWSE) */ 
     503    init_pair( C_FOLDER, COLOR_RED, COLOR_BLACK ); 
     504 
     505    p_intf->p_sys->b_color_started = VLC_TRUE; 
     506} 
     507 
     508#ifndef HAVE_NCURSESW 
    420509static char *KeyToUTF8( int i_key, char *psz_part ) 
    421510{ 
     
    431520    psz_part[len] = (char)i_key; 
    432521 
    433 #ifdef HAVE_NCURSESW 
    434     psz_utf8 = strdup( psz_part ); 
    435 #else 
    436522    psz_utf8 = FromLocaleDup( psz_part ); 
    437523 
     
    454540        return NULL; 
    455541    } 
    456 #endif 
    457542 
    458543    memset( psz_part, 0, 6 ); 
    459544    return psz_utf8; 
    460545} 
     546#endif 
    461547 
    462548static inline int RemoveLastUTF8Entity( char *psz, int len ) 
     
    557643            case 'D': 
    558644            case KEY_BACKSPACE: 
     645            case 0x7f: 
    559646            case KEY_DC: 
    560647            { 
     
    579666 
    580667            case KEY_ENTER: 
    581             case 0x0d: 
     668            case '\r': 
     669            case '\n': 
    582670                if( !p_sys->pp_plist[p_sys->i_box_plidx] ) 
    583671                { 
     
    664752 
    665753            case KEY_ENTER: 
    666             case 0x0d: 
     754            case '\r': 
     755            case '\n': 
    667756            case ' ': 
    668757                if( p_sys->pp_dir_entries[p_sys->i_box_bidx]->b_file || i_key == ' ' ) 
     
    787876    else if( p_sys->i_box_type == BOX_SEARCH && p_sys->psz_search_chain ) 
    788877    { 
    789         int i_chain_len; 
    790         i_chain_len = strlen( p_sys->psz_search_chain ); 
     878        int i_chain_len = strlen( p_sys->psz_search_chain ); 
    791879        switch( i_key ) 
    792880        { 
     881            case KEY_CLEAR: 
    793882            case 0x0c:      /* ^l */ 
    794883                clear(); 
    795884                return 1; 
    796885            case KEY_ENTER: 
    797             case 0x0d: 
     886            case '\r': 
     887            case '\n': 
    798888                if( i_chain_len > 0 ) 
    799889                { 
     
    806896                p_sys->i_box_type = BOX_PLAYLIST; 
    807897                return 1; 
    808             case 0x1b:      /* Esc. */ 
     898            case 0x1b: /* ESC */ 
     899                /* Alt+key combinations return 2 keys in the terminal keyboard: 
     900                 * ESC, and the 2nd key. 
     901                 * If some other key is available immediately (where immediately 
     902                 * means after wgetch() 1 second delay ), that means that the 
     903                 * ESC key was not pressed. 
     904                 * 
     905                 * man 3X curs_getch says: 
     906                 * 
     907                 * Use of the escape key by a programmer for a single 
     908                 * character function is discouraged, as it will cause a delay  
     909                 * of up to one second while the keypad code looks for a 
     910                 * following function-key sequence. 
     911                 * 
     912                 */ 
     913                if( wgetch( p_sys->w ) != ERR ) 
     914                    return 0; 
    809915                p_sys->i_box_plidx = p_sys->i_before_search; 
    810916                p_sys->i_box_type = BOX_PLAYLIST; 
    811917                return 1; 
    812918            case KEY_BACKSPACE: 
     919            case 0x7f: 
    813920                RemoveLastUTF8Entity( p_sys->psz_search_chain, i_chain_len ); 
    814921                break; 
    815922            default: 
    816923            { 
     924#ifdef HAVE_NCURSESW 
     925                if( i_chain_len + 1 < SEARCH_CHAIN_SIZE ) 
     926                { 
     927                    p_sys->psz_search_chain[i_chain_len] = (char) i_key; 
     928                    p_sys->psz_search_chain[i_chain_len + 1] = '\0'; 
     929                } 
     930#else 
    817931                char *psz_utf8 = KeyToUTF8( i_key, p_sys->psz_partial_keys ); 
    818932 
     
    826940                    free( psz_utf8 ); 
    827941                } 
     942#endif 
    828943                break; 
    829944            } 
     
    843958        switch( i_key ) 
    844959        { 
    845             case 0x0c:      /* ^l */ 
     960            case KEY_CLEAR: 
     961            case 0x0c:          /* ^l */ 
    846962                clear(); 
    847963                return 1; 
    848964            case KEY_ENTER: 
    849             case 0x0d: 
     965            case '\r':  
     966            case '\n': 
    850967                if( i_chain_len > 0 ) 
    851968                { 
     
    870987                p_sys->i_box_type = BOX_PLAYLIST; 
    871988                return 1; 
    872             case 0x1b:      /* Esc. */ 
     989            case 0x1b:  /* ESC */ 
     990                if( wgetch( p_sys->w ) != ERR ) 
     991                    return 0; 
    873992                p_sys->i_box_type = BOX_PLAYLIST; 
    874993                return 1; 
    875994            case KEY_BACKSPACE: 
     995            case 0x7f: 
    876996                RemoveLastUTF8Entity( p_sys->psz_open_chain, i_chain_len ); 
    877997                break; 
    878998            default: 
    879999            { 
     1000#ifdef HAVE_NCURSESW 
     1001                if( i_chain_len + 1 < OPEN_CHAIN_SIZE ) 
     1002                { 
     1003                    p_sys->psz_open_chain[i_chain_len] = (char) i_key; 
     1004                    p_sys->psz_open_chain[i_chain_len + 1] = '\0'; 
     1005                } 
     1006#else 
    8801007                char *psz_utf8 = KeyToUTF8( i_key, p_sys->psz_partial_keys ); 
    8811008 
     
    8891016                    free( psz_utf8 ); 
    8901017                } 
     1018#endif 
    8911019                break; 
    8921020            } 
     
    8991027    switch( i_key ) 
    9001028    { 
     1029        case 0x1b:  /* ESC */ 
     1030            if( wgetch( p_sys->w ) != ERR ) 
     1031                return 0; 
    9011032        case 'q': 
    9021033        case 'Q': 
    903         case 0x1b:  /* Esc */ 
     1034        case KEY_EXIT: 
    9041035            vlc_object_kill( p_intf->p_libvlc ); 
    9051036            return 0; 
     
    9381069                p_sys->i_box_type = BOX_BROWSE; 
    9391070            return 1; 
     1071        case 'c': 
     1072            p_sys->b_color = !p_sys->b_color; 
     1073            if( p_sys->b_color && !p_sys->b_color_started ) 
     1074                start_color_and_pairs( p_intf ); 
     1075            return 1; 
    9401076        case 'h': 
    9411077        case 'H': 
     
    10761212         * ^l should clear and redraw the screen 
    10771213         */ 
    1078         case 0x0c: 
     1214        case KEY_CLEAR: 
     1215        case 0x0c:          /* ^l */ 
    10791216            clear(); 
    10801217            return 1; 
     
    11931330    if( i_char_len == (size_t)-1 ) 
    11941331        /* an invalid character was encountered */ 
    1195         abort()
     1332        return
    11961333    else 
    11971334    { 
     
    13291466    /* Title */ 
    13301467    attrset( A_REVERSE ); 
    1331     int i_len = strlen( "VLC media player [ h for help ]" ); 
     1468    int i_len = strlen( "VLC media player "PACKAGE_VERSION ); 
    13321469    int mid = ( COLS - i_len ) / 2; 
    13331470    if( mid < 0 ) 
     
    13361473    char psz_title[i_size]; 
    13371474    memset( psz_title, ' ', mid ); 
    1338     snprintf( &psz_title[mid], i_size, "VLC media player [ h for help ]" ); 
     1475    if( p_sys->b_color ) 
     1476        wcolor_set( p_sys->w, C_TITLE, NULL ); 
     1477    snprintf( &psz_title[mid], i_size, "VLC media player "PACKAGE_VERSION ); 
    13391478    mvnprintw( y, 0, COLS, "%s", psz_title ); 
    13401479    attroff( A_REVERSE ); 
    13411480    y += 2; 
    13421481 
     1482    if( p_sys->b_color ) 
     1483        wcolor_set( p_sys->w, C_STATUS, NULL ); 
     1484 
    13431485    /* Infos */ 
    1344  
    1345     char psz_state[25]; 
    1346     /* strlen( "[Repeat] [Random] [Loop]" ) == 24, + '\0' */ 
    1347     psz_state[0] = '\0'; 
    1348     if( var_GetBool( p_playlist, "repeat" ) ) 
    1349         strcat( psz_state, "[Repeat] " ); 
    1350     if( var_GetBool( p_playlist, "random" ) ) 
    1351         strcat( psz_state, "[Random] " ); 
    1352     if( var_GetBool( p_playlist, "loop" ) ) 
    1353         strcat( psz_state, "[Loop]" ); 
     1486    char *psz_state; 
     1487    if( asprintf( &psz_state, "%s%s%s", 
     1488            var_GetBool( p_playlist, "repeat" ) ? _( "[Repeat] " ) : "", 
     1489            var_GetBool( p_playlist, "random" ) ? _( "[Random] " ) : "", 
     1490            var_GetBool( p_playlist, "loop" ) ? _( "[Loop]" ) : "" ) == -1 ) 
     1491        psz_state = NULL; 
    13541492 
    13551493    if( p_input && !p_input->b_dead ) 
     
    13621500        /* Source */ 
    13631501        char *psz_uri = input_item_GetURI( input_GetItem( p_input ) ); 
    1364         mvnprintw( y++, 0, COLS, " Source   : %s", psz_uri ); 
     1502        mvnprintw( y++, 0, COLS, _(" Source   : %s"), psz_uri ); 
    13651503        free( psz_uri ); 
    13661504 
     
    13691507        if( val.i_int == PLAYING_S ) 
    13701508        { 
    1371             mvnprintw( y++, 0, COLS, " State    : Playing %s", psz_state ); 
     1509            mvnprintw( y++, 0, COLS, _(" State    : Playing %s"), psz_state ); 
    13721510        } 
    13731511        else if( val.i_int == OPENING_S ) 
    13741512        { 
    1375             mvnprintw( y++, 0, COLS, " State    : Opening/Connecting %s", psz_state ); 
     1513            mvnprintw( y++, 0, COLS, _(" State    : Opening/Connecting %s"), psz_state ); 
    13761514        } 
    13771515        else if( val.i_int == BUFFERING_S ) 
    13781516        { 
    1379             mvnprintw( y++, 0, COLS, " State    : Buffering %s", psz_state ); 
     1517            mvnprintw( y++, 0, COLS, _(" State    : Buffering %s"), psz_state ); 
    13801518        } 
    13811519        else if( val.i_int == PAUSE_S ) 
    13821520        { 
    1383             mvnprintw( y++, 0, COLS, " State    : Paused %s", psz_state ); 
     1521            mvnprintw( y++, 0, COLS, _(" State    : Paused %s"), psz_state ); 
    13841522        } 
    13851523 
     
    13951533            msecstotimestr( buf2, val.i_time / 1000 ); 
    13961534 
    1397             mvnprintw( y++, 0, COLS, " Position : %s/%s (%.2f%%)", buf1, buf2, p_sys->f_slider ); 
     1535            mvnprintw( y++, 0, COLS, _(" Position : %s/%s (%.2f%%)"), buf1, buf2, p_sys->f_slider ); 
    13981536 
    13991537            /* Volume */ 
    14001538            aout_VolumeGet( p_intf, &i_volume ); 
    1401             mvnprintw( y++, 0, COLS, " Volume   : %i%%", i_volume*200/AOUT_VOLUME_MAX ); 
     1539            mvnprintw( y++, 0, COLS, _(" Volume   : %i%%"), i_volume*200/AOUT_VOLUME_MAX ); 
    14021540 
    14031541            /* Title */ 
     
    14071545                if( val_list.p_list->i_count > 0 ) 
    14081546                { 
    1409                     mvnprintw( y++, 0, COLS, " Title    : %d/%d", val.i_int, val_list.p_list->i_count ); 
     1547                    mvnprintw( y++, 0, COLS, _(" Title    : %d/%d"), val.i_int, val_list.p_list->i_count ); 
    14101548                } 
    14111549                var_Change( p_input, "title", VLC_VAR_FREELIST, &val_list, NULL ); 
     
    14181556                if( val_list.p_list->i_count > 0 ) 
    14191557                { 
    1420                     mvnprintw( y++, 0, COLS, " Chapter  : %d/%d", val.i_int, val_list.p_list->i_count ); 
     1558                    mvnprintw( y++, 0, COLS, _(" Chapter  : %d/%d"), val.i_int, val_list.p_list->i_count ); 
    14211559                } 
    14221560                var_Change( p_input, "chapter", VLC_VAR_FREELIST, &val_list, NULL ); 
     
    14301568    else 
    14311569    { 
    1432         mvnprintw( y++, 0, COLS, "Source: <no current item> %s", psz_state ); 
     1570        mvnprintw( y++, 0, COLS, _(" Source: <no current item> %s"), psz_state ); 
    14331571        DrawEmptyLine( p_sys->w, y++, 0, COLS ); 
     1572        mvnprintw( y++, 0, COLS, _(" [ h for help ]") ); 
    14341573        DrawEmptyLine( p_sys->w, y++, 0, COLS ); 
    1435         DrawEmptyLine( p_sys->w, y++, 0, COLS ); 
    1436     } 
    1437  
    1438     DrawBox( p_sys->w, y, 0, 3, COLS, "" ); 
     1574    } 
     1575    free( psz_state ); 
     1576    if( p_sys->b_color ) 
     1577        wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1578 
     1579    DrawBox( p_sys->w, y, 0, 3, COLS, "", p_sys->b_color ); 
    14391580    DrawEmptyLine( p_sys->w, y+1, 1, COLS-2); 
    14401581    DrawLine( p_sys->w, y+1, 1, (int)(p_intf->p_sys->f_slider/100.0 * (COLS -2)) ); 
     
    14511592        /* Help box */ 
    14521593        int l = 0; 
    1453         DrawBox( p_sys->w, y++, 0, h, COLS, " Help " ); 
    1454  
    1455         MainBoxWrite( p_intf, l++, 1, "[Display]" ); 
    1456         MainBoxWrite( p_intf, l++, 1, "     h,H         Show/Hide help box" ); 
    1457         MainBoxWrite( p_intf, l++, 1, "     i           Show/Hide info box" ); 
    1458         MainBoxWrite( p_intf, l++, 1, "     m           Show/Hide metadata box" ); 
    1459         MainBoxWrite( p_intf, l++, 1, "     L           Show/Hide messages box" ); 
    1460         MainBoxWrite( p_intf, l++, 1, "     P           Show/Hide playlist box" ); 
    1461         MainBoxWrite( p_intf, l++, 1, "     B           Show/Hide filebrowser" ); 
     1594        DrawBox( p_sys->w, y++, 0, h, COLS, _(" Help "), p_sys->b_color ); 
     1595 
     1596        if( p_sys->b_color ) 
     1597            wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1598        MainBoxWrite( p_intf, l++, 1, _("[Display]") ); 
     1599        if( p_sys->b_color ) 
     1600            wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1601        MainBoxWrite( p_intf, l++, 1, _("     h,H         Show/Hide help box") ); 
     1602        MainBoxWrite( p_intf, l++, 1, _("     i           Show/Hide info box") ); 
     1603        MainBoxWrite( p_intf, l++, 1, _("     m           Show/Hide metadata box") ); 
     1604        MainBoxWrite( p_intf, l++, 1, _("     L           Show/Hide messages box") ); 
     1605        MainBoxWrite( p_intf, l++, 1, _("     P           Show/Hide playlist box") ); 
     1606        MainBoxWrite( p_intf, l++, 1, _("     B           Show/Hide filebrowser") ); 
     1607        MainBoxWrite( p_intf, l++, 1, _("     c           Switch color on/off") ); 
     1608        MainBoxWrite( p_intf, l++, 1, _("     Esc         Close Add/Search entry") ); 
    14621609        MainBoxWrite( p_intf, l++, 1, "" ); 
    14631610 
    1464         MainBoxWrite( p_intf, l++, 1, "[Global]" ); 
    1465         MainBoxWrite( p_intf, l++, 1, "     q, Q        Quit" ); 
    1466         MainBoxWrite( p_intf, l++, 1, "     s           Stop" ); 
    1467         MainBoxWrite( p_intf, l++, 1, "     <space>     Pause/Play" ); 
    1468         MainBoxWrite( p_intf, l++, 1, "     f           Toggle Fullscreen" ); 
    1469         MainBoxWrite( p_intf, l++, 1, "     n, p        Next/Previous playlist item" ); 
    1470         MainBoxWrite( p_intf, l++, 1, "     [, ]        Next/Previous title" ); 
    1471         MainBoxWrite( p_intf, l++, 1, "     <, >        Next/Previous chapter" ); 
    1472         MainBoxWrite( p_intf, l++, 1, "     <right>     Seek +1%%" ); 
    1473         MainBoxWrite( p_intf, l++, 1, "     <left>      Seek -1%%" ); 
    1474         MainBoxWrite( p_intf, l++, 1, "     a           Volume Up" ); 
    1475         MainBoxWrite( p_intf, l++, 1, "     z           Volume Down" ); 
     1611        if( p_sys->b_color ) 
     1612            wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1613        MainBoxWrite( p_intf, l++, 1, _("[Global]") ); 
     1614        if( p_sys->b_color ) 
     1615            wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1616        MainBoxWrite( p_intf, l++, 1, _("     q, Q, Esc   Quit") ); 
     1617        MainBoxWrite( p_intf, l++, 1, _("     s           Stop") ); 
     1618        MainBoxWrite( p_intf, l++, 1, _("     <space>     Pause/Play") ); 
     1619        MainBoxWrite( p_intf, l++, 1, _("     f           Toggle Fullscreen") ); 
     1620        MainBoxWrite( p_intf, l++, 1, _("     n, p        Next/Previous playlist item") ); 
     1621        MainBoxWrite( p_intf, l++, 1, _("     [, ]        Next/Previous title") ); 
     1622        MainBoxWrite( p_intf, l++, 1, _("     <, >        Next/Previous chapter") ); 
     1623        MainBoxWrite( p_intf, l++, 1, _("     <right>     Seek +1%%") ); 
     1624        MainBoxWrite( p_intf, l++, 1, _("     <left>      Seek -1%%") ); 
     1625        MainBoxWrite( p_intf, l++, 1, _("     a           Volume Up") ); 
     1626        MainBoxWrite( p_intf, l++, 1, _("     z           Volume Down") ); 
    14761627        MainBoxWrite( p_intf, l++, 1, "" ); 
    14771628 
    1478         MainBoxWrite( p_intf, l++, 1, "[Playlist]" ); 
    1479         MainBoxWrite( p_intf, l++, 1, "     r           Toggle Random playing" ); 
    1480         MainBoxWrite( p_intf, l++, 1, "     l           Toggle Loop Playlist" ); 
    1481         MainBoxWrite( p_intf, l++, 1, "     R           Toggle Repeat item" ); 
    1482         MainBoxWrite( p_intf, l++, 1, "     o           Order Playlist by title" ); 
    1483         MainBoxWrite( p_intf, l++, 1, "     O           Reverse order Playlist by title" ); 
    1484         MainBoxWrite( p_intf, l++, 1, "     g           Go to the current playing item" ); 
    1485         MainBoxWrite( p_intf, l++, 1, "     /           Look for an item" ); 
    1486         MainBoxWrite( p_intf, l++, 1, "     A           Add an entry" ); 
    1487         MainBoxWrite( p_intf, l++, 1, "     D, <del>    Delete an entry" ); 
    1488         MainBoxWrite( p_intf, l++, 1, "     <backspace> Delete an entry" ); 
     1629        if( p_sys->b_color ) 
     1630            wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1631        MainBoxWrite( p_intf, l++, 1, _("[Playlist]") ); 
     1632        if( p_sys->b_color ) 
     1633            wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1634        MainBoxWrite( p_intf, l++, 1, _("     r           Toggle Random playing") ); 
     1635        MainBoxWrite( p_intf, l++, 1, _("     l           Toggle Loop Playlist") ); 
     1636        MainBoxWrite( p_intf, l++, 1, _("     R           Toggle Repeat item") ); 
     1637        MainBoxWrite( p_intf, l++, 1, _("     o           Order Playlist by title") ); 
     1638        MainBoxWrite( p_intf, l++, 1, _("     O           Reverse order Playlist by title") ); 
     1639        MainBoxWrite( p_intf, l++, 1, _("     g           Go to the current playing item") ); 
     1640        MainBoxWrite( p_intf, l++, 1, _("     /           Look for an item") ); 
     1641        MainBoxWrite( p_intf, l++, 1, _("     A           Add an entry") ); 
     1642        MainBoxWrite( p_intf, l++, 1, _("     D, <del>    Delete an entry") ); 
     1643        MainBoxWrite( p_intf, l++, 1, _("     <backspace> Delete an entry") ); 
     1644        MainBoxWrite( p_intf, l++, 1, _("     e           Eject (if stopped)") ); 
    14891645        MainBoxWrite( p_intf, l++, 1, "" ); 
    14901646 
    1491         MainBoxWrite( p_intf, l++, 1, "[Filebrowser]" ); 
    1492         MainBoxWrite( p_intf, l++, 1, "     <enter>     Add the selected file to the playlist" ); 
    1493         MainBoxWrite( p_intf, l++, 1, "     <space>     Add the selected directory to the playlist" ); 
    1494         MainBoxWrite( p_intf, l++, 1, "     .           Show/Hide hidden files" ); 
     1647        if( p_sys->b_color ) 
     1648            wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1649        MainBoxWrite( p_intf, l++, 1, _("[Filebrowser]") ); 
     1650        if( p_sys->b_color ) 
     1651            wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1652        MainBoxWrite( p_intf, l++, 1, _("     <enter>     Add the selected file to the playlist") ); 
     1653        MainBoxWrite( p_intf, l++, 1, _("     <space>     Add the selected directory to the playlist") ); 
     1654        MainBoxWrite( p_intf, l++, 1, _("     .           Show/Hide hidden files") ); 
    14951655        MainBoxWrite( p_intf, l++, 1, "" ); 
    14961656 
    1497         MainBoxWrite( p_intf, l++, 1, "[Boxes]" ); 
    1498         MainBoxWrite( p_intf, l++, 1, "     <up>,<down>     Navigate through the box line by line" ); 
    1499         MainBoxWrite( p_intf, l++, 1, "     <pgup>,<pgdown> Navigate through the box page by page" ); 
     1657        if( p_sys->b_color ) 
     1658            wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1659        MainBoxWrite( p_intf, l++, 1, _("[Boxes]") ); 
     1660        if( p_sys->b_color ) 
     1661            wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1662        MainBoxWrite( p_intf, l++, 1, _("     <up>,<down>     Navigate through the box line by line") ); 
     1663        MainBoxWrite( p_intf, l++, 1, _("     <pgup>,<pgdown> Navigate through the box page by page") ); 
    15001664        MainBoxWrite( p_intf, l++, 1, "" ); 
    15011665 
    1502         MainBoxWrite( p_intf, l++, 1, "[Player]" ); 
    1503         MainBoxWrite( p_intf, l++, 1, "     <up>,<down>     Seek +/-5%%" ); 
     1666        if( p_sys->b_color ) 
     1667            wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1668        MainBoxWrite( p_intf, l++, 1, _("[Player]") ); 
     1669        if( p_sys->b_color ) 
     1670            wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1671        MainBoxWrite( p_intf, l++, 1, _("     <up>,<down>     Seek +/-5%%") ); 
    15041672        MainBoxWrite( p_intf, l++, 1, "" ); 
    15051673 
    1506         MainBoxWrite( p_intf, l++, 1, "[Miscellaneous]" ); 
    1507         MainBoxWrite( p_intf, l++, 1, "     Ctrl-l          Refresh the screen" ); 
     1674        if( p_sys->b_color ) 
     1675            wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1676        MainBoxWrite( p_intf, l++, 1, _("[Miscellaneous]") ); 
     1677        if( p_sys->b_color ) 
     1678            wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1679        MainBoxWrite( p_intf, l++, 1, _("     Ctrl-l          Refresh the screen") ); 
    15081680 
    15091681        p_sys->i_box_lines_total = l; 
     
    15261698        /* Info box */ 
    15271699        int l = 0; 
    1528         DrawBox( p_sys->w, y++, 0, h, COLS, " Information " ); 
     1700        DrawBox( p_sys->w, y++, 0, h, COLS, _(" Information "), p_sys->b_color ); 
    15291701 
    15301702        if( p_input ) 
     
    15361708                info_category_t *p_category = input_GetItem(p_input)->pp_categories[i]; 
    15371709                if( y >= y_end ) break; 
    1538                 MainBoxWrite( p_intf, l++, 1, "  [%s]", p_category->psz_name ); 
     1710                if( p_sys->b_color ) 
     1711                    wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     1712                MainBoxWrite( p_intf, l++, 1, _("  [%s]"), p_category->psz_name ); 
     1713                if( p_sys->b_color ) 
     1714                    wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    15391715                for( j = 0; j < p_category->i_infos; j++ ) 
    15401716                { 
    15411717                    info_t *p_info = p_category->pp_infos[j]; 
    15421718                    if( y >= y_end ) break; 
    1543                     MainBoxWrite( p_intf, l++, 1, "      %s: %s", p_info->psz_name, p_info->psz_value ); 
     1719                    MainBoxWrite( p_intf, l++, 1, _("      %s: %s"), p_info->psz_name, p_info->psz_value ); 
    15441720                } 
    15451721            } 
     
    15481724        else 
    15491725        { 
    1550             MainBoxWrite( p_intf, l++, 1, "No item currently playing" ); 
     1726            MainBoxWrite( p_intf, l++, 1, _("No item currently playing") ); 
    15511727        } 
    15521728        p_sys->i_box_lines_total = l; 
     
    15771753        psz_title[i_len + 1] = ' '; 
    15781754        psz_title[i_len + 2] = '\0'; 
    1579         DrawBox( p_sys->w, y++, 0, h, COLS, psz_title ); 
     1755        DrawBox( p_sys->w, y++, 0, h, COLS, psz_title, p_sys->b_color ); 
    15801756 
    15811757        if( p_input ) 
     
    16301806                            psz_meta_title = ""; break; 
    16311807                    } 
     1808                    if( p_sys->b_color ) 
     1809                        wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
    16321810                    MainBoxWrite( p_intf, l++, 1, "  [%s]", psz_meta_title ); 
     1811                    if( p_sys->b_color ) 
     1812                        wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    16331813                    MainBoxWrite( p_intf, l++, 1, "      %s", psz_meta ); 
    16341814                } 
     
    16381818        else 
    16391819        { 
    1640             MainBoxWrite( p_intf, l++, 1, "No item currently playing" ); 
     1820            MainBoxWrite( p_intf, l++, 1, _("No item currently playing") ); 
    16411821        } 
    16421822        p_sys->i_box_lines_total = l; 
     
    16611841        int i_start; 
    16621842 
    1663         DrawBox( p_sys->w, y++, 0, h, COLS, " Logs " ); 
     1843        DrawBox( p_sys->w, y++, 0, h, COLS, _(" Logs "), p_sys->b_color ); 
    16641844 
    16651845        i_start = p_intf->p_sys->p_sub->i_start; 
     
    16831863                break; 
    16841864            } 
     1865            if( p_sys->b_color ) 
     1866                wcolor_set( p_sys->w,  
     1867                    p_sys->p_sub->p_msg[i_stop].i_type + C_INFO, 
     1868                    NULL ); 
    16851869            mvnprintw( y + h-2-i_line, 1, COLS - 2, "   [%s] %s", 
    16861870                      ppsz_type[p_sys->p_sub->p_msg[i_stop].i_type], 
    16871871                      p_sys->p_sub->p_msg[i_stop].psz_msg ); 
     1872            if( p_sys->b_color ) 
     1873                wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    16881874        } 
    16891875 
     
    16981884        int        i_start, i_stop; 
    16991885        int        i_item; 
    1700         DrawBox( p_sys->w, y++, 0, h, COLS, " Browse " ); 
     1886        DrawBox( p_sys->w, y++, 0, h, COLS, _(" Browse "), p_sys->b_color ); 
    17011887 
    17021888        if( p_sys->i_box_bidx >= p_sys->i_dir_entries ) p_sys->i_box_plidx = p_sys->i_dir_entries - 1; 
     
    17361922                attrset( A_REVERSE ); 
    17371923            } 
     1924            if( p_sys->b_color && !p_sys->pp_dir_entries[i_item]->b_file ) 
     1925                wcolor_set( p_sys->w, C_FOLDER, NULL ); 
    17381926            mvnprintw( y++, 1, COLS - 2, " %c %s", p_sys->pp_dir_entries[i_item]->b_file == VLC_TRUE ? ' ' : '+', 
    17391927                            p_sys->pp_dir_entries[i_item]->psz_path ); 
     1928            if( p_sys->b_color && !p_sys->pp_dir_entries[i_item]->b_file ) 
     1929                wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     1930 
    17401931            if( b_selected ) 
    17411932            { 
     
    17571948        { 
    17581949            case VIEW_ONELEVEL: 
    1759                 psz_title = strdup( " Playlist (All, one level) " ); 
     1950                psz_title = strdup( _(" Playlist (All, one level) ") ); 
    17601951                break; 
    17611952            case VIEW_CATEGORY: 
    1762                 psz_title = strdup( " Playlist (By category) " ); 
     1953                psz_title = strdup( _(" Playlist (By category) ") ); 
    17631954                break; 
    17641955            default: 
    1765                 psz_title = strdup( " Playlist (Manually added) " ); 
    1766         } 
    1767  
    1768         DrawBox( p_sys->w, y++, 0, h, COLS, psz_title ); 
     1956                psz_title = strdup( _(" Playlist (Manually added) ") ); 
     1957        } 
     1958 
     1959        DrawBox( p_sys->w, y++, 0, h, COLS, psz_title, p_sys->b_color ); 
    17691960 
    17701961        if( p_sys->b_need_update || p_sys->pp_plist == NULL ) 
     
    18242015                attrset( A_REVERSE ); 
    18252016            } 
     2017            if( p_sys->b_color ) 
     2018                wcolor_set( p_sys->w, i_item % 3 + C_PLAYLIST_1, NULL ); 
    18262019            mvnprintw( y++, 1, COLS - 2, "%c%s", c, 
    18272020                       p_sys->pp_plist[i_item]->psz_display ); 
     2021            if( p_sys->b_color ) 
     2022                wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    18282023            if( b_selected ) 
    18292024            { 
     
    18462041            { 
    18472042                /* Searching next entry */ 
    1848                 mvnprintw( 7, 1, COLS-2, "Find: %s", p_sys->psz_old_search ); 
     2043                mvnprintw( 7, 1, COLS-2, _("Find: %s"), p_sys->psz_old_search ); 
    18492044            } 
    18502045            else 
    18512046            { 
    1852                 mvnprintw( 7, 1, COLS-2, "Find: %s", p_sys->psz_search_chain ); 
     2047                mvnprintw( 7, 1, COLS-2, _("Find: %s"), p_sys->psz_search_chain ); 
    18532048            } 
    18542049        } 
     
    18592054        { 
    18602055            DrawEmptyLine( p_sys->w, 7, 1, COLS-2 ); 
    1861             mvnprintw( 7, 1, COLS-2, "Open: %s", p_sys->psz_open_chain ); 
     2056            mvnprintw( 7, 1, COLS-2, _("Open: %s"), p_sys->psz_open_chain ); 
    18622057        } 
    18632058    } 
     
    22612456 * 
    22622457 ****************************************************************************/ 
    2263 static void DrawBox( WINDOW *win, int y, int x, int h, int w, const char *title
     2458static void DrawBox( WINDOW *win, int y, int x, int h, int w, const char *title, vlc_bool_t b_color
    22642459{ 
    22652460    int i; 
     
    22682463    if( w > 3 && h > 2 ) 
    22692464    { 
     2465        if( b_color ) 
     2466            wcolor_set( win, C_BOX, NULL ); 
    22702467        if( title == NULL ) title = ""; 
    22712468        i_len = strlen( title ); 
     
    22882485        mvwhline( win, y+h-1, x+1,   ACS_HLINE, w - 2 ); 
    22892486        mvwaddch( win, y+h-1, x+w-1, ACS_LRCORNER ); 
     2487        if( b_color ) 
     2488            wcolor_set( win, C_DEFAULT, NULL ); 
    22902489    } 
    22912490}