Explorar el Código

Option to disable dir auto-select

master
Arun Prakash Jana hace 6 años
padre
commit
e454078571
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: A75979F35C080412
Se han modificado 3 ficheros con 31 adiciones y 18 borrados
  1. +3
    -1
      README.md
  2. +5
    -0
      nnn.1
  3. +23
    -17
      nnn.c

+ 3
- 1
README.md Ver fichero

@@ -278,7 +278,9 @@ If `nnn` is invoked as root or the environment variable `NNN_SHOW_HIDDEN` is set


In this mode directories are opened in filter mode, allowing continuous navigation. Works best with the **arrow keys**. In this mode directories are opened in filter mode, allowing continuous navigation. Works best with the **arrow keys**.


In case of only one match and it's a directory, `nnn` auto selects the directory and enters it in this mode.
In case of only one match and it's a directory, `nnn` auto selects the directory and enters it in this mode. To disable this behaviour,

export NNN_NO_AUTOSELECT=1


#### File indicators #### File indicators




+ 5
- 0
nnn.1 Ver fichero

@@ -282,6 +282,11 @@ for filenames having quote(s) in them.
.Bd -literal .Bd -literal
export NNN_SHOW_HIDDEN=1 export NNN_SHOW_HIDDEN=1
.Ed .Ed
.Pp
\fBNNN_NO_AUTOSELECT:\fR Disable directory auto-selection in \fInavigate-as-you-type\fR mode.
.Bd -literal
export export NNN_NO_AUTOSELECT=1
.Ed
.Sh KNOWN ISSUES .Sh KNOWN ISSUES
If you are using urxvt you might have to set backspace key to DEC. If you are using urxvt you might have to set backspace key to DEC.
.Sh AUTHORS .Sh AUTHORS


+ 23
- 17
nnn.c Ver fichero

@@ -241,26 +241,28 @@ typedef struct {


/* Settings */ /* Settings */
typedef struct { typedef struct {
ushort filtermode : 1; /* Set to enter filter mode */
ushort mtimeorder : 1; /* Set to sort by time modified */
ushort sizeorder : 1; /* Set to sort by file size */
ushort apparentsz : 1; /* Set to sort by apparent size (disk usage) */
ushort blkorder : 1; /* Set to sort by blocks used (disk usage) */
ushort showhidden : 1; /* Set to show hidden files */
ushort copymode : 1; /* Set when copying files */
ushort showdetail : 1; /* Clear to show fewer file info */
ushort showcolor : 1; /* Set to show dirs in blue */
ushort dircolor : 1; /* Current status of dir color */
ushort metaviewer : 1; /* Index of metadata viewer in utils[] */
ushort quote : 1; /* Copy paths within quotes */
ushort noxdisplay : 1; /* X11 is not available */
ushort color : 3; /* Color code for directories */
uint filtermode : 1; /* Set to enter filter mode */
uint mtimeorder : 1; /* Set to sort by time modified */
uint sizeorder : 1; /* Set to sort by file size */
uint apparentsz : 1; /* Set to sort by apparent size (disk usage) */
uint blkorder : 1; /* Set to sort by blocks used (disk usage) */
uint showhidden : 1; /* Set to show hidden files */
uint copymode : 1; /* Set when copying files */
uint autoselect : 1; /* Auto-select dir in nav-as-you-type mode */
uint showdetail : 1; /* Clear to show fewer file info */
uint showcolor : 1; /* Set to show dirs in blue */
uint dircolor : 1; /* Current status of dir color */
uint metaviewer : 1; /* Index of metadata viewer in utils[] */
uint quote : 1; /* Copy paths within quotes */
uint noxdisplay : 1; /* X11 is not available */
uint color : 3; /* Color code for directories */
uint reserved : 15;
} settings; } settings;


/* GLOBALS */ /* GLOBALS */


/* Configuration */ /* Configuration */
static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 4};
static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 4, 0};


static struct entry *dents; static struct entry *dents;
static char *pnamebuf, *pcopybuf; static char *pnamebuf, *pcopybuf;
@@ -1159,7 +1161,7 @@ filterentries(char *path)
continue; continue;


/* If the only match is a dir, auto-select and cd into it */ /* If the only match is a dir, auto-select and cd into it */
if (cfg.filtermode && ndents == 1 && S_ISDIR(dents[0].mode)) {
if (ndents == 1 && cfg.filtermode && cfg.autoselect && S_ISDIR(dents[0].mode)) {
*ch = KEY_ENTER; *ch = KEY_ENTER;
cur = 0; cur = 0;
goto end; goto end;
@@ -3500,12 +3502,16 @@ main(int argc, char *argv[])
g_tmpfplen = xstrlcpy(g_tmpfpath, "/tmp", MAX_HOME_LEN); g_tmpfplen = xstrlcpy(g_tmpfpath, "/tmp", MAX_HOME_LEN);


/* Check if X11 is available */ /* Check if X11 is available */
if (g_tmpfplen && getenv("NNN_NO_X")) {
if (!copier && g_tmpfplen && getenv("NNN_NO_X")) {
cfg.noxdisplay = 1; cfg.noxdisplay = 1;
xstrlcpy(g_cppath, g_tmpfpath, MAX_HOME_LEN); xstrlcpy(g_cppath, g_tmpfpath, MAX_HOME_LEN);
xstrlcpy(g_cppath + g_tmpfplen - 1, "/.nnncp", MAX_HOME_LEN - g_tmpfplen); xstrlcpy(g_cppath + g_tmpfplen - 1, "/.nnncp", MAX_HOME_LEN - g_tmpfplen);
} }


/* Disable auto-select if opted */
if (getenv("NNN_NO_AUTOSELECT"))
cfg.autoselect = 0;

signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);


/* Test initial path */ /* Test initial path */


Cargando…
Cancelar
Guardar