aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authordok <dok@grehack.fr>2019-01-06 18:42:49 +0100
committersin <sin@2f30.org>2019-01-19 17:30:23 +0000
commit4799ca8afd18a7443bdb4faff2ce2c5cd02b84e8 (patch)
tree9f6f4e25c11741f3abba7a5c85c565ede79c426d /noice.c
parent3ae2cb00d7db3a1aec7d0687bdc32c814d96581a (diff)
downloadnoice-4799ca8afd18a7443bdb4faff2ce2c5cd02b84e8.tar.gz
Add directory sorting
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/noice.c b/noice.c
index 67b14d9..beb3b4f 100644
--- a/noice.c
+++ b/noice.c
@@ -65,6 +65,7 @@ enum action {
SEL_CD,
SEL_CDHOME,
SEL_TOGGLEDOT,
+ SEL_DSORT,
SEL_MTIME,
SEL_ICASE,
SEL_REDRAW,
@@ -266,10 +267,28 @@ visible(regex_t *regex, char *file)
}
int
+dircmp(mode_t a, mode_t b)
+{
+ if (S_ISDIR(a) && S_ISDIR(b))
+ return 0;
+ if (!S_ISDIR(a) && !S_ISDIR(b))
+ return 0;
+ if (S_ISDIR(a))
+ return -1;
+ else
+ return 1;
+}
+
+int
entrycmp(const void *va, const void *vb)
{
const struct entry *a = va, *b = vb;
+ if (dirorder) {
+ if (dircmp(a->mode, b->mode) != 0)
+ return dircmp(a->mode, b->mode);
+ }
+
if (mtimeorder)
return b->t - a->t;
if (icaseorder)
@@ -801,6 +820,12 @@ nochange:
if (ndents > 0)
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
goto begin;
+ case SEL_DSORT:
+ dirorder = !dirorder;
+ /* Save current */
+ if (ndents > 0)
+ mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
+ goto begin;
case SEL_ICASE:
icaseorder = !icaseorder;
/* Save current */
Un proyecto texto-plano.xyz