diff -urp mc-4.8.10.orig/lib/widget/menu.c mc-4.8.10/lib/widget/menu.c
old
|
new
|
struct menu_t |
68 | 68 | hotkey_t text; |
69 | 69 | GList *entries; |
70 | 70 | 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) */ |
72 | 72 | unsigned int selected; /* pointer to current menu entry */ |
73 | 73 | char *help_node; |
74 | 74 | }; |
… |
… |
menu_arrange (menu_t * menu, dlg_shortcu |
86 | 86 | GList *i; |
87 | 87 | size_t max_shortcut_len = 0; |
88 | 88 | |
89 | | menu->max_entry_len = 1; |
90 | | menu->max_hotkey_len = 1; |
| 89 | menu->max_text_len = 1; |
91 | 90 | |
92 | 91 | for (i = menu->entries; i != NULL; i = g_list_next (i)) |
93 | 92 | { |
… |
… |
menu_arrange (menu_t * menu, dlg_shortcu |
98 | 97 | size_t len; |
99 | 98 | |
100 | 99 | 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); |
102 | 101 | |
103 | 102 | if (get_shortcut != NULL) |
104 | 103 | entry->shortcut = get_shortcut (entry->command); |
… |
… |
menu_arrange (menu_t * menu, dlg_shortcu |
111 | 110 | } |
112 | 111 | } |
113 | 112 | |
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); |
115 | 114 | } |
116 | 115 | } |
117 | 116 | |
… |
… |
menubar_paint_idx (WMenuBar * menubar, u |
126 | 125 | const int y = 2 + idx; |
127 | 126 | int x = menu->start_x; |
128 | 127 | |
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; |
131 | 130 | |
132 | 131 | if (entry == NULL) |
133 | 132 | { |
… |
… |
menubar_paint_idx (WMenuBar * menubar, u |
136 | 135 | |
137 | 136 | widget_move (w, y, x - 1); |
138 | 137 | 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); |
141 | 140 | tty_print_alt_char (ACS_RTEE, FALSE); |
142 | 141 | } |
143 | 142 | else |
… |
… |
menubar_paint_idx (WMenuBar * menubar, u |
149 | 148 | widget_move (w, y, x); |
150 | 149 | tty_print_char ((unsigned char) entry->first_letter); |
151 | 150 | 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 */ |
153 | 152 | tty_print_string (entry->text.start); |
154 | 153 | |
155 | 154 | if (entry->text.hotkey != NULL) |
… |
… |
menubar_paint_idx (WMenuBar * menubar, u |
164 | 163 | |
165 | 164 | if (entry->shortcut != NULL) |
166 | 165 | { |
167 | | widget_move (w, y, x + menu->max_hotkey_len + 3); |
| 166 | widget_move (w, y, x + menu->max_text_len + 3); |
168 | 167 | tty_print_string (entry->shortcut); |
169 | 168 | } |
170 | 169 | |
… |
… |
menubar_draw_drop (WMenuBar * menubar) |
184 | 183 | int column = menu->start_x - 1; |
185 | 184 | unsigned int i; |
186 | 185 | |
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; |
189 | 188 | |
190 | 189 | 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); |
192 | 191 | |
193 | 192 | for (i = 0; i < count; i++) |
194 | 193 | menubar_paint_idx (menubar, i, |
… |
… |
menubar_event (Gpm_Event * event, void * |
712 | 711 | |
713 | 712 | /* the mouse operation is on the menus or it is not */ |
714 | 713 | 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) |
718 | 717 | { |
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; |
721 | 720 | } |
722 | 721 | |
723 | 722 | bottom_y = g_list_length (menu->entries) + 3; |
… |
… |
create_menu (const char *name, GList * e |
805 | 804 | menu->text = parse_hotkey (name); |
806 | 805 | menu->entries = entries; |
807 | 806 | menu->max_entry_len = 1; |
808 | | menu->max_hotkey_len = 0; |
| 807 | menu->max_text_len = 0; |
809 | 808 | menu->selected = 0; |
810 | 809 | menu->help_node = g_strdup (help_node); |
811 | 810 | |