add case insensitive patch

This commit is contained in:
stupidcomputer 2025-01-11 18:42:33 -06:00
parent 07d57cf2f5
commit bc3aad5943
2 changed files with 9 additions and 8 deletions

View File

@ -3,7 +3,7 @@
dmenu \- dynamic menu dmenu \- dynamic menu
.SH SYNOPSIS .SH SYNOPSIS
.B dmenu .B dmenu
.RB [ \-bFfiv ] .RB [ \-bFfsv ]
.RB [ \-l .RB [ \-l
.IR lines ] .IR lines ]
.RB [ \-m .RB [ \-m
@ -58,8 +58,8 @@ disables fuzzy matching.
dmenu grabs the keyboard before reading stdin if not reading from a tty. This dmenu grabs the keyboard before reading stdin if not reading from a tty. This
is faster, but will lock up X until stdin reaches end\-of\-file. is faster, but will lock up X until stdin reaches end\-of\-file.
.TP .TP
.B \-i .B \-s
dmenu matches menu items case insensitively. dmenu matches menu items case sensitively.
.TP .TP
.BI \-l " lines" .BI \-l " lines"
dmenu lists items vertically, with the given number of lines. dmenu lists items vertically, with the given number of lines.

11
dmenu.c
View File

@ -58,8 +58,9 @@ static Clr *scheme[SchemeLast];
#include "config.h" #include "config.h"
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; static char * cistrstr(const char *s, const char *sub);
static char *(*fstrstr)(const char *, const char *) = strstr; static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp;
static char *(*fstrstr)(const char *, const char *) = cistrstr;
static unsigned int static unsigned int
textw_clamp(const char *str, unsigned int n) textw_clamp(const char *str, unsigned int n)
@ -890,9 +891,9 @@ main(int argc, char *argv[])
fast = 1; fast = 1;
else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
centered = 1; centered = 1;
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ else if (!strcmp(argv[i], "-s")) { /* case sensitivity */
fstrncmp = strncasecmp; fstrncmp = strncmp;
fstrstr = cistrstr; fstrstr = strstr;
} else if (i + 1 == argc) } else if (i + 1 == argc)
usage(); usage();
/* these options take one argument */ /* these options take one argument */