diff options
Diffstat (limited to '')
-rw-r--r-- | src/list_window.c | 3 | ||||
-rw-r--r-- | src/screen.c | 15 | ||||
-rw-r--r-- | src/support.c | 23 |
3 files changed, 27 insertions, 14 deletions
diff --git a/src/list_window.c b/src/list_window.c index 5ee81d069..05f5630e9 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -203,7 +203,8 @@ list_window_paint(list_window_t *lw, if( show_cursor && selected ) wattron(lw->w, A_REVERSE); - waddnstr(lw->w, label, lw->cols); + //waddnstr(lw->w, label, lw->cols); + waddnstr(lw->w, label); if( fill && len<lw->cols ) mvwhline(lw->w, i, len, ' ', lw->cols-len); diff --git a/src/screen.c b/src/screen.c index 72bdaff36..0a3b2f721 100644 --- a/src/screen.c +++ b/src/screen.c @@ -187,9 +187,9 @@ paint_top_window(char *header, mpdclient_t *c, int clear) static int prev_header_len = -1; WINDOW *w = screen->top_window.w; - if(prev_header_len!=strlen(header)) + if(prev_header_len!=my_strlen(header)) { - prev_header_len = strlen(header); + prev_header_len = my_strlen(header); clear = 1; } @@ -244,7 +244,7 @@ paint_top_window(char *header, mpdclient_t *c, int clear) g_snprintf(buf, 32, _(" Volume %d%%"), c->status->volume); } colors_use(w, COLOR_TITLE); - mvwaddstr(w, 0, screen->top_window.cols-strlen(buf), buf); + mvwaddstr(w, 0, screen->top_window.cols-my_strlen(buf), buf); flags[0] = 0; if( c->status->repeat ) @@ -334,7 +334,7 @@ paint_status_window(mpdclient_t *c) if( str ) { waddstr(w, str); - x += strlen(str)+1; + x += my_strlen(str)+1; } /* create time string */ @@ -381,7 +381,7 @@ paint_status_window(mpdclient_t *c) if( (IS_PLAYING(status->state) || IS_PAUSED(status->state)) ) { char songname[MAX_SONGNAME_LENGTH]; - int width = COLS-x-strlen(screen->buf); + int width = COLS-x-my_strlen(screen->buf); if( song ) strfsong(songname, MAX_SONGNAME_LENGTH, STATUS_FORMAT, song); @@ -390,7 +390,7 @@ paint_status_window(mpdclient_t *c) colors_use(w, COLOR_STATUS); /* scroll if the song name is to long */ - if( strlen(songname) > width ) + if( my_strlen(songname) > width ) { static scroll_state_t st = { 0, 0 }; char *tmp = strscroll(songname, " *** ", width, &st); @@ -398,7 +398,8 @@ paint_status_window(mpdclient_t *c) g_strlcpy(songname, tmp, MAX_SONGNAME_LENGTH); g_free(tmp); } - mvwaddnstr(w, 0, x, songname, width); + //mvwaddnstr(w, 0, x, songname, width); + mvwaddnstr(w, 0, x, songname); } /* display time string */ diff --git a/src/support.c b/src/support.c index ade5ee4eb..847178d9c 100644 --- a/src/support.c +++ b/src/support.c @@ -106,6 +106,7 @@ strcasestr(const char *haystack, const char *needle) } #endif /* HAVE_STRCASESTR */ +// FIXME: utf-8 length char * strscroll(char *str, char *separator, int width, scroll_state_t *st) { @@ -123,18 +124,28 @@ strscroll(char *str, char *separator, int width, scroll_state_t *st) tmp = g_malloc(size); g_strlcpy(tmp, str, size); g_strlcat(tmp, separator, size); - len = strlen(tmp); + len = my_strlen(tmp); if( st->offset >= len ) st->offset = 0; /* create the new scrolled string */ size = width+1; - buf = g_malloc(size); - g_strlcpy(buf, tmp+st->offset, size); - if( strlen(buf) < width ) - g_strlcat(buf, tmp, size); - + if (g_utf8_validate(tmp, -1, NULL) ) + { + int ulen; + buf = g_malloc(size*6);// max length of utf8 char is 6 + g_utf8_strncpy(buf, g_utf8_offset_to_pointer(tmp,st->offset), size); + if( (ulen = g_utf8_strlen(buf, -1)) < width ) + g_utf8_strncpy(buf+strlen(buf), tmp, size - ulen - 1); + } + else + { + buf = g_malloc(size); + g_strlcpy(buf, tmp+st->offset, size); + if( strlen(buf) < width ) + g_strlcat(buf, tmp, size); + } if( time(NULL)-st->t >= 1 ) { st->t = time(NULL); |