From 92499b38a09341b7c3b5b4ba6f544652c2343f63 Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Sun, 19 Aug 2012 02:39:19 +0200 Subject: [PATCH] word wrap on "\n" --- dunst.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dunst.c b/dunst.c index d0df738..ea21159 100644 --- a/dunst.c +++ b/dunst.c @@ -365,10 +365,23 @@ void update_lists() /* TODO get draw_txt_buf as argument */ int do_word_wrap(char *source, int max_width) { + strtrim(source); + if (!source || source == '\0' || strcmp(source, "") == 0) + return 0; + char *eol = source; while (True) { if (*eol == '\0') return 1; + if (*eol == '\n') { + *eol = '\0'; + return 1 + do_word_wrap(eol + 1, max_width); + } + if (*eol == '\\' && *(eol+1) == 'n') { + *eol = ' '; + *(eol+1) = '\0'; + return 1 + do_word_wrap(eol + 2, max_width); + } if (textnw(dc, source, (eol - source) + 1) >= max_width) { /* go back to previous space */