MCPcopy Create free account
hub / github.com/Entware/Entware / get_prompt_str

Function get_prompt_str

scripts/config/menu.c:709–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

707}
708
709static void get_prompt_str(struct gstr *r, struct property *prop,
710 struct list_head *head)
711{
712 int i, j;
713 struct menu *submenu[8], *menu, *location = NULL;
714 struct jump_key *jump = NULL;
715
716 str_printf(r, " Prompt: %s\n", prop->text);
717
718 get_dep_str(r, prop->menu->dep, " Depends on: ");
719 /*
720 * Most prompts in Linux have visibility that exactly matches their
721 * dependencies. For these, we print only the dependencies to improve
722 * readability. However, prompts with inline "if" expressions and
723 * prompts with a parent that has a "visible if" expression have
724 * differing dependencies and visibility. In these rare cases, we
725 * print both.
726 */
727 if (!expr_eq(prop->menu->dep, prop->visible.expr))
728 get_dep_str(r, prop->visible.expr, " Visible if: ");
729
730 menu = prop->menu;
731 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
732 submenu[i++] = menu;
733 if (location == NULL && menu_is_visible(menu))
734 location = menu;
735 }
736 if (head && location) {
737 jump = xmalloc(sizeof(struct jump_key));
738 jump->target = location;
739 list_add_tail(&jump->entries, head);
740 }
741
742 str_printf(r, " Location:\n");
743 for (j = 0; --i >= 0; j++) {
744 int jk = -1;
745 int indent = 2 * j + 4;
746
747 menu = submenu[i];
748 if (jump && menu == location) {
749 jump->offset = strlen(r->s);
750 jk = get_jump_key_char();
751 }
752
753 if (jk >= 0) {
754 str_printf(r, "(%c)", jk);
755 indent -= 3;
756 }
757
758 str_printf(r, "%*c-> %s", indent, ' ', menu_get_prompt(menu));
759 if (menu->sym) {
760 str_printf(r, " (%s [=%s])", menu->sym->name ?
761 menu->sym->name : "<choice>",
762 sym_get_string_value(menu->sym));
763 }
764 str_append(r, "\n");
765 }
766}

Callers 1

get_symbol_strFunction · 0.85

Calls 10

str_printfFunction · 0.85
get_dep_strFunction · 0.85
expr_eqFunction · 0.85
menu_is_visibleFunction · 0.85
xmallocFunction · 0.85
menu_get_promptFunction · 0.85
sym_get_string_valueFunction · 0.85
str_appendFunction · 0.85
list_add_tailFunction · 0.70
get_jump_key_charFunction · 0.70

Tested by

no test coverage detected