mirror of
https://github.com/jarun/nnn.git
synced 2024-11-18 00:49:15 +00:00
Add bookmarknav patch
This commit is contained in:
parent
19b2ea324a
commit
fbd6f69f25
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -44,7 +44,7 @@ jobs:
|
||||||
CC: gcc
|
CC: gcc
|
||||||
run: |
|
run: |
|
||||||
export PATCH_OPTS="--merge"
|
export PATCH_OPTS="--merge"
|
||||||
patches=("O_GITSTATUS" "O_NAMEFIRST" "O_RESTOREPREVIEW")
|
patches=("O_BOOKMARKNAV" "O_GITSTATUS" "O_NAMEFIRST" "O_RESTOREPREVIEW")
|
||||||
z=$(( 1 << ${#patches[@]} ))
|
z=$(( 1 << ${#patches[@]} ))
|
||||||
for ((n=1; n < z; ++n)); do
|
for ((n=1; n < z; ++n)); do
|
||||||
for ((i=0; i < ${#patches[@]}; ++i)); do
|
for ((i=0; i < ${#patches[@]}; ++i)); do
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -31,6 +31,7 @@ O_MATCHFLTR := 0 # allow filters without matches
|
||||||
O_NOSORT := 0 # disable sorting entries on dir load
|
O_NOSORT := 0 # disable sorting entries on dir load
|
||||||
|
|
||||||
# User patches
|
# User patches
|
||||||
|
O_BOOKMARKNAV := 0 # enter/leave type-to-nav in bookmark/plugin dir
|
||||||
O_GITSTATUS := 0 # add git status to detail view
|
O_GITSTATUS := 0 # add git status to detail view
|
||||||
O_NAMEFIRST := 0 # print file name first, add uid and guid to detail view
|
O_NAMEFIRST := 0 # print file name first, add uid and guid to detail view
|
||||||
O_RESTOREPREVIEW := 0 # add preview pipe to close and restore preview pane
|
O_RESTOREPREVIEW := 0 # add preview pipe to close and restore preview pane
|
||||||
|
@ -163,6 +164,7 @@ DESKTOPFILE = misc/desktop/nnn.desktop
|
||||||
LOGOSVG = misc/logo/logo.svg
|
LOGOSVG = misc/logo/logo.svg
|
||||||
LOGO64X64 = misc/logo/logo-64x64.png
|
LOGO64X64 = misc/logo/logo-64x64.png
|
||||||
|
|
||||||
|
BOOKMARKNAV = patches/bookmarknav
|
||||||
GITSTATUS = patches/gitstatus
|
GITSTATUS = patches/gitstatus
|
||||||
NAMEFIRST = patches/namefirst
|
NAMEFIRST = patches/namefirst
|
||||||
RESTOREPREVIEW = patches/restorepreview
|
RESTOREPREVIEW = patches/restorepreview
|
||||||
|
@ -322,6 +324,9 @@ endif
|
||||||
ifeq ($(strip $(O_RESTOREPREVIEW)),1)
|
ifeq ($(strip $(O_RESTOREPREVIEW)),1)
|
||||||
patch --forward $(PATCH_OPTS) --strip=1 --input=$(RESTOREPREVIEW)/mainline.diff
|
patch --forward $(PATCH_OPTS) --strip=1 --input=$(RESTOREPREVIEW)/mainline.diff
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(strip $(O_BOOKMARKNAV)),1)
|
||||||
|
patch --forward $(PATCH_OPTS) --strip=1 --input=$(BOOKMARKNAV)/mainline.diff
|
||||||
|
endif
|
||||||
|
|
||||||
postpatch:
|
postpatch:
|
||||||
ifeq ($(strip $(O_NAMEFIRST)),1)
|
ifeq ($(strip $(O_NAMEFIRST)),1)
|
||||||
|
@ -335,6 +340,9 @@ endif
|
||||||
ifeq ($(strip $(O_RESTOREPREVIEW)),1)
|
ifeq ($(strip $(O_RESTOREPREVIEW)),1)
|
||||||
patch --reverse $(PATCH_OPTS) --strip=1 --input=$(RESTOREPREVIEW)/mainline.diff
|
patch --reverse $(PATCH_OPTS) --strip=1 --input=$(RESTOREPREVIEW)/mainline.diff
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(strip $(O_BOOKMARKNAV)),1)
|
||||||
|
patch --reverse $(PATCH_OPTS) --strip=1 --input=$(BOOKMARKNAV)/mainline.diff
|
||||||
|
endif
|
||||||
|
|
||||||
skip: ;
|
skip: ;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ The patches will be adapted on each release when necessary (v4.1 onwards). Each
|
||||||
|
|
||||||
| Patch (a-z) | Description | Make var |
|
| Patch (a-z) | Description | Make var |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
| bookmarknav | Enter/leave type-to-nav mode when entering/leaving bookmark and plugin dir. | `O_GITSTATUS` |
|
||||||
| gitstatus | Add git status column to the detail view. Provides command line flag `-G` to show column in normal mode. | `O_GITSTATUS` |
|
| gitstatus | Add git status column to the detail view. Provides command line flag `-G` to show column in normal mode. | `O_GITSTATUS` |
|
||||||
| namefirst | Print filenames first in the detail view. Print user/group columns when a directory contains different users/groups. | `O_NAMEFIRST` |
|
| namefirst | Print filenames first in the detail view. Print user/group columns when a directory contains different users/groups. | `O_NAMEFIRST` |
|
||||||
| restorepreview | Add pipe to close and restore [`preview-tui`](https://github.com/jarun/nnn/blob/master/plugins/preview-tui) for internal undetached edits (<kbd>e</kbd> key)| `O_RESTOREPREVIEW` |
|
| restorepreview | Add pipe to close and restore [`preview-tui`](https://github.com/jarun/nnn/blob/master/plugins/preview-tui) for internal undetached edits (<kbd>e</kbd> key)| `O_RESTOREPREVIEW` |
|
||||||
|
|
69
patches/bookmarknav/mainline.diff
Normal file
69
patches/bookmarknav/mainline.diff
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
# Description: Enter and exit type-to-nav mode when entering/leaving
|
||||||
|
# bookmark and plugin directory through <b/;(Enter)>.
|
||||||
|
# Allows for more seamless bookmark navigation.
|
||||||
|
#
|
||||||
|
# Author: Luuk van Baal
|
||||||
|
|
||||||
|
diff --git a/src/nnn.c b/src/nnn.c
|
||||||
|
index 1465f4ab..fda99616 100644
|
||||||
|
--- a/src/nnn.c
|
||||||
|
+++ b/src/nnn.c
|
||||||
|
@@ -368,6 +368,7 @@ typedef struct {
|
||||||
|
uint_t runctx : 3; /* The context in which plugin is to be run */
|
||||||
|
uint_t runplugin : 1; /* Choose plugin mode */
|
||||||
|
uint_t selbm : 1; /* Select a bookmark from bookmarks directory */
|
||||||
|
+ uint_t filtermode : 2; /* Store type-to-nav when entering plugin/bookmarks directory */
|
||||||
|
uint_t selmode : 1; /* Set when selecting files */
|
||||||
|
uint_t stayonsel : 1; /* Disable auto-jump on select */
|
||||||
|
uint_t trash : 2; /* Trash method 0: rm -rf, 1: trash-cli, 2: gio trash */
|
||||||
|
@@ -3446,8 +3447,8 @@ static int filterentries(char *path, char *lastname)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the only match is a dir, auto-enter and cd into it */
|
||||||
|
- if (ndents == 1 && cfg.filtermode
|
||||||
|
- && cfg.autoenter && (pdents[0].flags & DIR_OR_DIRLNK)) {
|
||||||
|
+ if (ndents == 1 && cfg.autoenter && (((pdents[0].flags & DIR_OR_DIRLNK) &&
|
||||||
|
+ cfg.filtermode) || (g_state.selbm || g_state.runplugin))) {
|
||||||
|
*ch = KEY_ENTER;
|
||||||
|
cur = 0;
|
||||||
|
goto end;
|
||||||
|
@@ -4988,14 +4989,14 @@ static size_t handle_bookmark(const char *bmark, char *newpath)
|
||||||
|
bmark ? xstrsncpy(newpath, bmark, PATH_MAX) : (r = MSG_NOT_SET);
|
||||||
|
else if (fd == '\r') { /* Visit bookmarks directory */
|
||||||
|
mkpath(cfgpath, toks[TOK_BM], newpath);
|
||||||
|
- g_state.selbm = 1;
|
||||||
|
+ g_state.filtermode = cfg.filtermode + 1;
|
||||||
|
+ g_state.selbm = cfg.filtermode = 1;
|
||||||
|
} else if (!get_kv_val(bookmark, newpath, fd, maxbm, NNN_BMS))
|
||||||
|
r = MSG_INVALID_KEY;
|
||||||
|
|
||||||
|
if (!r && chdir(newpath) == -1) {
|
||||||
|
r = MSG_ACCESS;
|
||||||
|
- if (g_state.selbm)
|
||||||
|
- g_state.selbm = 0;
|
||||||
|
+ g_state.selbm = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
@@ -6680,6 +6681,12 @@ begin:
|
||||||
|
setdirwatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (g_state.filtermode) {
|
||||||
|
+ cfg.filtermode = g_state.filtermode - 1;
|
||||||
|
+ if (!g_state.selbm)
|
||||||
|
+ g_state.filtermode = 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
#ifndef NOX11
|
||||||
|
xterm_cfg(path);
|
||||||
|
#endif
|
||||||
|
@@ -7769,6 +7776,8 @@ nochange:
|
||||||
|
g_state.runplugin = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ g_state.filtermode = cfg.filtermode + 1;
|
||||||
|
+ cfg.filtermode = 1;
|
||||||
|
xstrsncpy(lastdir, path, PATH_MAX);
|
||||||
|
xstrsncpy(path, plgpath, PATH_MAX);
|
||||||
|
if (ndents)
|
Loading…
Reference in a new issue