diff options
| author | 2018-11-27 00:24:12 +0530 | |
|---|---|---|
| committer | 2018-11-27 02:06:57 +0530 | |
| commit | 7db777756f994a8d121f7fa2f8fce6b9a8da16e3 (patch) | |
| tree | e487d26d4f859e81d0225e3d928525a048db1fde /src | |
| parent | c3b2ace9fd10389ed09a6664b34fd528da22f281 (diff) | |
| download | nnn-7db777756f994a8d121f7fa2f8fce6b9a8da16e3.tar.gz | |
Option to disable file open on Right and `l`
Diffstat (limited to 'src')
| -rw-r--r-- | src/nnn.c | 22 | ||||
| -rw-r--r-- | src/nnn.h | 5 |
2 files changed, 21 insertions, 6 deletions
@@ -261,11 +261,12 @@ typedef struct { uint quote : 1; /* Copy paths within quotes */ uint color : 3; /* Color code for directories */ uint ctxactive : 1; /* Context active or not */ - uint reserved : 11; + uint reserved : 10; /* The following settings are global */ uint curctx : 2; /* Current context number */ uint picker : 1; /* Write selection to user-specified file */ uint pickraw : 1; /* Write selection to sdtout before exit */ + uint nonavopen : 1; /* Open file on right arrow or `l` */ } settings; /* Contexts or workspaces */ @@ -281,7 +282,7 @@ typedef struct { /* GLOBALS */ /* Configuration, contexts */ -static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 4, 1, 0, 0, 0, 0}; +static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0}; static context g_ctx[MAX_CTX] __attribute__ ((aligned)); static struct entry *dents; @@ -2040,9 +2041,13 @@ static int show_help(char *path) if (getenv("NNN_SCRIPT")) dprintf(fd, "NNN_SCRIPT: %s\n", getenv("NNN_SCRIPT")); if (getenv("NNN_MULTISCRIPT")) - dprintf(fd, "NNN_MULTISCRIPT: %s\n", getenv("NNN_MULTISCRIPT")); + dprintf(fd, "NNN_MULTISCRIPT: 1\n"); if (getenv("NNN_SHOW_HIDDEN")) - dprintf(fd, "NNN_SHOW_HIDDEN: %s\n", getenv("NNN_SHOW_HIDDEN")); + dprintf(fd, "NNN_SHOW_HIDDEN: 1\n"); + if (getenv("NNN_NO_AUTOSELECT")) + dprintf(fd, "NNN_NO_AUTOSELECT: 1\n"); + if (getenv("DISABLE_FILE_OPEN_ON_NAV")) + dprintf(fd, "DISABLE_FILE_OPEN_ON_NAV: 1\n"); dprintf(fd, "\n"); @@ -2574,6 +2579,7 @@ nochange: setdirwatch(); goto begin; + case SEL_NAV_IN: // fallthrough case SEL_GOIN: /* Cannot descend in empty directories */ if (!ndents) @@ -2612,6 +2618,10 @@ nochange: goto begin; case S_IFREG: { + /* If open file is disabled on right arrow or `l`, return */ + if (cfg.nonavopen && sel == SEL_NAV_IN) + continue; + /* If NNN_USE_EDITOR is set, * open text in EDITOR */ @@ -3573,6 +3583,10 @@ int main(int argc, char *argv[]) if (getenv("NNN_NO_AUTOSELECT")) cfg.autoselect = 0; + /* Disable opening files on right arrow and `l` */ + if (getenv("DISABLE_FILE_OPEN_ON_NAV")) + cfg.nonavopen = 1; + signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); @@ -38,6 +38,7 @@ enum action { SEL_BACK = 1, SEL_GOIN, + SEL_NAV_IN, SEL_NEXT, SEL_PREV, SEL_PGDN, @@ -117,8 +118,8 @@ static struct key bindings[] = { /* Inside */ { KEY_ENTER, SEL_GOIN, "", "" }, { '\r', SEL_GOIN, "", "" }, - { KEY_RIGHT, SEL_GOIN, "", "" }, - { 'l', SEL_GOIN, "", "" }, + { KEY_RIGHT, SEL_NAV_IN, "", "" }, + { 'l', SEL_NAV_IN, "", "" }, /* Next */ { 'j', SEL_NEXT, "", "" }, { KEY_DOWN, SEL_NEXT, "", "" }, |