diff mbox

wrap long help lines, take two

Message ID 3b09bd800912142246u2d069702n759e165553bddc9f@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vadim Bendebury Dec. 15, 2009, 6:46 a.m. UTC
None
diff mbox

Patch

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));
 }