mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Minor refactor
This commit is contained in:
parent
06651f3f00
commit
90cf84186a
|
@ -28,7 +28,7 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/watch?v=AbaauM7gUJw
|
||||||
|
|
||||||
## Black magic! :dark_sunglasses:
|
## Black magic! :dark_sunglasses:
|
||||||
|
|
||||||
- Load, sort, filter thousands of files instantly
|
- Instantly load, sort, filter thousands of files
|
||||||
- Type to navigate with automatic dir selection
|
- Type to navigate with automatic dir selection
|
||||||
- Never lose context - start where you quit `nnn`
|
- Never lose context - start where you quit `nnn`
|
||||||
- find/fd/grep/ripgrep/fzf from `nnn` and list in `nnn`
|
- find/fd/grep/ripgrep/fzf from `nnn` and list in `nnn`
|
||||||
|
|
27
src/nnn.c
27
src/nnn.c
|
@ -5617,6 +5617,7 @@ nochange:
|
||||||
mkpath(path, pdents[cur].name, newpath);
|
mkpath(path, pdents[cur].name, newpath);
|
||||||
DPRINTF_S(newpath);
|
DPRINTF_S(newpath);
|
||||||
|
|
||||||
|
/* Visit directory */
|
||||||
if (pdents[cur].flags & DIR_OR_LINK_TO_DIR) {
|
if (pdents[cur].flags & DIR_OR_LINK_TO_DIR) {
|
||||||
if (chdir(newpath) == -1) {
|
if (chdir(newpath) == -1) {
|
||||||
printwarn(&presel);
|
printwarn(&presel);
|
||||||
|
@ -5634,9 +5635,12 @@ nochange:
|
||||||
}
|
}
|
||||||
DPRINTF_U(sb.st_mode);
|
DPRINTF_U(sb.st_mode);
|
||||||
|
|
||||||
switch (sb.st_mode & S_IFMT) {
|
/* Do not open non-regular files */
|
||||||
case S_IFREG:
|
if (!S_ISREG(sb.st_mode)) {
|
||||||
{
|
printwait(messages[MSG_UNSUPPORTED], &presel);
|
||||||
|
goto nochange;
|
||||||
|
}
|
||||||
|
|
||||||
/* If opened as vim plugin and Enter/^M pressed, pick */
|
/* If opened as vim plugin and Enter/^M pressed, pick */
|
||||||
if (g_state.picker && sel == SEL_GOIN) {
|
if (g_state.picker && sel == SEL_GOIN) {
|
||||||
appendfpath(newpath, mkpath(path, pdents[cur].name, newpath));
|
appendfpath(newpath, mkpath(path, pdents[cur].name, newpath));
|
||||||
|
@ -5664,8 +5668,11 @@ nochange:
|
||||||
? (presel = FILTER) : (watch = TRUE);
|
? (presel = FILTER) : (watch = TRUE);
|
||||||
xstrsncpy(lastname, pdents[cur].name, NAME_MAX + 1);
|
xstrsncpy(lastname, pdents[cur].name, NAME_MAX + 1);
|
||||||
goto begin;
|
goto begin;
|
||||||
} else if (cfg.nonavopen)
|
}
|
||||||
goto nochange; /* Open file disabled on right arrow or `l` */
|
|
||||||
|
/* Open file disabled on right arrow or `l` */
|
||||||
|
if (cfg.nonavopen)
|
||||||
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle plugin selection mode */
|
/* Handle plugin selection mode */
|
||||||
|
@ -5680,8 +5687,7 @@ nochange:
|
||||||
|
|
||||||
if (chdir(path) == -1
|
if (chdir(path) == -1
|
||||||
|| !run_selected_plugin(&path, pdents[cur].name,
|
|| !run_selected_plugin(&path, pdents[cur].name,
|
||||||
runfile, &lastname,
|
runfile, &lastname, &lastdir)) {
|
||||||
&lastdir)) {
|
|
||||||
DPRINTF_S("plugin failed!");
|
DPRINTF_S("plugin failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5699,7 +5705,7 @@ nochange:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg.useeditor
|
if (cfg.useeditor
|
||||||
#ifdef FILE_MIME_OPTS
|
#ifdef FILE_MIME
|
||||||
&& get_output(g_buf, CMD_LEN_MAX, "file", FILE_MIME_OPTS, newpath, FALSE)
|
&& get_output(g_buf, CMD_LEN_MAX, "file", FILE_MIME_OPTS, newpath, FALSE)
|
||||||
&& is_prefix(g_buf, "text/", 5)
|
&& is_prefix(g_buf, "text/", 5)
|
||||||
#else
|
#else
|
||||||
|
@ -5759,11 +5765,6 @@ nochange:
|
||||||
if (g_state.autonext && cur != ndents - 1)
|
if (g_state.autonext && cur != ndents - 1)
|
||||||
move_cursor((cur + 1) % ndents, 0);
|
move_cursor((cur + 1) % ndents, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
default:
|
|
||||||
printwait(messages[MSG_UNSUPPORTED], &presel);
|
|
||||||
goto nochange;
|
|
||||||
}
|
|
||||||
case SEL_NEXT: // fallthrough
|
case SEL_NEXT: // fallthrough
|
||||||
case SEL_PREV: // fallthrough
|
case SEL_PREV: // fallthrough
|
||||||
case SEL_PGDN: // fallthrough
|
case SEL_PGDN: // fallthrough
|
||||||
|
|
Loading…
Reference in a new issue