diff --git a/src/utils/utf8.c b/src/utils/utf8.c index 375cb4d..1ab4dc0 100644 --- a/src/utils/utf8.c +++ b/src/utils/utf8.c @@ -45,21 +45,19 @@ int64_t u_utf8_convert_to_wide(const char *utf8_str, } int64_t u_utf8_curs_printw(WINDOW *win, int64_t *y, int64_t *x, - const char *utf8_str, int max_len, bool multi_line) { + const char *utf8_str, int max_len, bool multiline) { wchar_t *wline = NULL; size_t nsize = 0; int64_t _x = *x; int64_t _y = *y; u_utf8_convert_to_wide(utf8_str, &wline, &nsize); - size_t s_rest = nsize; mvwaddnwstr(win, _y, _x, wline, max_len); - if (multi_line) { - s_rest -= max_len; - for (int i = 1; s_rest > 0; s_rest -= max_len, i++) { - _y++; + if (multiline) { + _y++; + for (int i = 1; max_len*i < nsize; i++) { _x = *x; - mvwaddnwstr(win, _y, _x, wline + max_len*i, max_len); + mvwaddnwstr(win, _y++, _x, wline + max_len*i, max_len); } } diff --git a/src/utils/utf8.h b/src/utils/utf8.h index 0198f7b..b38a0c4 100644 --- a/src/utils/utf8.h +++ b/src/utils/utf8.h @@ -9,6 +9,6 @@ const char *u_utf8_wind_n(const char *s, int n); size_t u_utf8_code_points_count(const char *s); int64_t u_utf8_convert_to_wide(const char *utf8_str, wchar_t **restrict wide_str, size_t *restrict len); -int64_t u_utf8_curs_printw(WINDOW *win, int64_t *y, int64_t *x, const char* utf8_str, int max_len, bool multi_line); +int64_t u_utf8_curs_printw(WINDOW *win, int64_t *y, int64_t *x, const char* utf8_str, int max_len, bool multiline); #endif \ No newline at end of file