History

menuconfig: wrap long help lines

Help text for certain config options is very extensive (the text includes the names of all other options the option in question depends on). Long lines are not wrapped, making it impossible to see the list without scrolling horizontally. This patch adds some logic which wraps help screen lines at word boundaries to prevent truncating. Tested by running ARCH=powerpc make menuconfig O=/tmp/build which shows that the long lines are now wrapped, and ARCH=powerpc make xconfig O=/tmp/build to demonstrate that it still compiles and operates as expected.

Vadim Bendebury (вб) committed 16 years ago

Commit da60fbb1 parent 5358db04 files · +33 −2Browse files

Unified · Split

4 files
  1. scripts/kconfig/expr.c +25 −2
  2. scripts/kconfig/lkc.h +5 −0
  3. scripts/kconfig/mconf.c +1 −0
  4. scripts/kconfig/util.c +2 −0
scripts/kconfig/expr.c+25−2
@@ -1097,9 +1097,32 @@ void expr_fprint(struct expr *e, FILE *out) · 1096 unmodified lines
1097 1097
1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
1099{1099{
1100 str_append((struct gstr*)data, str);1100 struct gstr *gs = (struct gstr*)data;
1101 const char *sym_str = NULL;
1102
1103 if (sym)
1104 sym_str = sym_get_string_value(sym);
1105
1106 if (gs->max_width) {
1107 unsigned extra_length = strlen(str);
1108 const char *last_cr = strrchr(gs->s, '\n');
1109 unsigned last_line_length;
1110
1111 if (sym_str)
1112 extra_length += 4 + strlen(sym_str);
1113
1114 if (!last_cr)
1115 last_cr = gs->s;
1116
1117 last_line_length = strlen(gs->s) - (last_cr - gs->s);
1118
1119 if ((last_line_length + extra_length) > gs->max_width)
1120 str_append(gs, "\\\n");
1121 }
1122
1123 str_append(gs, str);
1101 if (sym)1124 if (sym)
1102 str_printf((struct gstr*)data, " [=%s]", sym_get_string_value(sym));1125 str_printf(gs, " [=%s]", sym_str);
1103}1126}
1104 1127
1105void expr_gstr_print(struct expr *e, struct gstr *gs)1128void expr_gstr_print(struct expr *e, struct gstr *gs)
scripts/kconfig/lkc.h+5−0
@@ -106,6 +106,11 @@ int file_write_dep(const char *name); · 105 unmodified lines
106struct gstr {106struct gstr {
107 size_t len;107 size_t len;
108 char *s;108 char *s;
109 /*
110 * when max_width is not zero long lines in string s (if any) get
111 * wrapped not to exceed the max_width value
112 */
113 int max_width;
109};114};
110struct gstr str_new(void);115struct gstr str_new(void);
111struct gstr str_assign(const char *s);116struct gstr str_assign(const char *s);
scripts/kconfig/mconf.c+1−0
@@ -638,6 +638,7 @@ static void show_help(struct menu *menu) · 637 unmodified lines
638{638{
639 struct gstr help = str_new();639 struct gstr help = str_new();
640 640
641 help.max_width = getmaxx(stdscr) - 10;
641 menu_get_ext_help(menu, &help);642 menu_get_ext_help(menu, &help);
642 643
643 show_helptext(_(menu_get_prompt(menu)), str_get(&help));644 show_helptext(_(menu_get_prompt(menu)), str_get(&help));
scripts/kconfig/util.c+2−0
@@ -78,6 +78,7 @@ struct gstr str_new(void) · 77 unmodified lines
78 struct gstr gs;78 struct gstr gs;
79 gs.s = malloc(sizeof(char) * 64);79 gs.s = malloc(sizeof(char) * 64);
80 gs.len = 64;80 gs.len = 64;
81 gs.max_width = 0;
81 strcpy(gs.s, "\0");82 strcpy(gs.s, "\0");
82 return gs;83 return gs;
83}84}
@@ -88,6 +89,7 @@ struct gstr str_assign(const char *s) · 4 unmodified lines
88 struct gstr gs;89 struct gstr gs;
89 gs.s = strdup(s);90 gs.s = strdup(s);
90 gs.len = strlen(s) + 1;91 gs.len = strlen(s) + 1;
92 gs.max_width = 0;
91 return gs;93 return gs;
92}94}
93 95