]> Pileus Git - ~andy/linux/commitdiff
kconfig: attach help text to menus
authorSam Ravnborg <sam@ravnborg.org>
Fri, 20 Jul 2007 22:00:36 +0000 (00:00 +0200)
committerSam Ravnborg <sam@ravnborg.org>
Wed, 25 Jul 2007 19:14:26 +0000 (21:14 +0200)
Roman Zippel wrote:
> A simple example would be
> help texts, right now they are per symbol, but they should really be per
> menu, so archs can provide different help texts for something.

This patch does this and at the same time introduce a few API
funtions used to access the help text.

The relevant api functions are introduced in the various frontends.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
scripts/kconfig/conf.c
scripts/kconfig/expr.h
scripts/kconfig/gconf.c
scripts/kconfig/kxgettext.c
scripts/kconfig/lkc_proto.h
scripts/kconfig/mconf.c
scripts/kconfig/menu.c
scripts/kconfig/qconf.cc
scripts/kconfig/zconf.tab.c_shipped
scripts/kconfig/zconf.y

index 1199baf866ca1c24c08b46972144e24f43353ff5..8be6a4269e63b8864a0a6472443381f2372cbe55 100644 (file)
@@ -37,6 +37,14 @@ static struct menu *rootEntry;
 
 static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
 
