src/menu.c: nice menu view: added LTEE and RTEE symbols to menu separators.
Small optimization. Removed some trailing spaces. Some formatting.
Этот коммит содержится в:
родитель
f08aee0ad0
Коммит
931f0d073d
55
src/menu.c
55
src/menu.c
@ -83,18 +83,27 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
|
||||
|
||||
if (x + menubar->max_entry_len + 3 > menubar->widget.cols)
|
||||
x = menubar->widget.cols - menubar->max_entry_len - 3;
|
||||
widget_move (&menubar->widget, y, x);
|
||||
|
||||
attrset (color);
|
||||
hline (' ', menubar->max_entry_len + 2);
|
||||
|
||||
if (entry->text.start == NULL) {
|
||||
/* menu separator */
|
||||
attrset (SELECTED_COLOR);
|
||||
widget_move (&menubar->widget, y, x + 1);
|
||||
hline (slow_terminal ? ' ' : ACS_HLINE, menubar->max_entry_len);
|
||||
} else {
|
||||
addch ((unsigned char)entry->first_letter);
|
||||
|
||||
if (!slow_terminal) {
|
||||
widget_move (&menubar->widget, y, x - 1);
|
||||
tty_print_alt_char (ACS_LTEE);
|
||||
}
|
||||
|
||||
tty_print_hline (menubar->widget.y + y, menubar->widget.x + x,
|
||||
menubar->max_entry_len + 2);
|
||||
|
||||
if (!slow_terminal)
|
||||
tty_print_alt_char (ACS_RTEE);
|
||||
} else {
|
||||
/* menu text */
|
||||
attrset (color);
|
||||
widget_move (&menubar->widget, y, x);
|
||||
addch ((unsigned char) entry->first_letter);
|
||||
hline (' ', menubar->max_entry_len + 1); /* clear line */
|
||||
addstr (str_term_form (entry->text.start));
|
||||
|
||||
if (entry->text.hotkey != NULL) {
|
||||
@ -103,35 +112,36 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
|
||||
addstr (str_term_form (entry->text.hotkey));
|
||||
attrset(color);
|
||||
}
|
||||
if (entry->text.end != NULL) {
|
||||
|
||||
if (entry->text.end != NULL)
|
||||
addstr (str_term_form (entry->text.end));
|
||||
}
|
||||
}
|
||||
|
||||
/* move cursor to the start of entry text */
|
||||
widget_move (&menubar->widget, y, x + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void menubar_draw_drop (WMenu *menubar)
|
||||
{
|
||||
const int count = (menubar->menu [menubar->selected])->count;
|
||||
const int count = menubar->menu [menubar->selected]->count;
|
||||
int column = menubar->menu [menubar->selected]->start_x - 1;
|
||||
int i;
|
||||
int sel = menubar->subsel;
|
||||
int column = menubar-> menu[menubar->selected]->start_x - 1;
|
||||
|
||||
if (column + menubar->max_entry_len + 4 > menubar->widget.cols)
|
||||
column = menubar->widget.cols - menubar->max_entry_len - 4;
|
||||
|
||||
attrset (SELECTED_COLOR);
|
||||
draw_box (menubar->widget.parent,
|
||||
menubar->widget.y+1, menubar->widget.x + column,
|
||||
count+2, menubar->max_entry_len + 4);
|
||||
menubar->widget.y + 1, menubar->widget.x + column,
|
||||
count + 2, menubar->max_entry_len + 4);
|
||||
|
||||
column++;
|
||||
for (i = 0; i < count; i++){
|
||||
if (i == sel)
|
||||
continue;
|
||||
/* draw items except selected */
|
||||
for (i = 0; i < count; i++)
|
||||
if (i != menubar->subsel)
|
||||
menubar_paint_idx (menubar, i, MENU_ENTRY_COLOR);
|
||||
}
|
||||
menubar_paint_idx (menubar, sel, MENU_SELECTED_COLOR);
|
||||
|
||||
/* draw selected item at last to move cursot to the nice location */
|
||||
menubar_paint_idx (menubar, menubar->subsel, MENU_SELECTED_COLOR);
|
||||
}
|
||||
|
||||
static void menubar_draw (WMenu *menubar)
|
||||
@ -171,7 +181,6 @@ static void menubar_draw (WMenu *menubar)
|
||||
else
|
||||
widget_move (&menubar->widget, 0,
|
||||
menubar-> menu[menubar->selected]->start_x);
|
||||
|
||||
}
|
||||
|
||||
static inline void menubar_remove (WMenu *menubar)
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user