add incremental as well, this should now include most suckless patches people use

This commit is contained in:
speedie 2023-05-06 23:39:03 +02:00
parent 5ff1abc849
commit 442c40b732
10 changed files with 36 additions and 0 deletions

View file

@ -63,6 +63,12 @@ You may use long, descriptive arguments or the shorter arguments.
`-f, --fast` `-f, --fast`
: Grabs keyboard before reading stdin : Grabs keyboard before reading stdin
`-r, --incremental`
: Print text every time a key is pressed
`-nr, --no-incremental`
: Don't print text every time a key is pressed
`-F, --fuzzy` `-F, --fuzzy`
: Enable fuzzy matching : Enable fuzzy matching

View file

@ -143,6 +143,7 @@ spmenu.fast: 0
spmenu.managed: 0 spmenu.managed: 0
spmenu.mon: -1 spmenu.mon: -1
spmenu.printindex: 0 spmenu.printindex: 0
spmenu.incremental: 0
spmenu.coloritems: 1 spmenu.coloritems: 1
spmenu.sgr: 1 spmenu.sgr: 1

View file

@ -201,6 +201,7 @@ spmenu = {
/* Output options */ /* Output options */
output = ( { printindex = 0; // Print index instead of actual text (0/1) output = ( { printindex = 0; // Print index instead of actual text (0/1)
incremental = 0; // Print text on every keypress (0/1)
} ); } );
/* Mode options */ /* Mode options */

View file

@ -86,6 +86,10 @@ void readargs(int argc, char *argv[]) {
mode = 1; mode = 1;
} else if (!strcmp(argv[i], "-f") || (!strcmp(argv[i], "--fast"))) { // grabs keyboard before reading stdin } else if (!strcmp(argv[i], "-f") || (!strcmp(argv[i], "--fast"))) { // grabs keyboard before reading stdin
fast = 1; fast = 1;
} else if (!strcmp(argv[i], "-r") || (!strcmp(argv[i], "--incremental"))) { // incremental
incremental = 1;
} else if (!strcmp(argv[i], "-nr") || (!strcmp(argv[i], "--no-incremental"))) { // no incremental
incremental = 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
@ -455,6 +459,8 @@ void usage(void) {
"spmenu -ix, --print-index Print index instead of actual text\n" "spmenu -ix, --print-index Print index instead of actual text\n"
"spmenu -nix, --no-print-index Don't print index instead of actual text\n" "spmenu -nix, --no-print-index Don't print index instead of actual text\n"
"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 -nr, --no-incremental Don't print text every time a key is pressed\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"

View file

@ -408,6 +408,7 @@ void conf_init(void) {
// look up // look up
config_setting_lookup_int(conf, "printindex", &printindex); // spmenu.output.printindex config_setting_lookup_int(conf, "printindex", &printindex); // spmenu.output.printindex
config_setting_lookup_int(conf, "incremental", &incremental); // spmenu.output.incremental
} }
} }

View file

@ -31,6 +31,11 @@ void eventloop(void) {
grabfocus(); grabfocus();
break; break;
case KeyPress: // read key array and call functions case KeyPress: // read key array and call functions
if (incremental) {
puts(text);
fflush(stdout);
}
keypress(&ev); keypress(&ev);
break; break;
case SelectionNotify: // paste selection case SelectionNotify: // paste selection

View file

@ -147,6 +147,7 @@ ResourcePref resources[] = {
{ "mon", INTEGER, &mon }, { "mon", INTEGER, &mon },
{ "sortmatches", INTEGER, &sortmatches }, { "sortmatches", INTEGER, &sortmatches },
{ "printindex", INTEGER, &printindex }, { "printindex", INTEGER, &printindex },
{ "incremental", INTEGER, &incremental },
{ "fuzzy", INTEGER, &fuzzy }, { "fuzzy", INTEGER, &fuzzy },
{ "pango_item", INTEGER, &pango_item }, { "pango_item", INTEGER, &pango_item },
{ "pango_prompt", INTEGER, &pango_prompt }, { "pango_prompt", INTEGER, &pango_prompt },

View file

@ -226,6 +226,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 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) */
static char *worddelimiters = " "; /* Word delimiters used for keybinds that change words, Space is default. */ static char *worddelimiters = " "; /* Word delimiters used for keybinds that change words, Space is default. */

View file

@ -83,6 +83,12 @@ Don\[cq]t print index instead of actual text
\f[V]-f, --fast\f[R] \f[V]-f, --fast\f[R]
Grabs keyboard before reading stdin Grabs keyboard before reading stdin
.TP .TP
\f[V]-r, --incremental\f[R]
Print text every time a key is pressed
.TP
\f[V]-nr, --no-incremental\f[R]
Don\[cq]t print text every time a key is pressed
.TP
\f[V]-F, --fuzzy\f[R] \f[V]-F, --fuzzy\f[R]
Enable fuzzy matching Enable fuzzy matching
.TP .TP

View file

@ -235,6 +235,14 @@ Dont print index instead of actual text
<dd> <dd>
Grabs keyboard before reading stdin Grabs keyboard before reading stdin
</dd> </dd>
<dt><code>-r, --incremental</code></dt>
<dd>
Print text every time a key is pressed
</dd>
<dt><code>-nr, --no-incremental</code></dt>
<dd>
Dont print text every time a key is pressed
</dd>
<dt><code>-F, --fuzzy</code></dt> <dt><code>-F, --fuzzy</code></dt>
<dd> <dd>
Enable fuzzy matching Enable fuzzy matching