+static const char *get_help(struct menu *menu)
+{
+       if (menu_has_help(menu))
+               return menu_get_help(menu);
+       else
+               return nohelp_text;
+}
+
 static void strip(char *str)
 {
        char *p = str;
@@ -171,7 +179,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
 int conf_string(struct menu *menu)
 {
        struct symbol *sym = menu->sym;
-       const char *def, *help;
+       const char *def;
 
        while (1) {
                printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -186,10 +194,7 @@ int conf_string(struct menu *menu)
                case '?':
                        /* print help */
                        if (line[1] == '\n') {
-                               help = nohelp_text;
-                               if (menu->sym->help)
-                                       help = menu->sym->help;
-                               printf("\n%s\n", menu->sym->help);
+                               printf("\n%s\n", get_help(menu));
                                def = NULL;
                                break;
                        }
@@ -207,7 +212,6 @@ static int conf_sym(struct menu *menu)
        struct symbol *sym = menu->sym;
        int type;
        tristate oldval, newval;
-       const char *help;
 
        while (1) {
                printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -233,7 +237,7 @@ static int conf_sym(struct menu *menu)
                        printf("/m");
                if (oldval != yes && sym_tristate_within_range(sym, yes))
                        printf("/y");
-               if (sym->help)
+               if (menu_has_help(menu))
                        printf("/?");
                printf("] ");
                conf_askvalue(sym, sym_get_string_value(sym));
@@ -269,10 +273,7 @@ static int conf_sym(struct menu *menu)
                if (sym_set_tristate_value(sym, newval))
                        return 0;
 help:
-               help = nohelp_text;
-               if (sym->help)
-                       help = sym->help;
-               printf("\n%s\n", help);
+               printf("\n%s\n", get_help(menu));
        }
 }
 
@@ -342,7 +343,7 @@ static int conf_choice(struct menu *menu)
                        goto conf_childs;
                }
                printf("[1-%d", cnt);
-               if (sym->help)
+               if (menu_has_help(menu))
                        printf("?");
                printf("]: ");
                switch (input_mode) {
@@ -359,8 +360,7 @@ static int conf_choice(struct menu *menu)
                        fgets(line, 128, stdin);
                        strip(line);
                        if (line[0] == '?') {
-                               printf("\n%s\n", menu->sym->help ?
-                                       menu->sym->help : nohelp_text);
+                               printf("\n%s\n", get_help(menu));
                                continue;
                        }
                        if (!line[0])
@@ -391,8 +391,7 @@ static int conf_choice(struct menu *menu)
                if (!child)
                        continue;
                if (line[strlen(line) - 1] == '?') {
-                       printf("\n%s\n", child->sym->help ?
-                               child->sym->help : nohelp_text);
+                       printf("\n%s\n", get_help(child));
                        continue;
                }
                sym_set_choice_value(sym, child->sym);
index 6084525f604b10e9871ada2aa6ca096d5be481ff..d6c33ce6dfdf61d7f22fbe919e9dd0f10a027981 100644 (file)
@@ -71,7 +71,6 @@ enum {
 struct symbol {
        struct symbol *next;
        char *name;
-       char *help;
        enum symbol_type type;
        struct symbol_value curr;
        struct symbol_value def[4];
@@ -139,7 +138,7 @@ struct menu {
        struct property *prompt;
        struct expr *dep;
        unsigned int flags;
-       //char *help;
+       char *help;
        struct file *file;
        int lineno;
        void *data;
index 61d8166166ef86177cf28b65575a9004f7113c08..262908cfc2ac66a057eb18d4a7c1853f96f34f95 100644 (file)
@@ -38,9 +38,6 @@ static gboolean show_all = FALSE;
 static gboolean show_debug = FALSE;
 static gboolean resizeable = FALSE;
 
-static char nohelp_text[] =
-    N_("Sorry, no help available for this option yet.\n");
-
 GtkWidget *main_wnd = NULL;
 GtkWidget *tree1_w = NULL;     // left  frame
 GtkWidget *tree2_w = NULL;     // right frame
@@ -462,12 +459,9 @@ static void text_insert_help(struct menu *menu)
        GtkTextIter start, end;
        const char *prompt = menu_get_prompt(menu);
        gchar *name;
-       const char *help = _(nohelp_text);
+       const char *help;
 
-       if (!menu->sym)
-               help = "";
-       else if (menu->sym->help)
-               help = _(menu->sym->help);
+       help = _(menu_get_help(menu));
 
        if (menu->sym && menu->sym->name)
                name = g_strdup_printf(_(menu->sym->name));
index 11f7dab94715625911eb51ed2d6f24a339f12824..6eb72a7f2562fc2d79847d8e4da2ad3ebb539a25 100644 (file)
@@ -170,8 +170,8 @@ void menu_build_message_list(struct menu *menu)
                     menu->file == NULL ? "Root Menu" : menu->file->name,
                     menu->lineno);
 
-       if (menu->sym != NULL && menu->sym->help != NULL)
-               message__add(menu->sym->help, menu->sym->name,
+       if (menu->sym != NULL && menu_has_help(menu))
+               message__add(menu_get_help(menu), menu->sym->name,
                             menu->file == NULL ? "Root Menu" : menu->file->name,
                             menu->lineno);
 
index 15030770d1ad4e937272a6f03d7d704ebad70dff..4d09f6ddefe3daa71bb9d5d8bcbe1b774b0b2821 100644 (file)
@@ -15,6 +15,8 @@ P(menu_is_visible,bool,(struct menu *menu));
 P(menu_get_prompt,const char *,(struct menu *menu));
 P(menu_get_root_menu,struct menu *,(struct menu *menu));
 P(menu_get_parent_menu,struct menu *,(struct menu *menu));
+P(menu_has_help,bool,(struct menu *menu));
+P(menu_get_help,const char *,(struct menu *menu));
 
 /* symbol.c */
 P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
index d2c2a429887b30152b57d26eaea78086a41bd3c3..bc5854ed60554e9459fca037ff507ed4f7e79d16 100644 (file)
@@ -725,11 +725,11 @@ static void show_help(struct menu *menu)
        struct gstr help = str_new();
        struct symbol *sym = menu->sym;
 
-       if (sym->help)
+       if (menu_has_help(menu))
        {
                if (sym->name) {
                        str_printf(&help, "CONFIG_%s:\n\n", sym->name);
-                       str_append(&help, _(sym->help));
+                       str_append(&help, _(menu_get_help(menu)));
                        str_append(&help, "\n");
                }
        } else {
index f14aeac67d4f282e9e5c3edbe4a1398af1a7c4fb..f9d0d91a3fe44e2407761a60bb5a31dc22926b41 100644 (file)
@@ -417,3 +417,15 @@ struct menu *menu_get_parent_menu(struct menu *menu)
        return menu;
 }
 
+bool menu_has_help(struct menu *menu)
+{
+       return menu->help != NULL;
+}
+
+const char *menu_get_help(struct menu *menu)
+{
+       if (menu->help)
+               return menu->help;
+       else
+               return "";
+}
index f2a23a9c39386492773a9832603b13fb9ec7fb10..e4eeb59a8c24aae7065144f1618220d2f22b8cec 100644 (file)
@@ -1041,7 +1041,7 @@ void ConfigInfoView::menuInfo(void)
                if (showDebug())
                        debug = debug_info(sym);
 
-               help = print_filter(_(sym->help));
+               help = print_filter(_(menu_get_help(menu)));
        } else if (menu->prompt) {
                head += "<big><b>";
                head += print_filter(_(menu->prompt->text));
index 9a06b6771eee0c0095792aceda5117f1a91a0503..ec21db77f78bad37d5c5d872b6487cf9a43912a4 100644 (file)
@@ -1722,7 +1722,7 @@ yyreduce:
   case 83:
 
     {
-       current_entry->sym->help = (yyvsp[0].string);
+       current_entry->help = (yyvsp[0].string);
 ;}
     break;
 
@@ -2280,11 +2280,11 @@ void print_symbol(FILE *out, struct menu *menu)
                        break;
                }
        }
-       if (sym->help) {
-               int len = strlen(sym->help);
-               while (sym->help[--len] == '\n')
-                       sym->help[len] = 0;
-               fprintf(out, "  help\n%s\n", sym->help);
+       if (menu->help) {
+               int len = strlen(menu->help);
+               while (menu->help[--len] == '\n')
+                       menu->help[len] = 0;
+               fprintf(out, "  help\n%s\n", menu->help);
        }
        fputc('\n', out);
 }
index 92eb02bdf9c5f3a70ff96b5525fbcd89307afe63..79db4cf22a5127000f90fabfbee7b13c90c2d415 100644 (file)
@@ -402,7 +402,7 @@ help_start: T_HELP T_EOL
 
 help: help_start T_HELPTEXT
 {
-       current_entry->sym->help = $2;
+       current_entry->help = $2;
 };
 
 /* depends option */
@@ -649,11 +649,11 @@ void print_symbol(FILE *out, struct menu *menu)
                        break;
                }
        }
-       if (sym->help) {
-               int len = strlen(sym->help);
-               while (sym->help[--len] == '\n')
-                       sym->help[len] = 0;
-               fprintf(out, "  help\n%s\n", sym->help);
+       if (menu->help) {
+               int len = strlen(menu->help);
+               while (menu->help[--len] == '\n')
+                       menu->help[len] = 0;
+               fprintf(out, "  help\n%s\n", menu->help);
        }
        fputc('\n', out);
 }