diff options
author | Vadim Bendebury (вб) <vbendeb@google.com> | 2009-12-20 03:29:49 -0500 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-02-02 08:33:55 -0500 |
commit | da60fbbcb637b37b1d77a41886ae4e275422ca96 (patch) | |
tree | b75965f0cc17567b1b7723094e1e9358e23c3b12 | |
parent | 5358db0b0e16470337c6ec08177deb3f68ed7673 (diff) |
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.
Signed-off-by: Vadim Bendebury <vbendeb@google.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
-rw-r--r-- | scripts/kconfig/expr.c | 27 | ||||
-rw-r--r-- | scripts/kconfig/lkc.h | 5 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 1 | ||||
-rw-r--r-- | scripts/kconfig/util.c | 2 |
4 files changed, 33 insertions, 2 deletions
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index edd3f39a080a..d83f2322893a 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
@@ -1097,9 +1097,32 @@ void expr_fprint(struct expr *e, FILE *out) | |||
1097 | 1097 | ||
1098 | static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str) | 1098 | static 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 | ||
1105 | void expr_gstr_print(struct expr *e, struct gstr *gs) | 1128 | void expr_gstr_print(struct expr *e, struct gstr *gs) |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index f379b0bf8c9e..e59dd0c5787a 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -106,6 +106,11 @@ int file_write_dep(const char *name); | |||
106 | struct gstr { | 106 | struct 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 | }; |
110 | struct gstr str_new(void); | 115 | struct gstr str_new(void); |
111 | struct gstr str_assign(const char *s); | 116 | struct gstr str_assign(const char *s); |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 8413cf38ed27..ac1e9dacde97 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -638,6 +638,7 @@ static void show_help(struct menu *menu) | |||
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)); |
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index b6b2a46af14c..81c100d953ef 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c | |||
@@ -78,6 +78,7 @@ struct gstr str_new(void) | |||
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) | |||
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 | ||