linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wrap long help lines, take two
@ 2009-12-15  6:46 Vadim Bendebury (вб)
  2009-12-15 13:33 ` Michal Marek
  0 siblings, 1 reply; 6+ messages in thread
From: Vadim Bendebury (вб) @ 2009-12-15  6:46 UTC (permalink / raw)
  To: linux-kbuild; +Cc: mmarek

Help text for certain config options is very extensive (the text includes all
config options which the option in question depends on). Long lines are not
wrapped, making it impossible to see the list.

This patch adds some logic which wraps help screen lines at word
boundaries to prevent truncating .

Tested by running

mkdir ../build/powerpc
ARCH=powerpc make menuconfig O=../build/powerpc

in the kernel sorce tree. Once menu is displayed, hitting c<cr>cc? brings up
the help message for CONFIG_CRYPTO_MANAGER, now properly wrapped.

Signed-off-by: Vadim Bendebury <vbendeb@google.com>
---
 scripts/kconfig/expr.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 2aa49e8..203eb6d 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -1099,9 +1099,25 @@ void expr_fprint(struct expr *e, FILE *out)

 static void expr_print_gstr_helper(void *data, struct symbol *sym,
const char *str)
 {
-       str_append((struct gstr*)data, str);
+       struct gstr *gs = (struct gstr*)data;
+       unsigned extra_length = strlen(str) + (sym ? 4 : 0);
+       const char *last_cr = strrchr(gs->s, '\n');
+       unsigned screen_width = getmaxx(stdscr) - 10;
+       unsigned last_line_length;
+
+       if (!last_cr) {
+               last_cr = gs->s;
+       }
+
+       last_line_length = strlen(gs->s) - (last_cr - gs->s);
+
+       if ((last_line_length + extra_length) > screen_width) {
+               str_append(gs, "\\\n");
+       }
+
+       str_append(gs, str);
        if (sym)
-               str_printf((struct gstr*)data, " [=%s]",
sym_get_string_value(sym));
+               str_printf(gs, " [=%s]", sym_get_string_value(sym));
 }

 void expr_gstr_print(struct expr *e, struct gstr *gs)
--
1.5.4.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-06 20:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-15  6:46 [PATCH] wrap long help lines, take two Vadim Bendebury (вб)
2009-12-15 13:33 ` Michal Marek
2009-12-16  4:56   ` Vadim Bendebury (вб)
2009-12-16 12:02     ` Michal Marek
2009-12-20  8:29       ` Vadim Bendebury (вб)
2010-01-06 20:48         ` Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).