mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Show directories first
This commit is contained in:
parent
0e82544199
commit
951d323616
|
@ -54,11 +54,12 @@ I chose to fork because:
|
||||||
- current item in reverse video
|
- current item in reverse video
|
||||||
- number of items in current directory
|
- number of items in current directory
|
||||||
- full name of currently selected file
|
- full name of currently selected file
|
||||||
|
- Directories first
|
||||||
|
- Sort numeric names in numeric order
|
||||||
- Case-insensitive alphabetic content listing instead of upper case first
|
- Case-insensitive alphabetic content listing instead of upper case first
|
||||||
- Roll over at the first and last entries of a directory (with Up/Down keys)
|
- Roll over at the first and last entries of a directory (with Up/Down keys)
|
||||||
- Removed navigation restriction with relative paths (and let permissions handle it)
|
- Removed navigation restriction with relative paths (and let permissions handle it)
|
||||||
- Sort entries by file size (largest to smallest)
|
- Sort entries by file size (largest to smallest)
|
||||||
- Sort numeric names in numeric order
|
|
||||||
- Shortcut to invoke file name copier (set using environment variable `NNN_COPIER`)
|
- Shortcut to invoke file name copier (set using environment variable `NNN_COPIER`)
|
||||||
- File associations
|
- File associations
|
||||||
- Environment variable `NNN_OPENER` to let desktop opener handle it all. E.g.:
|
- Environment variable `NNN_OPENER` to let desktop opener handle it all. E.g.:
|
||||||
|
|
18
nnn.c
18
nnn.c
|
@ -395,13 +395,25 @@ visible(regex_t *regex, char *file)
|
||||||
static int
|
static int
|
||||||
entrycmp(const void *va, const void *vb)
|
entrycmp(const void *va, const void *vb)
|
||||||
{
|
{
|
||||||
|
static pEntry pa, pb;
|
||||||
|
|
||||||
|
pa = (pEntry)va;
|
||||||
|
pb = (pEntry)vb;
|
||||||
|
|
||||||
|
/* Sort directories first */
|
||||||
|
if (S_ISDIR(pb->mode) && !S_ISDIR(pa->mode))
|
||||||
|
return 1;
|
||||||
|
else if (S_ISDIR(pa->mode) && !S_ISDIR(pb->mode))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Do the actual sorting */
|
||||||
if (mtimeorder)
|
if (mtimeorder)
|
||||||
return ((pEntry)vb)->t - ((pEntry)va)->t;
|
return pb->t - pa->t;
|
||||||
|
|
||||||
if (sizeorder)
|
if (sizeorder)
|
||||||
return ((pEntry)vb)->size - ((pEntry)va)->size;
|
return pb->size - pa->size;
|
||||||
|
|
||||||
return xstricmp(((pEntry)va)->name, ((pEntry)vb)->name);
|
return xstricmp(pa->name, pb->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue