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