mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Minor changes to fast redraw
This commit is contained in:
parent
7948db6a64
commit
917123c400
|
@ -30,6 +30,7 @@ It runs smoothly on the Raspberry Pi, Termux [on Android](https://www.youtube.co
|
||||||
- Works with 8-bit colors
|
- Works with 8-bit colors
|
||||||
- Disk-IO sensitive (few disk reads and writes)
|
- Disk-IO sensitive (few disk reads and writes)
|
||||||
- No FPU usage (all integer calculations, even for file size)
|
- No FPU usage (all integer calculations, even for file size)
|
||||||
|
- Minimizes screen refresh with fast line redraws
|
||||||
- Portable
|
- Portable
|
||||||
- Minimal library deps, easily compilable, tiny binary
|
- Minimal library deps, easily compilable, tiny binary
|
||||||
- No config file, minimal config with sensible defaults
|
- No config file, minimal config with sensible defaults
|
||||||
|
|
63
src/nnn.c
63
src/nnn.c
|
@ -337,7 +337,6 @@ static kv plug[PLUGIN_MAX];
|
||||||
static uchar g_tmpfplen;
|
static uchar g_tmpfplen;
|
||||||
static uchar blk_shift = BLK_SHIFT_512;
|
static uchar blk_shift = BLK_SHIFT_512;
|
||||||
static regex_t archive_re;
|
static regex_t archive_re;
|
||||||
static bool is_move_op = FALSE;
|
|
||||||
|
|
||||||
/* Retain old signal handlers */
|
/* Retain old signal handlers */
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -364,6 +363,7 @@ static char g_pipepath[TMP_LEN_MAX] __attribute__ ((aligned));
|
||||||
#define STATE_PLUGIN_INIT 0x1
|
#define STATE_PLUGIN_INIT 0x1
|
||||||
#define STATE_INTERRUPTED 0x2
|
#define STATE_INTERRUPTED 0x2
|
||||||
#define STATE_RANGESEL 0x4
|
#define STATE_RANGESEL 0x4
|
||||||
|
#define STATE_MOVE_OP 0x8
|
||||||
|
|
||||||
static uchar g_states;
|
static uchar g_states;
|
||||||
|
|
||||||
|
@ -656,7 +656,7 @@ static char *xitoa(uint val)
|
||||||
static void clearinfoln(void)
|
static void clearinfoln(void)
|
||||||
{
|
{
|
||||||
move(xlines - 2, 0);
|
move(xlines - 2, 0);
|
||||||
clrtoeol();
|
addch('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KEY_RESIZE
|
#ifdef KEY_RESIZE
|
||||||
|
@ -665,7 +665,7 @@ static void clearoldprompt(void)
|
||||||
{
|
{
|
||||||
clearinfoln();
|
clearinfoln();
|
||||||
tolastln();
|
tolastln();
|
||||||
clrtoeol();
|
addch('\n');
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4287,22 +4287,11 @@ static void statusbar(char *path)
|
||||||
sort, buf, get_lsperms(pent->mode), coolsize(pent->size), ptr, fname);
|
sort, buf, get_lsperms(pent->mode), coolsize(pent->size), ptr, fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
clrtoeol();
|
addch('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
static void redraw(char *path)
|
static int adjust_cols(int ncols)
|
||||||
{
|
{
|
||||||
xlines = LINES;
|
|
||||||
xcols = COLS;
|
|
||||||
|
|
||||||
int ncols = (xcols <= PATH_MAX) ? xcols : PATH_MAX;
|
|
||||||
int onscreen = xlines - 4;
|
|
||||||
int i;
|
|
||||||
char *ptr = path;
|
|
||||||
|
|
||||||
// Fast redraw
|
|
||||||
if (is_move_op && last_curscroll == curscroll) {
|
|
||||||
is_move_op = FALSE;
|
|
||||||
/* 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) {
|
||||||
/* Fallback to light mode if less than 35 columns */
|
/* Fallback to light mode if less than 35 columns */
|
||||||
|
@ -4318,6 +4307,13 @@ static void redraw(char *path)
|
||||||
attron(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
|
attron(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
|
||||||
cfg.dircolor = 1;
|
cfg.dircolor = 1;
|
||||||
|
|
||||||
|
return ncols;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_line(char *path, int ncols)
|
||||||
|
{
|
||||||
|
ncols = adjust_cols(ncols);
|
||||||
|
|
||||||
move(2 + last - curscroll, 0);
|
move(2 + last - curscroll, 0);
|
||||||
printptr(&dents[last], ncols, false);
|
printptr(&dents[last], ncols, false);
|
||||||
move(2 + cur - curscroll, 0);
|
move(2 + cur - curscroll, 0);
|
||||||
|
@ -4333,6 +4329,24 @@ static void redraw(char *path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void redraw(char *path)
|
||||||
|
{
|
||||||
|
xlines = LINES;
|
||||||
|
xcols = COLS;
|
||||||
|
|
||||||
|
int ncols = (xcols <= PATH_MAX) ? xcols : PATH_MAX;
|
||||||
|
int onscreen = xlines - 4;
|
||||||
|
int i;
|
||||||
|
char *ptr = path;
|
||||||
|
|
||||||
|
// Fast redraw
|
||||||
|
if (g_states & STATE_MOVE_OP) {
|
||||||
|
g_states &= ~STATE_MOVE_OP;
|
||||||
|
|
||||||
|
if (last_curscroll == curscroll)
|
||||||
|
return draw_line(path, ncols);
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear screen */
|
/* Clear screen */
|
||||||
erase();
|
erase();
|
||||||
|
|
||||||
|
@ -4401,20 +4415,7 @@ static void redraw(char *path)
|
||||||
|
|
||||||
attroff(A_UNDERLINE);
|
attroff(A_UNDERLINE);
|
||||||
|
|
||||||
/* Calculate the number of cols available to print entry name */
|
ncols = adjust_cols(ncols);
|
||||||
if (cfg.showdetail) {
|
|
||||||
/* Fallback to light mode if less than 35 columns */
|
|
||||||
if (ncols < 36) {
|
|
||||||
cfg.showdetail ^= 1;
|
|
||||||
printptr = &printent;
|
|
||||||
ncols -= 3; /* Preceding space, indicator, newline */
|
|
||||||
} else
|
|
||||||
ncols -= 35;
|
|
||||||
} else
|
|
||||||
ncols -= 3; /* Preceding space, indicator, newline */
|
|
||||||
|
|
||||||
attron(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
|
|
||||||
cfg.dircolor = 1;
|
|
||||||
|
|
||||||
/* Print listing */
|
/* Print listing */
|
||||||
for (i = curscroll; i < ndents && i < curscroll + onscreen; ++i)
|
for (i = curscroll; i < ndents && i < curscroll + onscreen; ++i)
|
||||||
|
@ -4802,7 +4803,7 @@ nochange:
|
||||||
case SEL_HOME: // fallthrough
|
case SEL_HOME: // fallthrough
|
||||||
case SEL_END: // fallthrough
|
case SEL_END: // fallthrough
|
||||||
case SEL_FIRST:
|
case SEL_FIRST:
|
||||||
is_move_op = TRUE;
|
g_states |= STATE_MOVE_OP;
|
||||||
handle_screen_move(sel);
|
handle_screen_move(sel);
|
||||||
break;
|
break;
|
||||||
case SEL_CDHOME: // fallthrough
|
case SEL_CDHOME: // fallthrough
|
||||||
|
|
Loading…
Reference in a new issue