mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Fix #208: cut at correct codepoint for CJK
This commit is contained in:
parent
671a0ef772
commit
b99a28a376
15
src/nnn.c
15
src/nnn.c
|
@ -1874,7 +1874,7 @@ static char *unescape(const char *str, uint maxcols)
|
||||||
{
|
{
|
||||||
static wchar_t wbuf[PATH_MAX] __attribute__ ((aligned));
|
static wchar_t wbuf[PATH_MAX] __attribute__ ((aligned));
|
||||||
static wchar_t *buf;
|
static wchar_t *buf;
|
||||||
static size_t len;
|
static size_t len, lencount;
|
||||||
|
|
||||||
/* Convert multi-byte to wide char */
|
/* Convert multi-byte to wide char */
|
||||||
len = mbstowcs(wbuf, str, PATH_MAX);
|
len = mbstowcs(wbuf, str, PATH_MAX);
|
||||||
|
@ -1882,11 +1882,12 @@ static char *unescape(const char *str, uint maxcols)
|
||||||
g_buf[0] = '\0';
|
g_buf[0] = '\0';
|
||||||
buf = wbuf;
|
buf = wbuf;
|
||||||
|
|
||||||
if (maxcols && len > maxcols) {
|
if (maxcols) {
|
||||||
len = wcswidth(wbuf, len);
|
len = lencount = wcswidth(wbuf, len);
|
||||||
|
while (len > maxcols) {
|
||||||
if (len > maxcols)
|
wbuf[--lencount] = L'\0';
|
||||||
wbuf[maxcols] = 0;
|
len = wcswidth(wbuf, lencount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*buf) {
|
while (*buf) {
|
||||||
|
@ -2824,7 +2825,7 @@ static void redraw(char *path)
|
||||||
|
|
||||||
/* Calculate the number of cols available to print entry name */
|
/* Calculate the number of cols available to print entry name */
|
||||||
if (cfg.showdetail)
|
if (cfg.showdetail)
|
||||||
ncols -= 32;
|
ncols -= 30;
|
||||||
else
|
else
|
||||||
ncols -= 5;
|
ncols -= 5;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue