Add case insensitive comparison - noice - small file browser (mirror / fork from 2f30.org) (HTM) git clone git://git.codemadness.org/noice (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 3ae2cb00d7db3a1aec7d0687bdc32c814d96581a (DIR) parent 383abc8aa9265f3a81142973106dcaeaded63e85 (HTM) Author: dok <dok@grehack.fr> Date: Sun, 6 Jan 2019 16:38:13 +0100 Add case insensitive comparison Diffstat: M config.def.h | 3 +++ M noice.1 | 2 ++ M noice.c | 12 +++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) --- (DIR) 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" }, (DIR) 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 \&! (DIR) 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)