Show
Ignore:
Timestamp:
10/09/07 20:56:52 (1 year ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1189450612 +0000
git-parent:

[3305b049e7f587b23359a1c9047fb5763d19c1dc]

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

Removes trailing spaces. Removes tabs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lxdialog/util.c

    rc31926a r6ee1e19  
    3030const char *dialog_result; 
    3131 
    32 /*  
     32/* 
    3333 * Attribute values, default is for mono display 
    3434 */ 
    3535chtype attributes[] = 
    3636{ 
    37     A_NORMAL,          /* screen_attr */ 
    38     A_NORMAL,          /* shadow_attr */ 
    39     A_NORMAL,          /* dialog_attr */ 
    40     A_BOLD,            /* title_attr */ 
    41     A_NORMAL,          /* border_attr */ 
    42     A_REVERSE,         /* button_active_attr */ 
    43     A_DIM,         /* button_inactive_attr */ 
    44     A_REVERSE,         /* button_key_active_attr */ 
    45     A_BOLD,            /* button_key_inactive_attr */ 
    46     A_REVERSE,         /* button_label_active_attr */ 
    47     A_NORMAL,          /* button_label_inactive_attr */ 
    48     A_NORMAL,          /* inputbox_attr */ 
    49     A_NORMAL,          /* inputbox_border_attr */ 
    50     A_NORMAL,          /* searchbox_attr */ 
    51     A_BOLD,            /* searchbox_title_attr */ 
    52     A_NORMAL,          /* searchbox_border_attr */ 
    53     A_BOLD,            /* position_indicator_attr */ 
    54     A_NORMAL,          /* menubox_attr */ 
    55     A_NORMAL,          /* menubox_border_attr */ 
    56     A_NORMAL,          /* item_attr */ 
    57     A_REVERSE,         /* item_selected_attr */ 
    58     A_BOLD,            /* tag_attr */ 
    59     A_REVERSE,         /* tag_selected_attr */ 
    60     A_BOLD,            /* tag_key_attr */ 
    61     A_REVERSE,         /* tag_key_selected_attr */ 
    62     A_BOLD,            /* check_attr */ 
    63     A_REVERSE,         /* check_selected_attr */ 
    64     A_BOLD,            /* uarrow_attr */ 
    65     A_BOLD         /* darrow_attr */ 
     37    A_NORMAL,            /* screen_attr */ 
     38    A_NORMAL,            /* shadow_attr */ 
     39    A_NORMAL,            /* dialog_attr */ 
     40    A_BOLD,            /* title_attr */ 
     41    A_NORMAL,            /* border_attr */ 
     42    A_REVERSE,            /* button_active_attr */ 
     43    A_DIM,            /* button_inactive_attr */ 
     44    A_REVERSE,            /* button_key_active_attr */ 
     45    A_BOLD,            /* button_key_inactive_attr */ 
     46    A_REVERSE,            /* button_label_active_attr */ 
     47    A_NORMAL,            /* button_label_inactive_attr */ 
     48    A_NORMAL,            /* inputbox_attr */ 
     49    A_NORMAL,            /* inputbox_border_attr */ 
     50    A_NORMAL,            /* searchbox_attr */ 
     51    A_BOLD,            /* searchbox_title_attr */ 
     52    A_NORMAL,            /* searchbox_border_attr */ 
     53    A_BOLD,            /* position_indicator_attr */ 
     54    A_NORMAL,            /* menubox_attr */ 
     55    A_NORMAL,            /* menubox_border_attr */ 
     56    A_NORMAL,            /* item_attr */ 
     57    A_REVERSE,            /* item_selected_attr */ 
     58    A_BOLD,            /* tag_attr */ 
     59    A_REVERSE,            /* tag_selected_attr */ 
     60    A_BOLD,            /* tag_key_attr */ 
     61    A_REVERSE,            /* tag_key_selected_attr */ 
     62    A_BOLD,            /* check_attr */ 
     63    A_REVERSE,            /* check_selected_attr */ 
     64    A_BOLD,            /* uarrow_attr */ 
     65    A_BOLD            /* darrow_attr */ 
    6666}; 
    6767 
     
    104104    {UARROW_FG, UARROW_BG, UARROW_HL}, 
    105105    {DARROW_FG, DARROW_BG, DARROW_HL}, 
    106 };             /* color_table */ 
     106};                /* color_table */ 
    107107 
    108108/* 
     
    116116    wattrset (win, attr); 
    117117    for (i = 0; i < height; i++) { 
    118    wmove (win, i, 0); 
    119    for (j = 0; j < width; j++) 
    120        waddch (win, ' '); 
     118    wmove (win, i, 0); 
     119    for (j = 0; j < width; j++) 
     120        waddch (win, ' '); 
    121121    } 
    122122    touchwin (win); 
     
    145145init_dialog (void) 
    146146{ 
    147     initscr ();            /* Init curses */ 
     147    initscr ();            /* Init curses */ 
    148148    keypad (stdscr, TRUE); 
    149149    cbreak (); 
     
    151151 
    152152 
    153     if (use_colors)    /* Set up colors */ 
    154    color_setup (); 
     153    if (use_colors)    /* Set up colors */ 
     154    color_setup (); 
    155155 
    156156 
     
    166166    int i; 
    167167 
    168     if (has_colors ()) {   /* Terminal supports color? */ 
    169    start_color (); 
    170  
    171    /* Initialize color pairs */ 
    172    for (i = 0; i < ATTRIBUTE_COUNT; i++) 
    173        init_pair (i + 1, color_table[i][0], color_table[i][1]); 
    174  
    175    /* Setup color attributes */ 
    176    for (i = 0; i < ATTRIBUTE_COUNT; i++) 
    177        attributes[i] = C_ATTR (color_table[i][2], i + 1); 
     168    if (has_colors ()) {    /* Terminal supports color? */ 
     169    start_color (); 
     170 
     171    /* Initialize color pairs */ 
     172    for (i = 0; i < ATTRIBUTE_COUNT; i++) 
     173        init_pair (i + 1, color_table[i][0], color_table[i][1]); 
     174 
     175    /* Setup color attributes */ 
     176    for (i = 0; i < ATTRIBUTE_COUNT; i++) 
     177        attributes[i] = C_ATTR (color_table[i][2], i + 1); 
    178178    } 
    179179} 
     
    205205 
    206206    prompt_len = strlen(tempstr); 
    207      
     207     
    208208    /* 
    209209     * Remove newlines 
    210210     */ 
    211211    for(i=0; i<prompt_len; i++) { 
    212    if(tempstr[i] == '\n') tempstr[i] = ' '; 
    213     } 
    214  
    215     if (prompt_len <= width - x * 2) { /* If prompt is short */ 
    216    wmove (win, y, (width - prompt_len) / 2); 
    217    waddstr (win, tempstr); 
     212    if(tempstr[i] == '\n') tempstr[i] = ' '; 
     213    } 
     214 
     215    if (prompt_len <= width - x * 2) {    /* If prompt is short */ 
     216    wmove (win, y, (width - prompt_len) / 2); 
     217    waddstr (win, tempstr); 
    218218    } else { 
    219    cur_x = x; 
    220    cur_y = y; 
    221    newl = 1; 
    222    word = tempstr; 
    223    while (word && *word) { 
    224        sp = index(word, ' '); 
    225        if (sp) 
    226            *sp++ = 0; 
    227  
    228        /* Wrap to next line if either the word does not fit, 
    229           or it is the first word of a new sentence, and it is 
    230           short, and the next word does not fit. */ 
    231        room = width - cur_x; 
    232        wlen = strlen(word); 
    233        if (wlen > room || 
    234           (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room 
    235             && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { 
    236        cur_y++; 
    237        cur_x = x; 
    238        } 
    239        wmove (win, cur_y, cur_x); 
    240        waddstr (win, word); 
    241        getyx (win, cur_y, cur_x); 
    242        cur_x++; 
    243        if (sp && *sp == ' ') { 
    244            cur_x++;    /* double space */ 
    245        while (*++sp == ' '); 
    246        newl = 1; 
    247        } else 
    248            newl = 0; 
    249        word = sp; 
    250    
     219    cur_x = x; 
     220    cur_y = y; 
     221    newl = 1; 
     222    word = tempstr; 
     223    while (word && *word) { 
     224        sp = index(word, ' '); 
     225        if (sp) 
     226            *sp++ = 0; 
     227 
     228        /* Wrap to next line if either the word does not fit, 
     229           or it is the first word of a new sentence, and it is 
     230           short, and the next word does not fit. */ 
     231        room = width - cur_x; 
     232        wlen = strlen(word); 
     233        if (wlen > room || 
     234           (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room 
     235             && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { 
     236        cur_y++; 
     237        cur_x = x; 
     238        } 
     239        wmove (win, cur_y, cur_x); 
     240        waddstr (win, word); 
     241        getyx (win, cur_y, cur_x); 
     242        cur_x++; 
     243        if (sp && *sp == ' ') { 
     244            cur_x++;    /* double space */ 
     245        while (*++sp == ' '); 
     246        newl = 1; 
     247        } else 
     248            newl = 0; 
     249        word = sp; 
     250   
    251251    } 
    252252} 
     
    266266    label += temp; 
    267267    wattrset (win, selected ? button_label_active_attr 
    268          : button_label_inactive_attr); 
     268          : button_label_inactive_attr); 
    269269    for (i = 0; i < temp; i++) 
    270    waddch (win, ' '); 
     270    waddch (win, ' '); 
    271271    wattrset (win, selected ? button_key_active_attr 
    272          : button_key_inactive_attr); 
     272          : button_key_inactive_attr); 
    273273    waddch (win, label[0]); 
    274274    wattrset (win, selected ? button_label_active_attr 
    275          : button_label_inactive_attr); 
     275          : button_label_inactive_attr); 
    276276    waddstr (win, (char *)label + 1); 
    277277    wattrset (win, selected ? button_active_attr : button_inactive_attr); 
     
    285285void 
    286286draw_box (WINDOW * win, int y, int x, int height, int width, 
    287      chtype box, chtype border) 
     287      chtype box, chtype border) 
    288288{ 
    289289    int i, j; 
     
    291291    wattrset (win, 0); 
    292292    for (i = 0; i < height; i++) { 
    293    wmove (win, y + i, x); 
    294    for (j = 0; j < width; j++) 
    295        if (!i && !j) 
    296        waddch (win, border | ACS_ULCORNER); 
    297        else if (i == height - 1 && !j) 
    298        waddch (win, border | ACS_LLCORNER); 
    299        else if (!i && j == width - 1) 
    300        waddch (win, box | ACS_URCORNER); 
    301        else if (i == height - 1 && j == width - 1) 
    302        waddch (win, box | ACS_LRCORNER); 
    303        else if (!i) 
    304        waddch (win, border | ACS_HLINE); 
    305        else if (i == height - 1) 
    306        waddch (win, box | ACS_HLINE); 
    307        else if (!j) 
    308        waddch (win, border | ACS_VLINE); 
    309        else if (j == width - 1) 
    310        waddch (win, box | ACS_VLINE); 
    311        else 
    312        waddch (win, box | ' '); 
     293    wmove (win, y + i, x); 
     294    for (j = 0; j < width; j++) 
     295        if (!i && !j) 
     296        waddch (win, border | ACS_ULCORNER); 
     297        else if (i == height - 1 && !j) 
     298        waddch (win, border | ACS_LLCORNER); 
     299        else if (!i && j == width - 1) 
     300        waddch (win, box | ACS_URCORNER); 
     301        else if (i == height - 1 && j == width - 1) 
     302        waddch (win, box | ACS_LRCORNER); 
     303        else if (!i) 
     304        waddch (win, border | ACS_HLINE); 
     305        else if (i == height - 1) 
     306        waddch (win, box | ACS_HLINE); 
     307        else if (!j) 
     308        waddch (win, border | ACS_VLINE); 
     309        else if (j == width - 1) 
     310        waddch (win, box | ACS_VLINE); 
     311        else 
     312        waddch (win, box | ' '); 
    313313    } 
    314314} 
     
    323323    int i; 
    324324 
    325     if (has_colors ()) {   /* Whether terminal supports color? */ 
    326    wattrset (win, shadow_attr); 
    327    wmove (win, y + height, x + 2); 
    328    for (i = 0; i < width; i++) 
    329        waddch (win, winch (win) & A_CHARTEXT); 
    330    for (i = y + 1; i < y + height + 1; i++) { 
    331        wmove (win, i, x + width); 
    332        waddch (win, winch (win) & A_CHARTEXT); 
    333        waddch (win, winch (win) & A_CHARTEXT); 
    334    
    335    wnoutrefresh (win); 
     325    if (has_colors ()) {    /* Whether terminal supports color? */ 
     326    wattrset (win, shadow_attr); 
     327    wmove (win, y + height, x + 2); 
     328    for (i = 0; i < width; i++) 
     329        waddch (win, winch (win) & A_CHARTEXT); 
     330    for (i = y + 1; i < y + height + 1; i++) { 
     331        wmove (win, i, x + width); 
     332        waddch (win, winch (win) & A_CHARTEXT); 
     333        waddch (win, winch (win) & A_CHARTEXT); 
     334   
     335    wnoutrefresh (win); 
    336336    } 
    337337} 
     
    343343first_alpha(const char *string, const char *exempt) 
    344344{ 
    345    int i, in_paren=0, c; 
    346  
    347    for (i = 0; i < strlen(string); i++) { 
    348        c = tolower(string[i]); 
    349  
    350        if (strchr("<[(", c)) ++in_paren; 
    351        if (strchr(">])", c)) --in_paren; 
    352  
    353         if ((! in_paren) && isalpha(c) &&  
    354             strchr(exempt, c) == 0) 
    355            return i; 
    356    
    357  
    358    return 0; 
    359 } 
     345    int i, in_paren=0, c; 
     346 
     347    for (i = 0; i < strlen(string); i++) { 
     348        c = tolower(string[i]); 
     349 
     350        if (strchr("<[(", c)) ++in_paren; 
     351        if (strchr(">])", c)) --in_paren; 
     352 
     353        if ((! in_paren) && isalpha(c) && 
     354             strchr(exempt, c) == 0) 
     355            return i; 
     356   
     357 
     358    return 0; 
     359}