Lines Matching defs:menu

17 struct menu rootmenu;
18 static struct menu **last_entry_ptr;
21 * menu_next - return the next menu entry with depth-first traversal
22 * @menu: pointer to the current menu
24 * continues until it reaches the end of the entire menu tree.
25 * return: the menu to visit next, or NULL when it reaches the end.
27 struct menu *menu_next(struct menu *menu, struct menu *root)
29 if (menu->list)
30 return menu->list;
32 while (menu != root && !menu->next)
33 menu = menu->parent;
35 if (menu == root)
38 return menu->next;
41 void menu_warn(struct menu *menu, const char *fmt, ...)
45 fprintf(stderr, "%s:%d:warning: ", menu->filename, menu->lineno);
69 struct menu *menu;
71 menu = xmalloc(sizeof(*menu));
72 memset(menu, 0, sizeof(*menu));
73 menu->sym = sym;
74 menu->parent = current_menu;
75 menu->filename = cur_filename;
76 menu->lineno = cur_lineno;
78 *last_entry_ptr = menu;
79 last_entry_ptr = &menu->next;
80 current_entry = menu;
83 list_add_tail(&menu->link, &sym->menus);
87 struct menu *menu_add_menu(void)
160 prop->menu = current_entry;
193 struct menu *menu = current_entry;
195 while ((menu = menu->parent) != NULL) {
198 if (!menu->visibility)
201 * Do not add a reference to the menu's visibility
207 dup_expr = expr_copy(menu->visibility);
266 struct menu *choice = sym_get_choice_menu(sym2);
304 static void _menu_finalize(struct menu *parent, bool inside_choice)
306 struct menu *menu, *last_menu;
314 * This menu node has children. We (recursively) process them
327 for (menu = parent->list; menu; menu = menu->next) {
328 if (menu->sym && menu->sym->type != S_UNKNOWN) {
329 menu_set_type(menu->sym->type);
343 /* Menu node for 'menu', 'if' */
347 /* For each child menu node... */
348 for (menu = parent->list; menu; menu = menu->next) {
350 * Propagate parent dependencies to the child menu
353 basedep = rewrite_m(menu->dep);
357 menu->dep = basedep;
359 if (menu->sym)
364 prop = menu->sym->prop;
367 * For non-symbol menu nodes, we just need to
370 prop = menu->prompt;
374 if (prop->menu != menu)
401 if (menu->sym && menu->sym->type != S_TRISTATE)
412 expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
416 expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
428 for (menu = parent->list; menu; menu = menu->next)
429 _menu_finalize(menu, is_choice);
434 * all depend on sym, then the following menu structure is
459 for (menu = parent->next; menu; menu = menu->next) {
460 dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
474 * Note that 'R' might be from an enclosing menu or if,
490 _menu_finalize(menu, false);
491 menu->parent = parent;
492 last_menu = menu;
503 for (menu = parent->list; menu; menu = menu->next) {
505 menu->sym && !sym_is_choice_value(menu->sym)) {
506 current_entry = menu;
507 menu->sym->flags |= SYMBOL_CHOICEVAL;
514 if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
516 menu->dep = expr_alloc_and(basedep, menu->dep);
517 for (prop = menu->sym->prop; prop; prop = prop->next) {
518 if (prop->menu != menu)
529 (*ep)->right.sym = menu->sym;
560 if (menu->list && (!menu->prompt || !menu->prompt->text)) {
561 for (last_menu = menu->list; ; last_menu = last_menu->next) {
566 last_menu->next = menu->next;
567 menu->next = menu->list;
568 menu->list = NULL;
598 bool menu_has_prompt(struct menu *menu)
600 if (!menu->prompt)
606 * Determine if a menu is empty.
607 * A menu is considered empty if it contains no or only
610 bool menu_is_empty(struct menu *menu)
612 struct menu *child;
614 for (child = menu->list; child; child = child->next) {
621 bool menu_is_visible(struct menu *menu)
623 struct menu *child;
627 if (!menu->prompt)
630 if (menu->visibility) {
631 if (expr_calc_value(menu->visibility) == no)
635 sym = menu->sym;
638 visible = menu->prompt->visible.tri;
640 visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
645 if (!sym || sym_get_tristate_value(menu->sym) == no)
648 for (child = menu->list; child; child = child->next) {
659 const char *menu_get_prompt(struct menu *menu)
661 if (menu->prompt)
662 return menu->prompt->text;
663 else if (menu->sym)
664 return menu->sym->name;
668 struct menu *menu_get_parent_menu(struct menu *menu)
672 for (; menu != &rootmenu; menu = menu->parent) {
673 type = menu->prompt ? menu->prompt->type : 0;
677 return menu;
680 static void get_def_str(struct gstr *r, struct menu *menu)
683 menu->filename, menu->lineno);
704 struct menu *submenu[8], *menu, *location = NULL;
709 get_dep_str(r, prop->menu->dep, " Depends on: ");
718 if (!expr_eq(prop->menu->dep, prop->visible.expr))
721 menu = prop->menu;
722 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
723 submenu[i++] = menu;
724 if (location == NULL && menu_is_visible(menu))
725 location = menu;
738 menu = submenu[i];
739 if (jump && menu == location) {
749 str_printf(r, "%*c-> %s", indent, ' ', menu_get_prompt(menu));
750 if (menu->sym) {
751 str_printf(r, " (%s [=%s])", menu->sym->name ?
752 menu->sym->name : "<choice>",
753 sym_get_string_value(menu->sym));
784 struct menu *menu;
801 list_for_each_entry(menu, &sym->menus, link) {
802 if (menu->prompt) {
803 get_def_str(r, menu);
804 get_prompt_str(r, menu->prompt, head);
808 list_for_each_entry(menu, &sym->menus, link) {
809 if (!menu->prompt) {
810 get_def_str(r, menu);
811 get_dep_str(r, menu->dep, " Depends on: ");
846 void menu_get_ext_help(struct menu *menu, struct gstr *help)
848 struct symbol *sym = menu->sym;
851 if (menu->help) {
854 help_text = menu->help;