diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-01 14:24:17 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-01 15:09:29 (EDT) |
commit | 8dd98917acb6ee2078c6d4a9e176a016b2648695 (patch) | |
tree | 7c3ab96070269d634a0dd367afaea1f8ba4ba80f | |
parent | 41a2147edfb2d7bc893ecc5a830143ebfd2d6dd9 (diff) | |
download | marquee-8dd98917acb6ee2078c6d4a9e176a016b2648695.zip marquee-8dd98917acb6ee2078c6d4a9e176a016b2648695.tar.gz marquee-8dd98917acb6ee2078c6d4a9e176a016b2648695.tar.bz2 |
mq_html_list(): New function
-rw-r--r-- | src/html.c | 43 | ||||
-rw-r--r-- | src/html.h | 3 |
2 files changed, 46 insertions, 0 deletions
@@ -186,6 +186,49 @@ TEXT_ELEMENT(p) #undef TEXT_ELEMENT gchar * +mq_html_list(const gchar *type, ...) +{ + gsize len; + va_list ap; + gchar *child; + gchar *form; + gchar *ptr; + + /* TODO: Doesn't support specification of <ol> list types. */ + + /* Calculate length. */ + len = strlen("<ul>\n"); + va_start(ap, type); + while ((child = va_arg(ap, gchar *))) { + len += strlen("<li>\n"); + len += strlen(child); + len += strlen("</li>\n"); + } + va_end(ap); + len += strlen("</ul>\n"); + ++len; /* NUL byte */ + + /* Build string. */ + form = g_new(gchar, len); + if (type && type[0]) { + ptr = g_stpcpy(form, "<ol>\n"); + } else { + ptr = g_stpcpy(form, "<ul>\n"); + } + va_start(ap, type); + while ((child = va_arg(ap, gchar *))) { + ptr = g_stpcpy(ptr, "<li>\n"); + ptr = g_stpcpy(ptr, child); + g_free(child); + ptr = g_stpcpy(ptr, "</li>\n"); + } + va_end(ap); + ptr = g_stpcpy(ptr, "</ul>\n"); /* g_stpcpy() adds the NUL. */ + + return form; +} + +gchar * mq_html_container(const gchar *element, ...) { gsize len; @@ -45,6 +45,9 @@ gchar * mq_html_container(const gchar *element, ...); gchar * +mq_html_list(const gchar *type, ...); + +gchar * mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...); gchar * |