diff options
author | 2019-02-12 03:14:08 +0530 | |
---|---|---|
committer | 2019-02-12 03:14:08 +0530 | |
commit | b99a28a3761ee864fd3cf5150c49bc6c7ffc1f5a (patch) | |
tree | 1672a9e1d109141e11e862576f0b7ccc41eb1b97 | |
parent | 671a0ef77226a1eaa3e3128bcd3d760e996283db (diff) | |
download | nnn-b99a28a3761ee864fd3cf5150c49bc6c7ffc1f5a.tar.gz |
Fix #208: cut at correct codepoint for CJK
-rw-r--r-- | src/nnn.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1874,7 +1874,7 @@ static char *unescape(const char *str, uint maxcols) { static wchar_t wbuf[PATH_MAX] __attribute__ ((aligned)); static wchar_t *buf; - static size_t len; + static size_t len, lencount; /* Convert multi-byte to wide char */ len = mbstowcs(wbuf, str, PATH_MAX); @@ -1882,11 +1882,12 @@ static char *unescape(const char *str, uint maxcols) g_buf[0] = '\0'; buf = wbuf; - if (maxcols && len > maxcols) { - len = wcswidth(wbuf, len); - - if (len > maxcols) - wbuf[maxcols] = 0; + if (maxcols) { + len = lencount = wcswidth(wbuf, len); + while (len > maxcols) { + wbuf[--lencount] = L'\0'; + len = wcswidth(wbuf, lencount); + } } while (*buf) { @@ -2824,7 +2825,7 @@ static void redraw(char *path) /* Calculate the number of cols available to print entry name */ if (cfg.showdetail) - ncols -= 32; + ncols -= 30; else ncols -= 5; |