diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index fbc70fc9ff..80b279c638 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c @@ -728,9 +728,17 @@ static void calc_max_width(void) static bool done = false; static int col = 0; -#define ADVANCE_COUNTERS(c) { width += glyph_width(c); k++; } -#define LINE_IS_FULL ((k>=max_columns-1) ||( width >= max_width)) -#define LINE_IS_NOT_FULL ((k= max_columns - 1) || (width >= max_width)); +} + static unsigned char* crop_at_width(const unsigned char* p) { int k,width; @@ -739,12 +747,12 @@ static unsigned char* crop_at_width(const unsigned char* p) k=width=0; - while (LINE_IS_NOT_FULL) { + while (!line_is_full(k, width)) { oldp = p; if (BUFFER_OOB(p)) break; p = get_ucs(p, &ch); - ADVANCE_COUNTERS(ch); + advance_conters(ch, &k, &width); } return (unsigned char*)oldp; @@ -824,7 +832,7 @@ static unsigned char* find_next_line(const unsigned char* cur_line, bool *is_sho for (j=k=width=spaces=newlines=0; ; j++) { if (BUFFER_OOB(cur_line+j)) return NULL; - if (LINE_IS_FULL) { + if (line_is_full(k, width)) { size = search_len = j; break; } @@ -840,7 +848,7 @@ static unsigned char* find_next_line(const unsigned char* cur_line, bool *is_sho } if (j==0) /* i=1 is intentional */ for (i=0; i0) { while (spaces) { spaces--; - ADVANCE_COUNTERS(' '); - if (LINE_IS_FULL) { + advance_conters(' ', &k, &width); + if (line_is_full(k, width)) { size = search_len = j; break; } @@ -879,14 +887,14 @@ static unsigned char* find_next_line(const unsigned char* cur_line, bool *is_sho * while drawing. */ search_len = size; spaces=0; - ADVANCE_COUNTERS(' '); - if (LINE_IS_FULL) { + advance_conters(' ', &k, &width); + if (line_is_full(k, width)) { size = search_len = j; break; } } first_chars = false; - ADVANCE_COUNTERS(c); + advance_conters(ch, &k, &width); break; } }