add match toggle
This commit is contained in:
parent
7803e08417
commit
4e9713ddae
|
@ -41,6 +41,8 @@ On top of this, you can specify arguments to change the behavior of spmenu. See
|
|||
- spmenu -nmt text - Set normal mode text to text
|
||||
- spmenu -imt text - Set insert mode text to text
|
||||
- spmenu -bw - Width of the border. 0 will disable the border
|
||||
- spmenu -so - Sort matches
|
||||
- spmenu -nso - Don't sort matches
|
||||
- spmenu -s - Use case-sensitive matching
|
||||
- spmenu -i - Use case-insensitive matching
|
||||
- spmenu -nm - Start spmenu in normal mode
|
||||
|
@ -124,6 +126,7 @@ On top of this, you can specify arguments to change the behavior of spmenu. See
|
|||
|
||||
There are also extra arguments recognized for dmenu compatibility. These are:
|
||||
|
||||
- spmenu -S - Don't sort matches
|
||||
- spmenu -nb color - Set the normal background color
|
||||
- spmenu -nf color - Set the normal foreground color
|
||||
- spmenu -sb color - Set the selected background color
|
||||
|
|
|
@ -60,6 +60,12 @@ readargs(int argc, char *argv[])
|
|||
else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */
|
||||
fstrncmp = strncmp;
|
||||
fstrstr = strstr;
|
||||
} else if (!strcmp(argv[i], "-S")) { /* don't sort */
|
||||
sortmatches = 0;
|
||||
} else if (!strcmp(argv[i], "-nso")) { /* don't sort */
|
||||
sortmatches = 0;
|
||||
} 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;
|
||||
|
@ -293,6 +299,8 @@ usage(void)
|
|||
"spmenu -nmt <text> Set normal mode text to <text>\n"
|
||||
"spmenu -imt <text> Set insert mode text to <text>\n"
|
||||
"spmenu -bw Width of the border. 0 will disable the border\n"
|
||||
"spmenu -so Sort matches\n"
|
||||
"spmenu -nso Don't sort matches\n"
|
||||
"spmenu -s Use case-sensitive matching\n"
|
||||
"spmenu -i Use case-insensitive matching\n"
|
||||
"spmenu -nm Start spmenu in normal mode\n"
|
||||
|
@ -378,6 +386,7 @@ usage(void)
|
|||
"spmenu -sgr15 Set the SGR 15 color\n"
|
||||
"\n", stdout);
|
||||
fputs("- dmenu compatibility -\n"
|
||||
"spmenu -S Don't sort matches\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"
|
||||
|
|
|
@ -42,6 +42,7 @@ static char *password = "."; /* Password character, when the -P
|
|||
|
||||
/* Match options */
|
||||
static int type = 1; /* Allow typing into spmenu or only allow keybinds. */
|
||||
static int sortmatches = 1; /* Sort matches (0/1) */
|
||||
static int casesensitive = 0; /* Case-sensitive by default? (0/1) */
|
||||
static int preselected = 0; /* Which line should spmenu preselect? */
|
||||
static int accuratewidth = 1; /* Enable accurate width. May have a performance hit if you are matching a lot of items at once */
|
||||
|
|
6
spmenu.1
6
spmenu.1
|
@ -94,6 +94,10 @@ spmenu -imt text - Set insert mode text to text
|
|||
spmenu -bw - Width of the border.
|
||||
0 will disable the border
|
||||
.IP \[bu] 2
|
||||
spmenu -so - Sort matches
|
||||
.IP \[bu] 2
|
||||
spmenu -nso - Don\[cq]t sort matches
|
||||
.IP \[bu] 2
|
||||
spmenu -s - Use case-sensitive matching
|
||||
.IP \[bu] 2
|
||||
spmenu -i - Use case-insensitive matching
|
||||
|
@ -256,6 +260,8 @@ spmenu -sgr15 - Set the SGR 15 color
|
|||
There are also extra arguments recognized for dmenu compatibility.
|
||||
These are:
|
||||
.IP \[bu] 2
|
||||
spmenu -S - Don\[cq]t sort matches
|
||||
.IP \[bu] 2
|
||||
spmenu -nb color - Set the normal background color
|
||||
.IP \[bu] 2
|
||||
spmenu -nf color - Set the normal foreground color
|
||||
|
|
4
spmenu.c
4
spmenu.c
|
@ -603,6 +603,9 @@ match(void)
|
|||
break;
|
||||
if (i != tokc) /* not all tokens match */
|
||||
continue;
|
||||
if (!sortmatches)
|
||||
appenditem(item, &matches, &matchend);
|
||||
else {
|
||||
/* exact matches go first, then prefixes, then substrings */
|
||||
if (!tokc || !fstrncmp(text, item->text, textsize))
|
||||
appenditem(item, &matches, &matchend);
|
||||
|
@ -611,6 +614,7 @@ match(void)
|
|||
else
|
||||
appenditem(item, &lsubstr, &substrend);
|
||||
}
|
||||
}
|
||||
if (lprefix) {
|
||||
if (matches) {
|
||||
matchend->right = lprefix;
|
||||
|
|
Loading…
Reference in a new issue