From d9ceb63f17ce25b255dbab8ea60ea710099e2611 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 29 Sep 2017 03:29:48 -0400 Subject: UTF-8-AWARE MARQUEE MODE --- diff --git a/src/tab.c b/src/tab.c index 80d3972..fe1096a 100644 --- a/src/tab.c +++ b/src/tab.c @@ -456,19 +456,26 @@ init_non_root(const gchar *uri) static void scroll_tab_label(MqTab *tab) { - gchar c; + gchar c[5]; /* Up to 4 bytes for a UTF-8 character, plus NUL */ guint i; + guint j; - /* Save the first character. */ - c = tab->scrolled_title[0]; + /* Save the first (possibly multibyte) character. */ + c[0] = tab->scrolled_title[0]; + for (i = 1; tab->scrolled_title[i] & 0x80; ++i) { + c[i] = tab->scrolled_title[i]; + } + c[i] = '\0'; /* Shift all characters. */ - for (i = 1; tab->scrolled_title[i]; ++i) { - tab->scrolled_title[i - 1] = tab->scrolled_title[i]; + for (j = 0; tab->scrolled_title[i]; ++i, ++j) { + tab->scrolled_title[j] = tab->scrolled_title[i]; } - /* Set the last character. */ - tab->scrolled_title[i - 1] = c; + /* Set the last (possibly multibyte) character. */ + for (--j, i = 0; c[i]; ++i, ++j) { + tab->scrolled_title[j] = c[i]; + } update_tab_label(tab); } -- cgit v0.9.1