From: Simon Doppler Date: Mon, 1 Dec 2014 20:20:39 +0000 (+0100) Subject: The calculation of `max_lines` takes in account the additionnal lines from URLs X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=35508ded3b1869a9fbe3a239825383677d1c0d75;p=smdp.git The calculation of `max_lines` takes in account the additionnal lines from URLs --- diff --git a/include/url.h b/include/url.h index 0426752..9088031 100644 --- a/include/url.h +++ b/include/url.h @@ -38,5 +38,6 @@ char * url_get_name(int index); int url_get_amount(void); void url_purge(void); void url_dump(void); +int url_count_inline(const char *line); #endif // !defined( URL_H ) diff --git a/src/url.c b/src/url.c index f968dae..682bced 100644 --- a/src/url.c +++ b/src/url.c @@ -136,3 +136,23 @@ static void url_print(url_t *u) { int url_get_amount(void) { return index_max; } + +int url_count_inline(const char *line) { + int count = 0; + const char* i = line; + + for (; *i; i++) { + if (*i == '\\') { + i++; + } else if ( *i == '[' && *(i+1) != ']') { + while (*i && *i != ']') i++; + i++; + if (*i == '(' && strchr(i, ')')) { + count ++; + i = strchr(i, ')') + 1; + } + } + } + + return count; +} diff --git a/src/viewer.c b/src/viewer.c index 6b96ea5..bd533e2 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -94,6 +94,10 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) { line = slide->line; while(line) { + + if (line && line->text && line->text->text) + lc += url_count_inline(line->text->text); + if(line->length > COLS) { i = line->length; offset = 0;