do wordwrap on "\n" even with !word_wrap

This commit is contained in:
Sascha Kruse 2012-08-22 22:34:31 +02:00
parent b5a7dbee5a
commit 925f3e8731

View File

@ -373,14 +373,14 @@ void update_lists()
/* TODO get draw_txt_buf as argument */
int do_word_wrap(char *source, int max_width)
{
if (!word_wrap || max_width < 1)
return 1;
strtrim_end(source);
if (!source || source == '\0' || strcmp(source, "") == 0)
if (!source || strlen(source) == 0)
return 0;
char *eol = source;
while (True) {
if (*eol == '\0')
return 1;
@ -394,6 +394,7 @@ int do_word_wrap(char *source, int max_width)
return 1 + do_word_wrap(eol + 2, max_width);
}
if (word_wrap && max_width > 0) {
if (textnw(dc, source, (eol - source) + 1) >= max_width) {
/* go back to previous space */
char *space = eol;
@ -411,6 +412,7 @@ int do_word_wrap(char *source, int max_width)
return 1;
return 1 + do_word_wrap(space + 1, max_width);
}
}
eol++;
}
}