From: Jonathan Neuschäfer Date: Wed, 4 Jan 2012 17:33:30 +0000 (+0100) Subject: screen_text: add support for appending text X-Git-Tag: release-0.21~25^2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c446197e412ba82659d724b04fa3894c30f99241;p=ncmpc.git screen_text: add support for appending text --- diff --git a/src/screen_text.c b/src/screen_text.c index 244903d..03a8fc5 100644 --- a/src/screen_text.c +++ b/src/screen_text.c @@ -37,14 +37,12 @@ screen_text_clear(struct screen_text *text) } void -screen_text_set(struct screen_text *text, const char *str) +screen_text_append(struct screen_text *text, const char *str) { const char *eol, *next; assert(str != NULL); - screen_text_clear(text); - while ((eol = strchr(str, '\n')) != NULL) { char *line; diff --git a/src/screen_text.h b/src/screen_text.h index 3d9327c..1b688f7 100644 --- a/src/screen_text.h +++ b/src/screen_text.h @@ -66,7 +66,14 @@ screen_text_is_empty(const struct screen_text *text) } void -screen_text_set(struct screen_text *text, const char *str); +screen_text_append(struct screen_text *text, const char *str); + +static inline void +screen_text_set(struct screen_text *text, const char *str) +{ + screen_text_clear(text); + screen_text_append(text, str); +} const char * screen_text_list_callback(unsigned idx, void *data);