move arguments around

This commit is contained in:
speedie 2023-03-16 16:01:53 +01:00
parent 7462aba7fc
commit 81f26de355
3 changed files with 148 additions and 138 deletions

View file

@ -57,7 +57,7 @@ See a list below for a list.
- spmenu -nso - Don't sort matches
- spmenu -pri priority - Specify a list of items that take priority
- spmenu -s - Use case-sensitive matching
- spmenu -i - Use case-insensitive matching
- spmenu -ns - Use case-insensitive matching
- spmenu -nm - Start spmenu in normal mode
- spmenu -im - Start spmenu in insert mode
- spmenu -t - Position spmenu at the top of the screen
@ -148,6 +148,7 @@ See a list below for a list.
There are also extra arguments recognized for dmenu compatibility. These are:
- spmenu -i - Use case-insensitive matching
- spmenu -S - Don't sort matches
- spmenu -nb color - Set the normal background color
- spmenu -nf color - Set the normal foreground color

View file

@ -4,19 +4,20 @@ readargs(int argc, char *argv[])
int i = 0;
int j = 0;
// check if we should load the xrdb/config, because it needs to be loaded before arguments are checked (internal -> xresources -> arguments)
for (j = 1; j < argc; j++) {
/* xrdb first as it overrides other options */
if (!strcmp(argv[j], "-xrdb")) { /* xresources */
if (!strcmp(argv[j], "-xrdb")) {
xresources = 1;
} else if (!strcmp(argv[j], "-nxrdb")) { /* no xresources */
} else if (!strcmp(argv[j], "-nxrdb")) {
xresources = 0;
} else if (!strcmp(argv[j], "-lcfg")) { /* load config */
} else if (!strcmp(argv[j], "-lcfg")) {
loadconfig = 1;
} else if (!strcmp(argv[j], "-ncfg")) { /* don't load config */
} else if (!strcmp(argv[j], "-ncfg")) {
loadconfig = 0;
}
}
// init/read xrdb
if (xresources) {
XrmInitialize();
@ -28,113 +29,106 @@ readargs(int argc, char *argv[])
load_xresources();
}
if (casesensitive) {
fstrncmp = strncmp;
fstrstr = strstr;
}
/* these options take no arguments */
// no arguments
for (i = 1; i < argc; i++)
if (!strcmp(argv[i], "-v")) { /* prints version information */
if (!strcmp(argv[i], "-v")) { // prints version information
puts("spmenu-"VERSION);
exit(0);
} else if (!strcmp(argv[i], "-h")) { /* help */
} else if (!strcmp(argv[i], "-h")) { // help
usage();
} else if (!strcmp(argv[i], "-it")) { /* image: top */
} else if (!strcmp(argv[i], "-it")) { // image: top
imageposition = 0;
} else if (!strcmp(argv[i], "-ib")) { /* image: bottom */
} else if (!strcmp(argv[i], "-ib")) { // image: bottom
imageposition = 1;
} else if (!strcmp(argv[i], "-ic")) { /* image: center */
} else if (!strcmp(argv[i], "-ic")) { // image: center
imageposition = 2;
} else if (!strcmp(argv[i], "-itc")) { /* image: top center */
} else if (!strcmp(argv[i], "-itc")) { // image: top center
imageposition = 3;
} else if (!strcmp(argv[i], "-b")) { /* appears at the bottom of the screen */
} else if (!strcmp(argv[i], "-b")) { // appears at the bottom of the screen
menuposition = 0;
} else if (!strcmp(argv[i], "-t")) { /* appears at the top of the screen */
} else if (!strcmp(argv[i], "-t")) { // appears at the top of the screen
menuposition = 1;
} else if (!strcmp(argv[i], "-nm")) { /* normal mode */
} else if (!strcmp(argv[i], "-nm")) { // normal mode
mode = 0;
} else if (!strcmp(argv[i], "-im")) { /* insert mode */
} else if (!strcmp(argv[i], "-im")) { // insert mode
mode = 1;
} else if (!strcmp(argv[i], "-c")) { /* appears at the center of the screen */
} else if (!strcmp(argv[i], "-c")) { // appears at the center of the screen
centered = 1;
} else if (!strcmp(argv[i], "-f")) { /* grabs keyboard before reading stdin */
} else if (!strcmp(argv[i], "-f")) { // grabs keyboard before reading stdin
fast = 1;
} else if (!strcmp(argv[i], "-rw")) { /* relative width */
} else if (!strcmp(argv[i], "-rw")) { // relative width
accuratewidth = 1;
} else if (!strcmp(argv[i], "-nrw")) { /* no relative width */
} else if (!strcmp(argv[i], "-nrw")) { // no relative width
accuratewidth = 0;
} else if (!strcmp(argv[i], "-xrdb")) /* xresources */
} else if (!strcmp(argv[i], "-xrdb")) { // xresources
xresources = 1;
else if (!strcmp(argv[i], "-nxrdb")) /* no xresources */
} else if (!strcmp(argv[i], "-nxrdb")) { // no xresources
xresources = 0;
else if (!strcmp(argv[i], "-F")) /* fuzzy matching */
} else if (!strcmp(argv[i], "-F")) { // fuzzy matching
fuzzy = 0;
else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */
fstrncmp = strncmp;
fstrstr = strstr;
} else if (!strcmp(argv[i], "-S")) { /* don't sort */
} else if (!strcmp(argv[i], "-s")) { // case-sensitive item matching
casesensitive = 1;
} else if (!strcmp(argv[i], "-ns")) { // case-insensitive item matching
casesensitive = 0;
} else if (!strcmp(argv[i], "-S")) { // don't sort
sortmatches = 0;
} else if (!strcmp(argv[i], "-nso")) { /* don't sort */
} else if (!strcmp(argv[i], "-nso")) { // don't sort
sortmatches = 0;
} else if (!strcmp(argv[i], "-so")) { /* don't sort */
} else if (!strcmp(argv[i], "-so")) { // don't sort
sortmatches = 1;
} else if (!strcmp(argv[i], "-i")) { /* case-sensitive item matching, for compatibility reasons */
fstrncmp = strncasecmp;
fstrstr = cistrstr;
} else if (!strcmp(argv[i], "-gc")) { /* generate image cache */
} else if (!strcmp(argv[i], "-gc")) { // generate image cache
generatecache = 1;
} else if (!strcmp(argv[i], "-ngc")) { /* don't generate image cache */
} else if (!strcmp(argv[i], "-ngc")) { // don't generate image cache
generatecache = 0;
} else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */
} else if (!strcmp(argv[i], "-wm")) { // display as managed wm window
managed = 1;
} else if (!strcmp(argv[i], "-nwm")) { /* don't display as managed wm window */
} else if (!strcmp(argv[i], "-nwm")) { // don't display as managed wm window
managed = 0;
} else if (!strcmp(argv[i], "-na")) { /* disable alpha */
} else if (!strcmp(argv[i], "-na")) { // disable alpha
alpha = 0;
} else if (!strcmp(argv[i], "-a")) { /* alpha */
} else if (!strcmp(argv[i], "-a")) { // alpha
alpha = 1;
} else if (!strcmp(argv[i], "-tp")) { /* allow the user to type */
} else if (!strcmp(argv[i], "-tp")) { // allow the user to type
type = 1;
} else if (!strcmp(argv[i], "-nt")) { /* don't allow the user to type */
} else if (!strcmp(argv[i], "-nt")) { // don't allow the user to type
type = 0;
} else if (!strcmp(argv[i], "-P")) { /* is the input a password */
} else if (!strcmp(argv[i], "-P")) { // is the input a password
passwd = 1;
} else if (!strcmp(argv[i], "-hmc")) { /* hide match count */
} else if (!strcmp(argv[i], "-hmc")) { // hide match count
hidematchcount = 1;
} else if (!strcmp(argv[i], "-smc")) { /* don't hide match count */
} else if (!strcmp(argv[i], "-smc")) { // don't hide match count
hidematchcount = 0;
} else if (!strcmp(argv[i], "-hm")) { /* hide mode indicator */
} else if (!strcmp(argv[i], "-hm")) { // hide mode indicator
hidemode = 1;
} else if (!strcmp(argv[i], "-sm")) { /* don't hide mode indicator */
} else if (!strcmp(argv[i], "-sm")) { // don't hide mode indicator
hidemode = 0;
} else if (!strcmp(argv[i], "-hla")) { /* hide left arrow */
} else if (!strcmp(argv[i], "-hla")) { // hide left arrow
hidelarrow = 1;
} else if (!strcmp(argv[i], "-sla")) { /* don't hide left arrow */
} else if (!strcmp(argv[i], "-sla")) { // don't hide left arrow
hidelarrow = 0;
} else if (!strcmp(argv[i], "-hra")) { /* hide right arrow */
} else if (!strcmp(argv[i], "-hra")) { // hide right arrow
hiderarrow = 1;
} else if (!strcmp(argv[i], "-sra")) { /* don't hide right arrow */
} else if (!strcmp(argv[i], "-sra")) { // don't hide right arrow
hiderarrow = 0;
} else if (!strcmp(argv[i], "-hpr")) { /* hide prompt */
} else if (!strcmp(argv[i], "-hpr")) { // hide prompt
hideprompt = 1;
} else if (!strcmp(argv[i], "-spr")) { /* don't hide prompt */
} else if (!strcmp(argv[i], "-spr")) { // don't hide prompt
hideprompt = 0;
} else if (!strcmp(argv[i], "-hc")) { /* hide cursor */
} else if (!strcmp(argv[i], "-hc")) { // hide cursor
hidecursor = 1;
} else if (!strcmp(argv[i], "-sc")) { /* don't hide cursor */
} else if (!strcmp(argv[i], "-sc")) { // don't hide cursor
hidecursor = 0;
} else if (!strcmp(argv[i], "-hhl")) { /* hide highlighting */
} else if (!strcmp(argv[i], "-hhl")) { // hide highlighting
hidehighlight = 1;
} else if (!strcmp(argv[i], "-shl")) { /* don't hide highlighting */
} else if (!strcmp(argv[i], "-shl")) { // don't hide highlighting
hidehighlight = 0;
} else if (!strcmp(argv[i], "-hi")) { /* hide image */
} else if (!strcmp(argv[i], "-hi")) { // hide image
hideimage = 1;
} else if (!strcmp(argv[i], "-si")) { /* don't hide image */
} else if (!strcmp(argv[i], "-si")) { // don't hide image
hideimage = 0;
} else if (!strcmp(argv[i], "-ip")) { /* indent to prompt width */
} else if (!strcmp(argv[i], "-ip")) { // indent to prompt width
indentitems = 1;
} else if (!strcmp(argv[i], "-nip")) { /* don't indent to prompt width */
} else if (!strcmp(argv[i], "-nip")) { // don't indent to prompt width
indentitems = 0;
} else if (i + 1 == argc) {
int arg = i;
@ -152,6 +146,10 @@ readargs(int argc, char *argv[])
else if (pr)
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
// dmenu compatibility arguments
} else if (!strcmp(argv[i], "-i")) { // case-insensitive item matching, for compatibility reasons
casesensitive = 0;
// these options take one argument
} else if (!strcmp(argv[i], "-g")) { // number of columns in grid
columns = atoi(argv[++i]);
@ -163,61 +161,61 @@ readargs(int argc, char *argv[])
} else if (!strcmp(argv[i], "-mh")) { // minimum height of one menu line
lineheight += atoi(argv[++i]);
if (columns == 0) columns = 1;
} else if (!strcmp(argv[i], "-lp")) {
} else if (!strcmp(argv[i], "-lp")) { // vertical padding
menupaddingv = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-hp")) {
} else if (!strcmp(argv[i], "-hp")) { // horizontal padding
menupaddingh = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-pri")) {
} else if (!strcmp(argv[i], "-pri")) { // high priority (csv)
hpitems = tokenize(argv[++i], ",", &hplength);
} else if (!strcmp(argv[i], "-ig")) {
} else if (!strcmp(argv[i], "-ig")) { // gaps between image
imagegaps = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-la")) {
} else if (!strcmp(argv[i], "-la")) { // left arrow symbol
leftarrow = argv[++i];
} else if (!strcmp(argv[i], "-ra")) {
} else if (!strcmp(argv[i], "-ra")) { // right arrow symbol
rightarrow = argv[++i];
} else if (!strcmp(argv[i], "-m")) /* monitor */
} else if (!strcmp(argv[i], "-m")) // monitor
mon = atoi(argv[++i]);
else if (!strcmp(argv[i], "-bw")) { /* border width */
else if (!strcmp(argv[i], "-bw")) { // border width
borderwidth = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-H")) /* hist file location */
} else if (!strcmp(argv[i], "-H")) // hist file location
histfile = argv[++i];
else if (!strcmp(argv[i], "-x")) /* window x offset */
else if (!strcmp(argv[i], "-x")) // window x offset
dmx = atoi(argv[++i]);
else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */
else if (!strcmp(argv[i], "-y")) // window y offset (from bottom up if -b)
dmy = atoi(argv[++i]);
else if (!strcmp(argv[i], "-z")) /* make spmenu this wide */
else if (!strcmp(argv[i], "-z")) // make spmenu this wide
dmw = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
else if (!strcmp(argv[i], "-p")) // adds prompt to left of input field
prompt = argv[++i];
else if (!strcmp(argv[i], "-fn")) /* font or font set */
else if (!strcmp(argv[i], "-fn")) // font or font set
fonts[0] = argv[++i];
else if (!strcmp(argv[i], "-nmt")) /* normal mode text */
else if (!strcmp(argv[i], "-nmt")) // normal mode text
strcpy(normtext, argv[++i]);
else if (!strcmp(argv[i], "-imt")) { /* insert mode text */
else if (!strcmp(argv[i], "-imt")) { // insert mode text
strcpy(instext, argv[++i]);
/* dmenu compatibility options */
} else if (!strcmp(argv[i], "-nb")) { /* normal background color */
// dmenu compatibility options
} else if (!strcmp(argv[i], "-nb")) { // normal background color
colors[SchemeItemNorm][ColBg] = argv[++i];
colors[SchemeMenu][ColBg] = argv[++i];
colors[SchemeInput][ColBg] = argv[++i];
colors[SchemePrompt][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-nf")) { /* normal foreground color */
} else if (!strcmp(argv[i], "-nf")) { // normal foreground color
colors[SchemeItemNorm][ColFg] = argv[++i];
colors[SchemeMenu][ColFg] = argv[++i];
colors[SchemeInput][ColFg] = argv[++i];
colors[SchemePrompt][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-sb")) { /* selected background color */
} else if (!strcmp(argv[i], "-sb")) { // selected background color
colors[SchemeItemSel][ColBg] = argv[++i];
colors[SchemeMenu][ColBg] = argv[++i];
colors[SchemeInput][ColBg] = argv[++i];
colors[SchemePrompt][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-sf")) { /* selected foreground color */
} else if (!strcmp(argv[i], "-sf")) { // selected foreground color
colors[SchemeItemSel][ColFg] = argv[++i];
colors[SchemeMenu][ColFg] = argv[++i];
colors[SchemeInput][ColBg] = argv[++i];
colors[SchemePrompt][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-is")) { /* image size */
} else if (!strcmp(argv[i], "-is")) { // image size
char buf[255];
memset(buf, 0, sizeof(buf));
memcpy(buf, argv[++i], sizeof(buf)-1);
@ -225,88 +223,96 @@ readargs(int argc, char *argv[])
if(sscanf(buf, "%dx%d", &imagewidth, &imageheight) == 1)
imageheight = imagewidth;
} else if (!strcmp(argv[i], "-w")) { /* embedding window id */
} else if (!strcmp(argv[i], "-w")) { // embedding window id
embed = argv[++i];
} else if (!strcmp(argv[i], "-n")) { /* preselected item */
} else if (!strcmp(argv[i], "-n")) { // preselected item
preselected = atoi(argv[++i]);
/* spmenu colors */
} else if (!strcmp(argv[i], "-nif")) { /* normal item foreground color */
// spmenu colors
} else if (!strcmp(argv[i], "-nif")) { // normal item foreground color
colors[SchemeItemNorm][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-nib")) { /* normal item background color */
} else if (!strcmp(argv[i], "-nib")) { // normal item background color
colors[SchemeItemNorm][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-sif")) { /* selected item foreground color */
} else if (!strcmp(argv[i], "-sif")) { // selected item foreground color
colors[SchemeItemSel][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-sib")) { /* selected item background color */
} else if (!strcmp(argv[i], "-sib")) { // selected item background color
colors[SchemeItemSel][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-npf")) { /* normal item priority foreground color */
} else if (!strcmp(argv[i], "-npf")) { // normal item priority foreground color
colors[SchemeItemNormPri][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-npb")) { /* normal item priority background color */
} else if (!strcmp(argv[i], "-npb")) { // normal item priority background color
colors[SchemeItemNormPri][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-spf")) { /* selected item priority foreground color */
} else if (!strcmp(argv[i], "-spf")) { // selected item priority foreground color
colors[SchemeItemSelPri][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-spb")) { /* selected item priority background color */
} else if (!strcmp(argv[i], "-spb")) { // selected item priority background color
colors[SchemeItemSelPri][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-mbg")) { /* menu color */
} else if (!strcmp(argv[i], "-mbg")) { // menu color
colors[SchemeMenu][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-pfg")) { /* prompt fg color */
} else if (!strcmp(argv[i], "-pfg")) { // prompt fg color
colors[SchemePrompt][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-pbg")) { /* prompt bg color */
} else if (!strcmp(argv[i], "-pbg")) { // prompt bg color
colors[SchemePrompt][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-ifg")) { /* input fg color */
} else if (!strcmp(argv[i], "-ifg")) { // input fg color
colors[SchemeInput][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-pfg")) { /* input bg color */
} else if (!strcmp(argv[i], "-pfg")) { // input bg color
colors[SchemeInput][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-shf")) { /* selected highlight foreground color */
} else if (!strcmp(argv[i], "-shf")) { // selected highlight foreground color
colors[SchemeSelHighlight][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-shf")) { /* selected highlight foreground color */
} else if (!strcmp(argv[i], "-shf")) { // selected highlight foreground color
colors[SchemeSelHighlight][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-nhf")) { /* normal highlight foreground color */
} else if (!strcmp(argv[i], "-nhf")) { // normal highlight foreground color
colors[SchemeNormHighlight][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-shb")) { /* selected highlight foreground color */
} else if (!strcmp(argv[i], "-shb")) { // selected highlight foreground color
colors[SchemeSelHighlight][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-nhb")) { /* normal highlight foreground color */
} else if (!strcmp(argv[i], "-nhb")) { // normal highlight foreground color
colors[SchemeNormHighlight][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-nbg")) { /* numbgcolor */
} else if (!strcmp(argv[i], "-nbg")) { // numbgcolor
colors[SchemeNumber][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-nfg")) { /* numfgcolor */
} else if (!strcmp(argv[i], "-nfg")) { // numfgcolor
colors[SchemeNumber][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-mbg")) { /* mode */
} else if (!strcmp(argv[i], "-mbg")) { // mode
colors[SchemeMode][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-mfg")) { /* mode */
} else if (!strcmp(argv[i], "-mfg")) { // mode
colors[SchemeMode][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-laf")) { /* left arrow fg */
} else if (!strcmp(argv[i], "-laf")) { // left arrow fg
colors[SchemeLArrow][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-raf")) { /* right arrow fg */
} else if (!strcmp(argv[i], "-raf")) { // right arrow fg
colors[SchemeRArrow][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-lab")) { /* left arrow bg */
} else if (!strcmp(argv[i], "-lab")) { // left arrow bg
colors[SchemeLArrow][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-rab")) { /* right arrow bg */
} else if (!strcmp(argv[i], "-rab")) { // right arrow bg
colors[SchemeRArrow][ColFg] = argv[++i];
} else if (!strcmp(argv[i], "-bc")) { /* border */
} else if (!strcmp(argv[i], "-bc")) { // border
colors[SchemeBorder][ColBg] = argv[++i];
} else if (!strcmp(argv[i], "-cc")) /* caret color */
} else if (!strcmp(argv[i], "-cc")) // caret color
colors[SchemeCaret][ColFg] = argv[++i];
/* sgr colors */
else if (!strcmp(argv[i], "-sgr0")) textcolors[0] = argv[++i]; /* sgr color 0 */
else if (!strcmp(argv[i], "-sgr1")) textcolors[1] = argv[++i]; /* sgr color 1 */
else if (!strcmp(argv[i], "-sgr2")) textcolors[2] = argv[++i]; /* sgr color 2 */
else if (!strcmp(argv[i], "-sgr3")) textcolors[3] = argv[++i]; /* sgr color 3 */
else if (!strcmp(argv[i], "-sgr4")) textcolors[4] = argv[++i]; /* sgr color 4 */
else if (!strcmp(argv[i], "-sgr5")) textcolors[5] = argv[++i]; /* sgr color 5 */
else if (!strcmp(argv[i], "-sgr6")) textcolors[6] = argv[++i]; /* sgr color 6 */
else if (!strcmp(argv[i], "-sgr7")) textcolors[7] = argv[++i]; /* sgr color 7 */
else if (!strcmp(argv[i], "-sgr8")) textcolors[8] = argv[++i]; /* sgr color 8 */
else if (!strcmp(argv[i], "-sgr9")) textcolors[9] = argv[++i]; /* sgr color 9 */
else if (!strcmp(argv[i], "-sgr10")) textcolors[10] = argv[++i]; /* sgr color 10 */
else if (!strcmp(argv[i], "-sgr11")) textcolors[11] = argv[++i]; /* sgr color 11 */
else if (!strcmp(argv[i], "-sgr12")) textcolors[12] = argv[++i]; /* sgr color 12 */
else if (!strcmp(argv[i], "-sgr13")) textcolors[13] = argv[++i]; /* sgr color 13 */
else if (!strcmp(argv[i], "-sgr14")) textcolors[14] = argv[++i]; /* sgr color 14 */
else if (!strcmp(argv[i], "-sgr15")) textcolors[15] = argv[++i]; /* sgr color 15 */
// sgr colors
else if (!strcmp(argv[i], "-sgr0")) textcolors[0] = argv[++i]; // sgr color 0
else if (!strcmp(argv[i], "-sgr1")) textcolors[1] = argv[++i]; // sgr color 1
else if (!strcmp(argv[i], "-sgr2")) textcolors[2] = argv[++i]; // sgr color 2
else if (!strcmp(argv[i], "-sgr3")) textcolors[3] = argv[++i]; // sgr color 3
else if (!strcmp(argv[i], "-sgr4")) textcolors[4] = argv[++i]; // sgr color 4
else if (!strcmp(argv[i], "-sgr5")) textcolors[5] = argv[++i]; // sgr color 5
else if (!strcmp(argv[i], "-sgr6")) textcolors[6] = argv[++i]; // sgr color 6
else if (!strcmp(argv[i], "-sgr7")) textcolors[7] = argv[++i]; // sgr color 7
else if (!strcmp(argv[i], "-sgr8")) textcolors[8] = argv[++i]; // sgr color 8
else if (!strcmp(argv[i], "-sgr9")) textcolors[9] = argv[++i]; // sgr color 9
else if (!strcmp(argv[i], "-sgr10")) textcolors[10] = argv[++i]; // sgr color 10
else if (!strcmp(argv[i], "-sgr11")) textcolors[11] = argv[++i]; // sgr color 11
else if (!strcmp(argv[i], "-sgr12")) textcolors[12] = argv[++i]; // sgr color 12
else if (!strcmp(argv[i], "-sgr13")) textcolors[13] = argv[++i]; // sgr color 13
else if (!strcmp(argv[i], "-sgr14")) textcolors[14] = argv[++i]; // sgr color 14
else if (!strcmp(argv[i], "-sgr15")) textcolors[15] = argv[++i]; // sgr color 15
else
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
if (casesensitive) {
fstrncmp = strncmp;
fstrstr = strstr;
} else {
fstrncmp = strncasecmp;
fstrstr = cistrstr;
}
}
void
@ -343,7 +349,7 @@ usage(void)
"spmenu -nso Don't sort matches\n"
"spmenu -pri <pri> Specify a list of items that take priority\n"
"spmenu -s Use case-sensitive matching\n"
"spmenu -i Use case-insensitive matching\n"
"spmenu -ns Use case-insensitive matching\n"
"spmenu -nm Start spmenu in normal mode\n"
"spmenu -im Start spmenu in insert mode\n"
"spmenu -t Position spmenu at the top of the screen\n"
@ -435,6 +441,7 @@ usage(void)
"\n", stdout);
fputs("- dmenu compatibility -\n"
"spmenu -S Don't sort matches\n"
"spmenu -i Use case-insensitive matching\n"
"spmenu -nb <color> Set the normal background color\n"
"spmenu -nf <color> Set the normal foreground color\n"
"spmenu -sb <color> Set the selected background color\n"

View file

@ -107,7 +107,7 @@ spmenu -pri priority - Specify a list of items that take priority
.IP \[bu] 2
spmenu -s - Use case-sensitive matching
.IP \[bu] 2
spmenu -i - Use case-insensitive matching
spmenu -ns - Use case-insensitive matching
.IP \[bu] 2
spmenu -nm - Start spmenu in normal mode
.IP \[bu] 2
@ -289,6 +289,8 @@ spmenu -sgr15 - Set the SGR 15 color
There are also extra arguments recognized for dmenu compatibility.
These are:
.IP \[bu] 2
spmenu -i - Use case-insensitive matching
.IP \[bu] 2
spmenu -S - Don\[cq]t sort matches
.IP \[bu] 2
spmenu -nb color - Set the normal background color