diff options
Diffstat (limited to 'src/nnn.c')
-rw-r--r-- | src/nnn.c | 41 |
1 files changed, 30 insertions, 11 deletions
@@ -285,7 +285,7 @@ typedef struct { uint dircolor : 1; /* Current status of dir color */ uint metaviewer : 1; /* Index of metadata viewer in utils[] */ uint ctxactive : 1; /* Context active or not */ - uint reserved : 8; + uint reserved : 7; /* The following settings are global */ uint curctx : 2; /* Current context number */ uint picker : 1; /* Write selection to user-specified file */ @@ -296,6 +296,7 @@ typedef struct { uint runctx : 2; /* The context in which script is to be run */ uint restrict0b : 1; /* Restrict 0-byte file opening */ uint filter_re : 1; /* Use regex filters */ + uint wild : 1; /* Do not sort entries on dir load */ } settings; /* Contexts or workspaces */ @@ -311,7 +312,7 @@ typedef struct { /* GLOBALS */ /* Configuration, contexts */ -static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +static settings cfg = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}; static context g_ctx[CTX_MAX] __attribute__ ((aligned)); static struct entry *dents; @@ -2443,7 +2444,7 @@ static bool show_help(char *path) "ce Edit in EDITOR p Open in PAGER\n" "1ORDER TOGGLES\n" "b^J Disk usage S Apparent du\n" - "ct Time modified s Size\n" + "b^W Random s Size t Time modified\n" "1MISC\n" "9! ^] Spawn SHELL C Execute entry\n" "9R ^V Run/pick script L Lock terminal\n" @@ -2727,7 +2728,8 @@ static void populate(char *path, char *lastname) if (!ndents) return; - qsort(dents, ndents, sizeof(*dents), entrycmp); + if (!cfg.wild) + qsort(dents, ndents, sizeof(*dents), entrycmp); #ifdef DBGMODE clock_gettime(CLOCK_REALTIME, &ts2); @@ -2834,7 +2836,7 @@ static void redraw(char *path) else ncols -= 5; - if (cfg.showcolor) { + if (!cfg.wild && cfg.showcolor) { attron(COLOR_PAIR(cfg.curctx + 1) | A_BOLD); cfg.dircolor = 1; } @@ -3301,6 +3303,7 @@ nochange: } #endif presel = filterentries(path); + /* Save current */ if (ndents) copycurname(); @@ -3311,7 +3314,8 @@ nochange: case SEL_FSIZE: // fallthrough case SEL_ASIZE: // fallthrough case SEL_BSIZE: // fallthrough - case SEL_MTIME: + case SEL_MTIME: // fallthrough + case SEL_WILD: switch (sel) { case SEL_MFLTR: cfg.filtermode ^= 1; @@ -3336,6 +3340,7 @@ nochange: cfg.apparentsz = 0; cfg.blkorder = 0; cfg.copymode = 0; + cfg.wild = 0; break; case SEL_ASIZE: cfg.apparentsz ^= 1; @@ -3344,8 +3349,7 @@ nochange: cfg.blkorder = 1; BLK_SHIFT = 0; } else - cfg.blkorder = 0; - break; + cfg.blkorder = 0; // fallthrough case SEL_BSIZE: if (sel == SEL_BSIZE) { if (!cfg.apparentsz) @@ -3362,14 +3366,25 @@ nochange: cfg.mtimeorder = 0; cfg.sizeorder = 0; cfg.copymode = 0; + cfg.wild = 0; break; - default: /* SEL_MTIME */ + case SEL_MTIME: cfg.mtimeorder ^= 1; cfg.sizeorder = 0; cfg.apparentsz = 0; cfg.blkorder = 0; cfg.copymode = 0; + cfg.wild = 0; break; + default: /* SEL_WILD */ + cfg.wild ^= 1; + cfg.mtimeorder = 0; + cfg.sizeorder = 0; + cfg.apparentsz = 0; + cfg.blkorder = 0; + cfg.copymode = 0; + setdirwatch(); + goto nochange; } /* Save current */ @@ -4013,7 +4028,7 @@ static void usage(void) { fprintf(stdout, "%s: nnn [-b key] [-C] [-e] [-i] [-l] [-n]\n" - " [-p file] [-s] [-S] [-v] [-h] [PATH]\n\n" + " [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]\n\n" "The missing terminal file manager for X.\n\n" "positional args:\n" " PATH start dir [default: current dir]\n\n" @@ -4028,6 +4043,7 @@ static void usage(void) " -s string filters [default: regex]\n" " -S du mode\n" " -v show version\n" + " -w wild mode\n" " -h show help\n\n" "v%s\n%s\n", __func__, VERSION, GENERAL_INFO); } @@ -4038,7 +4054,7 @@ int main(int argc, char *argv[]) char *ipath = NULL; int opt; - while ((opt = getopt(argc, argv, "Slib:Cenp:svh")) != -1) { + while ((opt = getopt(argc, argv, "Slib:Cenp:svwh")) != -1) { switch (opt) { case 'S': cfg.blkorder = 1; @@ -4084,6 +4100,9 @@ int main(int argc, char *argv[]) case 'v': fprintf(stdout, "%s\n", VERSION); return 0; + case 'w': + cfg.wild = 1; + break; case 'h': usage(); return 0; |