mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Optimize wide char conversion, show an extra char
This commit is contained in:
parent
b5654e3188
commit
eec6366272
17
src/nnn.c
17
src/nnn.c
|
@ -3424,8 +3424,10 @@ static wchar_t *unescape(const char *str, uint_t maxcols)
|
||||||
size_t lencount = 0;
|
size_t lencount = 0;
|
||||||
|
|
||||||
/* Convert multi-byte to wide char */
|
/* Convert multi-byte to wide char */
|
||||||
size_t len = mbstowcs(wbuf, str, NAME_MAX);
|
size_t len = mbstowcs(wbuf, str, maxcols);
|
||||||
|
|
||||||
|
if (len >= maxcols)
|
||||||
|
wbuf[maxcols] = '\0';
|
||||||
len = wcswidth(wbuf, len);
|
len = wcswidth(wbuf, len);
|
||||||
|
|
||||||
/* Reduce number of wide chars to max columns */
|
/* Reduce number of wide chars to max columns */
|
||||||
|
@ -3761,7 +3763,6 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
|
||||||
attroff(attrs);
|
attroff(attrs);
|
||||||
if (ind)
|
if (ind)
|
||||||
addch(ind);
|
addch(ind);
|
||||||
addch('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For the usage of comma operator in C, visit https://en.wikipedia.org/wiki/Comma_operator */
|
/* For the usage of comma operator in C, visit https://en.wikipedia.org/wiki/Comma_operator */
|
||||||
|
@ -5725,8 +5726,8 @@ static int adjust_cols(int n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3 = Preceding space, indicator, newline */
|
/* 2 columns for preceding space and indicator */
|
||||||
return (n - 3);
|
return (n - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_line(char *path, int ncols)
|
static void draw_line(char *path, int ncols)
|
||||||
|
@ -5770,7 +5771,7 @@ static void redraw(char *path)
|
||||||
|
|
||||||
int ncols = (xcols <= PATH_MAX) ? xcols : PATH_MAX;
|
int ncols = (xcols <= PATH_MAX) ? xcols : PATH_MAX;
|
||||||
int onscreen = xlines - 4;
|
int onscreen = xlines - 4;
|
||||||
int i;
|
int i, j = 1;
|
||||||
|
|
||||||
// Fast redraw
|
// Fast redraw
|
||||||
if (g_state.move) {
|
if (g_state.move) {
|
||||||
|
@ -5860,16 +5861,16 @@ static void redraw(char *path)
|
||||||
addch('^');
|
addch('^');
|
||||||
}
|
}
|
||||||
|
|
||||||
move(2, 0);
|
|
||||||
|
|
||||||
if (g_state.oldcolor) {
|
if (g_state.oldcolor) {
|
||||||
attron(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
|
attron(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
|
||||||
g_state.dircolor = 1;
|
g_state.dircolor = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print listing */
|
/* Print listing */
|
||||||
for (i = curscroll; i < ndents && i < curscroll + onscreen; ++i)
|
for (i = curscroll; i < ndents && i < curscroll + onscreen; ++i) {
|
||||||
|
move(++j, 0);
|
||||||
printptr(&pdents[i], ncols, i == cur);
|
printptr(&pdents[i], ncols, i == cur);
|
||||||
|
}
|
||||||
|
|
||||||
/* Must reset e.g. no files in dir */
|
/* Must reset e.g. no files in dir */
|
||||||
if (g_state.dircolor) {
|
if (g_state.dircolor) {
|
||||||
|
|
Loading…
Reference in a new issue