aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2015-01-31 22:02:59 +0000
committersin <sin@2f30.org>2015-01-31 22:02:59 +0000
commita63aac0b11c1bc8e54eed95f2fce6fd6dbb41ca8 (patch)
tree6f22018882a7eba4eae9ae6e4accfb6a552e4903 /noice.c
parent6735c1f9796a5d06d39ed78538d64a6ba26008f9 (diff)
downloadnoice-a63aac0b11c1bc8e54eed95f2fce6fd6dbb41ca8.tar.gz
Add 't' command to sort output by entry's mtime
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/noice.c b/noice.c
index 5358111..04115cf 100644
--- a/noice.c
+++ b/noice.c
@@ -56,6 +56,7 @@ enum action {
SEL_PGUP,
SEL_SH,
SEL_CD,
+ SEL_MTIME,
};
struct key {
@@ -68,8 +69,11 @@ struct key {
struct entry {
char *name;
mode_t mode;
+ time_t t;
};
+int mtimeorder;
+
/*
* Layout:
* .---------
@@ -231,6 +235,8 @@ entrycmp(const void *va, const void *vb)
a = (struct entry *)va;
b = (struct entry *)vb;
+ if (mtimeorder)
+ return b->t - a->t;
return strcmp(a->name, b->name);
}
@@ -487,6 +493,7 @@ dentfill(char *path, struct entry **dents,
if (r == -1)
printerr(1, "lstat");
(*dents)[n].mode = sb.st_mode;
+ (*dents)[n].t = sb.st_mtime;
n++;
}
@@ -809,6 +816,9 @@ moretyping:
filter = xstrdup(ifilter); /* Reset filter */
DPRINTF_S(path);
goto out;
+ case SEL_MTIME:
+ mtimeorder = !mtimeorder;
+ goto out;
}
}
Un proyecto texto-plano.xyz