Skip to content

Commit 9e9f67a

Browse files
authored
Merge pull request #4912 from egmontkob/4911-menu-padding
Ticket #4911: menu padding
2 parents 1032e65 + a74dac1 commit 9e9f67a

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/widget/menu.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ menu_arrange (menu_t *menu, dlg_shortcut_str get_shortcut)
114114
}
115115
}
116116

117-
menu->max_entry_len = menu->max_hotkey_len + max_shortcut_len;
117+
// shortcuts, if present, are separated by 2 spaces
118+
menu->max_entry_len =
119+
menu->max_hotkey_len + (max_shortcut_len > 0 ? max_shortcut_len + 2 : 0);
118120
}
119121
}
120122

@@ -129,8 +131,8 @@ menubar_paint_idx (const WMenuBar *menubar, unsigned int idx, int color)
129131
const int y = 2 + idx;
130132
int x = menu->start_x;
131133

132-
if (x + menu->max_entry_len + 4 > (gsize) w->cols)
133-
x = w->cols - menu->max_entry_len - 4;
134+
if (x + menu->max_entry_len + 3 > (gsize) w->cols)
135+
x = w->cols - menu->max_entry_len - 3;
134136

135137
if (entry == NULL)
136138
{
@@ -139,8 +141,8 @@ menubar_paint_idx (const WMenuBar *menubar, unsigned int idx, int color)
139141

140142
widget_gotoyx (menubar, y, x - 1);
141143
tty_print_char (mc_tty_frm[MC_TTY_FRM_DLEFTMIDDLE]);
142-
tty_draw_hline (w->y + y, w->x + x, mc_tty_frm[MC_TTY_FRM_HORIZ], menu->max_entry_len + 3);
143-
widget_gotoyx (menubar, y, x + menu->max_entry_len + 3);
144+
tty_draw_hline (w->y + y, w->x + x, mc_tty_frm[MC_TTY_FRM_HORIZ], menu->max_entry_len + 2);
145+
widget_gotoyx (menubar, y, x + menu->max_entry_len + 2);
144146
tty_print_char (mc_tty_frm[MC_TTY_FRM_DRIGHTMIDDLE]);
145147
}
146148
else
@@ -152,7 +154,7 @@ menubar_paint_idx (const WMenuBar *menubar, unsigned int idx, int color)
152154
widget_gotoyx (menubar, y, x);
153155
tty_print_char ((unsigned char) entry->first_letter);
154156
tty_getyx (&yt, &xt);
155-
tty_draw_hline (yt, xt, ' ', menu->max_entry_len + 2); // clear line
157+
tty_draw_hline (yt, xt, ' ', menu->max_entry_len + 1); // clear line
156158
tty_print_string (entry->text.start);
157159

158160
if (entry->text.hotkey != NULL)
@@ -187,15 +189,15 @@ menubar_draw_drop (const WMenuBar *menubar)
187189
int column = menu->start_x - 1;
188190
unsigned int i;
189191

190-
if (column + menu->max_entry_len + 5 > (gsize) w->cols)
191-
column = w->cols - menu->max_entry_len - 5;
192+
if (column + menu->max_entry_len + 4 > (gsize) w->cols)
193+
column = w->cols - menu->max_entry_len - 4;
192194

193195
if (mc_global.tty.shadows)
194-
tty_draw_box_shadow (w->y + 1, w->x + column, count + 2, menu->max_entry_len + 5,
196+
tty_draw_box_shadow (w->y + 1, w->x + column, count + 2, menu->max_entry_len + 4,
195197
SHADOW_COLOR);
196198

197199
tty_setcolor (MENU_ENTRY_COLOR);
198-
tty_draw_box (w->y + 1, w->x + column, count + 2, menu->max_entry_len + 5, FALSE);
200+
tty_draw_box (w->y + 1, w->x + column, count + 2, menu->max_entry_len + 4, FALSE);
199201

200202
for (i = 0; i < count; i++)
201203
menubar_paint_idx (menubar, i, i == menu->current ? MENU_SELECTED_COLOR : MENU_ENTRY_COLOR);
@@ -738,11 +740,11 @@ menubar_mouse_on_menu (const WMenuBar *menubar, int y, int x)
738740

739741
menu = MENU (g_list_nth_data (menubar->menu, menubar->current));
740742
left_x = menu->start_x;
741-
right_x = left_x + menu->max_entry_len + 3;
742-
if (right_x > w->cols)
743+
right_x = left_x + menu->max_entry_len + 2;
744+
if (right_x > w->cols - 1)
743745
{
744-
left_x = w->cols - (menu->max_entry_len + 3);
745-
right_x = w->cols;
746+
left_x = w->cols - 1 - (menu->max_entry_len + 2);
747+
right_x = w->cols - 1;
746748
}
747749

748750
bottom_y = g_list_length (menu->entries) + 2; // skip bar and top frame

0 commit comments

Comments
 (0)