noice

small file browser
git clone git://git.2f30.org/noice.git
Log | Files | Refs | README | LICENSE

commit 3ae2cb00d7db3a1aec7d0687bdc32c814d96581a
parent 383abc8aa9265f3a81142973106dcaeaded63e85
Author: dok <dok@grehack.fr>
Date:   Sun,  6 Jan 2019 16:38:13 +0100

Add case insensitive comparison

Diffstat:
Mconfig.def.h | 3+++
Mnoice.1 | 2++
Mnoice.c | 12+++++++++++-
3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/config.def.h b/config.def.h @@ -4,6 +4,7 @@ #define EMPTY " " int mtimeorder = 0; /* Set to 1 to sort by time modified */ +int icaseorder = 0; /* Set to 1 to sort by ignoring case */ int idletimeout = 0; /* Screensaver timeout in seconds, 0 to disable */ int showhidden = 0; /* Set to 1 to show hidden files by default */ char *idlecmd = "rain"; /* The screensaver program */ @@ -80,6 +81,8 @@ struct key bindings[] = { { '.', SEL_TOGGLEDOT }, /* Toggle sort by time */ { 't', SEL_MTIME }, + /* Toggle case sensitivity */ + { 'i', SEL_ICASE }, { CONTROL('L'), SEL_REDRAW }, /* Run command */ { 'z', SEL_RUN, "top" }, diff --git a/noice.1 b/noice.1 @@ -59,6 +59,8 @@ directory. Toggle hidden .dot files. .It Ic t Toggle sort by time modified. +.It Ic i +Toggle case sensitive sort. .It Ic C-l Force a redraw. .It Ic \&! diff --git a/noice.c b/noice.c @@ -66,6 +66,7 @@ enum action { SEL_CDHOME, SEL_TOGGLEDOT, SEL_MTIME, + SEL_ICASE, SEL_REDRAW, SEL_RUN, SEL_RUNARG, @@ -271,7 +272,10 @@ entrycmp(const void *va, const void *vb) if (mtimeorder) return b->t - a->t; - return strcmp(a->name, b->name); + if (icaseorder) + return strcasecmp(a->name, b->name); + else + return strcmp(a->name, b->name); } void @@ -797,6 +801,12 @@ nochange: if (ndents > 0) mkpath(path, dents[cur].name, oldpath, sizeof(oldpath)); goto begin; + case SEL_ICASE: + icaseorder = !icaseorder; + /* Save current */ + if (ndents > 0) + mkpath(path, dents[cur].name, oldpath, sizeof(oldpath)); + goto begin; case SEL_REDRAW: /* Save current */ if (ndents > 0)