Ticket #3085: mc-4.8.10-menu-width-ticket-3085.patch

File mc-4.8.10-menu-width-ticket-3085.patch, 4.7 KB (added by egmont, 11 years ago)

fix

  • lib/widget/menu.c

    diff -urp mc-4.8.10.orig/lib/widget/menu.c mc-4.8.10/lib/widget/menu.c
    old new struct menu_t 
    6868    hotkey_t text; 
    6969    GList *entries; 
    7070    size_t max_entry_len;       /* cached max length of entry texts (text + shortcut) */ 
    71     size_t max_hotkey_len;      /* cached max length of shortcuts */ 
     71    size_t max_text_len;        /* cached max length of entry texts (without shortcut) */ 
    7272    unsigned int selected;      /* pointer to current menu entry */ 
    7373    char *help_node; 
    7474}; 
    menu_arrange (menu_t * menu, dlg_shortcu 
    8686        GList *i; 
    8787        size_t max_shortcut_len = 0; 
    8888 
    89         menu->max_entry_len = 1; 
    90         menu->max_hotkey_len = 1; 
     89        menu->max_text_len = 1; 
    9190 
    9291        for (i = menu->entries; i != NULL; i = g_list_next (i)) 
    9392        { 
    menu_arrange (menu_t * menu, dlg_shortcu 
    9897                size_t len; 
    9998 
    10099                len = (size_t) hotkey_width (entry->text); 
    101                 menu->max_hotkey_len = max (menu->max_hotkey_len, len); 
     100                menu->max_text_len = max (menu->max_text_len, len); 
    102101 
    103102                if (get_shortcut != NULL) 
    104103                    entry->shortcut = get_shortcut (entry->command); 
    menu_arrange (menu_t * menu, dlg_shortcu 
    111110            } 
    112111        } 
    113112 
    114         menu->max_entry_len = menu->max_hotkey_len + max_shortcut_len; 
     113        menu->max_entry_len = menu->max_text_len + (max_shortcut_len > 0 ? 2 + max_shortcut_len : 0); 
    115114    } 
    116115} 
    117116 
    menubar_paint_idx (WMenuBar * menubar, u 
    126125    const int y = 2 + idx; 
    127126    int x = menu->start_x; 
    128127 
    129     if (x + menu->max_entry_len + 4 > (gsize) w->cols) 
    130         x = w->cols - menu->max_entry_len - 4; 
     128    if (x + menu->max_entry_len + 3 > (gsize) w->cols) 
     129        x = w->cols - menu->max_entry_len - 3; 
    131130 
    132131    if (entry == NULL) 
    133132    { 
    menubar_paint_idx (WMenuBar * menubar, u 
    136135 
    137136        widget_move (w, y, x - 1); 
    138137        tty_print_alt_char (ACS_LTEE, FALSE); 
    139         tty_draw_hline (w->y + y, w->x + x, ACS_HLINE, menu->max_entry_len + 3); 
    140         widget_move (w, y, x + menu->max_entry_len + 3); 
     138        tty_draw_hline (w->y + y, w->x + x, ACS_HLINE, menu->max_entry_len + 2); 
     139        widget_move (w, y, x + menu->max_entry_len + 2); 
    141140        tty_print_alt_char (ACS_RTEE, FALSE); 
    142141    } 
    143142    else 
    menubar_paint_idx (WMenuBar * menubar, u 
    149148        widget_move (w, y, x); 
    150149        tty_print_char ((unsigned char) entry->first_letter); 
    151150        tty_getyx (&yt, &xt); 
    152         tty_draw_hline (yt, xt, ' ', menu->max_entry_len + 2);  /* clear line */ 
     151        tty_draw_hline (yt, xt, ' ', menu->max_entry_len + 1);  /* clear line */ 
    153152        tty_print_string (entry->text.start); 
    154153 
    155154        if (entry->text.hotkey != NULL) 
    menubar_paint_idx (WMenuBar * menubar, u 
    164163 
    165164        if (entry->shortcut != NULL) 
    166165        { 
    167             widget_move (w, y, x + menu->max_hotkey_len + 3); 
     166            widget_move (w, y, x + menu->max_text_len + 3); 
    168167            tty_print_string (entry->shortcut); 
    169168        } 
    170169 
    menubar_draw_drop (WMenuBar * menubar) 
    184183    int column = menu->start_x - 1; 
    185184    unsigned int i; 
    186185 
    187     if (column + menu->max_entry_len + 5 > (gsize) w->cols) 
    188         column = w->cols - menu->max_entry_len - 5; 
     186    if (column + menu->max_entry_len + 4 > (gsize) w->cols) 
     187        column = w->cols - menu->max_entry_len - 4; 
    189188 
    190189    tty_setcolor (MENU_ENTRY_COLOR); 
    191     tty_draw_box (w->y + 1, w->x + column, count + 2, menu->max_entry_len + 5, FALSE); 
     190    tty_draw_box (w->y + 1, w->x + column, count + 2, menu->max_entry_len + 4, FALSE); 
    192191 
    193192    for (i = 0; i < count; i++) 
    194193        menubar_paint_idx (menubar, i, 
    menubar_event (Gpm_Event * event, void * 
    712711 
    713712    /* the mouse operation is on the menus or it is not */ 
    714713    menu = MENU (g_list_nth_data (menubar->menu, menubar->selected)); 
    715     left_x = menu->start_x; 
    716     right_x = left_x + menu->max_entry_len + 3; 
    717     if (right_x > w->cols) 
     714    left_x = menu->start_x + 1; 
     715    right_x = left_x + menu->max_entry_len + 1; 
     716    if (right_x > w->cols - 1) 
    718717    { 
    719         left_x = w->cols - menu->max_entry_len - 3; 
    720         right_x = w->cols; 
     718        left_x = w->cols - menu->max_entry_len - 2; 
     719        right_x = w->cols - 1; 
    721720    } 
    722721 
    723722    bottom_y = g_list_length (menu->entries) + 3; 
    create_menu (const char *name, GList * e 
    805804    menu->text = parse_hotkey (name); 
    806805    menu->entries = entries; 
    807806    menu->max_entry_len = 1; 
    808     menu->max_hotkey_len = 0; 
     807    menu->max_text_len = 0; 
    809808    menu->selected = 0; 
    810809    menu->help_node = g_strdup (help_node); 
    811810