diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-29 03:29:48 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-29 03:29:48 (EDT) |
commit | d9ceb63f17ce25b255dbab8ea60ea710099e2611 (patch) | |
tree | 0163e1fe561d7687ee66fffb6edb3036c716154e /src | |
parent | 08bf27821fe5e1444e993820adb5d874fbe04820 (diff) | |
download | marquee-d9ceb63f17ce25b255dbab8ea60ea710099e2611.zip marquee-d9ceb63f17ce25b255dbab8ea60ea710099e2611.tar.gz marquee-d9ceb63f17ce25b255dbab8ea60ea710099e2611.tar.bz2 |
UTF-8-AWARE MARQUEE MODE
Diffstat (limited to 'src')
-rw-r--r-- | src/tab.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -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); } |