[PATCH] wrap long help lines, take two

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux