add option to not allow typing if what is being typed doesn't have any
matches
This commit is contained in:
parent
671dbffa1b
commit
2e9cb1e408
|
@ -349,7 +349,11 @@ state.</li>
|
||||||
<h3 id="bugs">Bugs</h3>
|
<h3 id="bugs">Bugs</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Text drawing: Pango will sometimes spit out errors for invalid
|
<li>Text drawing: Pango will sometimes spit out errors for invalid
|
||||||
markup. Silencing this would be a good idea.</li>
|
markup. Silencing this would be a good idea.
|
||||||
|
<ul>
|
||||||
|
<li>Simply make sure characters are valid UTF-8 characters. Remove
|
||||||
|
anything else in the drw_text function.</li>
|
||||||
|
</ul></li>
|
||||||
<li>Image support: Images take a long time to load sometimes,
|
<li>Image support: Images take a long time to load sometimes,
|
||||||
particularly when items are selected using the cursor so what we really
|
particularly when items are selected using the cursor so what we really
|
||||||
need is a way to skip over images after a set time limit.</li>
|
need is a way to skip over images after a set time limit.</li>
|
||||||
|
|
|
@ -69,6 +69,12 @@ You may use long, descriptive arguments or the shorter arguments.
|
||||||
`-nr, --no-incremental`
|
`-nr, --no-incremental`
|
||||||
: Don't print text every time a key is pressed
|
: Don't print text every time a key is pressed
|
||||||
|
|
||||||
|
`-rm, --require-match`
|
||||||
|
: Require that input text matches an item
|
||||||
|
|
||||||
|
`-nrm, --no-require-match`
|
||||||
|
: Don't require that input text matches an item
|
||||||
|
|
||||||
`-F, --fuzzy`
|
`-F, --fuzzy`
|
||||||
: Enable fuzzy matching
|
: Enable fuzzy matching
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,7 @@ spmenu.managed: 0
|
||||||
spmenu.mon: -1
|
spmenu.mon: -1
|
||||||
spmenu.printindex: 0
|
spmenu.printindex: 0
|
||||||
spmenu.incremental: 0
|
spmenu.incremental: 0
|
||||||
|
spmenu.requirematch: 0
|
||||||
spmenu.coloritems: 1
|
spmenu.coloritems: 1
|
||||||
spmenu.sgr: 1
|
spmenu.sgr: 1
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,10 @@ void readargs(int argc, char *argv[]) {
|
||||||
incremental = 1;
|
incremental = 1;
|
||||||
} else if (!strcmp(argv[i], "-nr") || (!strcmp(argv[i], "--no-incremental"))) { // no incremental
|
} else if (!strcmp(argv[i], "-nr") || (!strcmp(argv[i], "--no-incremental"))) { // no incremental
|
||||||
incremental = 0;
|
incremental = 0;
|
||||||
|
} else if (!strcmp(argv[i], "-rm") || (!strcmp(argv[i], "--require-match"))) { // require match
|
||||||
|
requirematch = 1;
|
||||||
|
} else if (!strcmp(argv[i], "-nrm") || (!strcmp(argv[i], "--no-require-match"))) { // no incremental
|
||||||
|
requirematch = 0;
|
||||||
} else if (!strcmp(argv[i], "-rw") || (!strcmp(argv[i], "--relative-width"))) { // relative width
|
} else if (!strcmp(argv[i], "-rw") || (!strcmp(argv[i], "--relative-width"))) { // relative width
|
||||||
accuratewidth = 1;
|
accuratewidth = 1;
|
||||||
} else if (!strcmp(argv[i], "-nrw") || (!strcmp(argv[i], "--no-relative-width"))) { // no relative width
|
} else if (!strcmp(argv[i], "-nrw") || (!strcmp(argv[i], "--no-relative-width"))) { // no relative width
|
||||||
|
@ -463,6 +467,8 @@ void usage(void) {
|
||||||
"spmenu -f, --fast Grabs keyboard before reading stdin\n"
|
"spmenu -f, --fast Grabs keyboard before reading stdin\n"
|
||||||
"spmenu -r, --incremental Print text every time a key is pressed\n"
|
"spmenu -r, --incremental Print text every time a key is pressed\n"
|
||||||
"spmenu -nr, --no-incremental Don't print text every time a key is pressed\n"
|
"spmenu -nr, --no-incremental Don't print text every time a key is pressed\n"
|
||||||
|
"spmenu -rm, --require-match Require that input text matches an item\n"
|
||||||
|
"spmenu -nrm, --no-require-match Don't require that input text matches an item\n"
|
||||||
"spmenu -F, --fuzzy Enable fuzzy matching\n"
|
"spmenu -F, --fuzzy Enable fuzzy matching\n"
|
||||||
"spmenu -NF, --no-fuzzy Disable fuzzy matching\n"
|
"spmenu -NF, --no-fuzzy Disable fuzzy matching\n"
|
||||||
"spmenu -P, --password Hide characters\n"
|
"spmenu -P, --password Hide characters\n"
|
||||||
|
|
|
@ -96,6 +96,7 @@ ResourcePref resources[] = {
|
||||||
{ "globalcolors", INTEGER, &globalcolors },
|
{ "globalcolors", INTEGER, &globalcolors },
|
||||||
{ "coloritems", INTEGER, &coloritems },
|
{ "coloritems", INTEGER, &coloritems },
|
||||||
{ "sgr", INTEGER, &sgr },
|
{ "sgr", INTEGER, &sgr },
|
||||||
|
{ "requirematch", INTEGER, &requirematch },
|
||||||
{ "menuposition", INTEGER, &menuposition },
|
{ "menuposition", INTEGER, &menuposition },
|
||||||
{ "xpos", INTEGER, &xpos },
|
{ "xpos", INTEGER, &xpos },
|
||||||
{ "ypos", INTEGER, &ypos },
|
{ "ypos", INTEGER, &ypos },
|
||||||
|
|
|
@ -227,6 +227,7 @@ static int pango_password = 0; /* Enable support for pango markup f
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
static int printindex = 0; /* Print index instead of the text itself (0/1) */
|
static int printindex = 0; /* Print index instead of the text itself (0/1) */
|
||||||
|
static int requirematch = 0; /* Require input text to match an item (0/1) */
|
||||||
static int incremental = 0; /* Print text every time a key is pressed (0/1) */
|
static int incremental = 0; /* Print text every time a key is pressed (0/1) */
|
||||||
static int coloritems = 1; /* Color items (0/1) */
|
static int coloritems = 1; /* Color items (0/1) */
|
||||||
static int sgr = 1; /* Support SGR sequences (0/1) */
|
static int sgr = 1; /* Support SGR sequences (0/1) */
|
||||||
|
|
6
spmenu.1
6
spmenu.1
|
@ -89,6 +89,12 @@ Print text every time a key is pressed
|
||||||
\f[V]-nr, --no-incremental\f[R]
|
\f[V]-nr, --no-incremental\f[R]
|
||||||
Don\[cq]t print text every time a key is pressed
|
Don\[cq]t print text every time a key is pressed
|
||||||
.TP
|
.TP
|
||||||
|
\f[V]-rm, --require-match\f[R]
|
||||||
|
Require that input text matches an item
|
||||||
|
.TP
|
||||||
|
\f[V]-nrm, --no-require-match\f[R]
|
||||||
|
Don\[cq]t require that input text matches an item
|
||||||
|
.TP
|
||||||
\f[V]-F, --fuzzy\f[R]
|
\f[V]-F, --fuzzy\f[R]
|
||||||
Enable fuzzy matching
|
Enable fuzzy matching
|
||||||
.TP
|
.TP
|
||||||
|
|
9
spmenu.c
9
spmenu.c
|
@ -436,6 +436,9 @@ void insert(const char *str, ssize_t n) {
|
||||||
if (strlen(text) + n > sizeof text - 1)
|
if (strlen(text) + n > sizeof text - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
static char l[BUFSIZ] = "";
|
||||||
|
if (requirematch) memcpy(l, text, BUFSIZ);
|
||||||
|
|
||||||
// move existing text out of the way, insert new text, and update cursor
|
// move existing text out of the way, insert new text, and update cursor
|
||||||
memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0));
|
memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0));
|
||||||
|
|
||||||
|
@ -446,6 +449,12 @@ void insert(const char *str, ssize_t n) {
|
||||||
// add to cursor position and continue matching
|
// add to cursor position and continue matching
|
||||||
cursor += n;
|
cursor += n;
|
||||||
match();
|
match();
|
||||||
|
|
||||||
|
if (!matches && requirematch) {
|
||||||
|
memcpy(text, l, BUFSIZ);
|
||||||
|
cursor -= n;
|
||||||
|
match();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nextrune(int inc) {
|
size_t nextrune(int inc) {
|
||||||
|
|
|
@ -243,6 +243,14 @@ Print text every time a key is pressed
|
||||||
<dd>
|
<dd>
|
||||||
Don’t print text every time a key is pressed
|
Don’t print text every time a key is pressed
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt><code>-rm, --require-match</code></dt>
|
||||||
|
<dd>
|
||||||
|
Require that input text matches an item
|
||||||
|
</dd>
|
||||||
|
<dt><code>-nrm, --no-require-match</code></dt>
|
||||||
|
<dd>
|
||||||
|
Don’t require that input text matches an item
|
||||||
|
</dd>
|
||||||
<dt><code>-F, --fuzzy</code></dt>
|
<dt><code>-F, --fuzzy</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
Enable fuzzy matching
|
Enable fuzzy matching
|
||||||
|
|
Loading…
Reference in a new issue