From 442c40b7322be47cd13abf29f0f8816aa3a5b02c Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 6 May 2023 23:39:03 +0200 Subject: [PATCH] add incremental as well, this should now include most suckless patches people use --- docs/docs.md | 6 ++++++ docs/example.Xresources | 1 + docs/spmenu.conf | 1 + libs/argv.c | 6 ++++++ libs/conf/config.c | 1 + libs/event.c | 5 +++++ libs/xresources.h | 1 + options.h | 1 + spmenu.1 | 6 ++++++ spmenu.html | 8 ++++++++ 10 files changed, 36 insertions(+) diff --git a/docs/docs.md b/docs/docs.md index 55d7a4b..55d9a18 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -63,6 +63,12 @@ You may use long, descriptive arguments or the shorter arguments. `-f, --fast` : 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` : Enable fuzzy matching diff --git a/docs/example.Xresources b/docs/example.Xresources index 6626af6..e8a728e 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -143,6 +143,7 @@ spmenu.fast: 0 spmenu.managed: 0 spmenu.mon: -1 spmenu.printindex: 0 +spmenu.incremental: 0 spmenu.coloritems: 1 spmenu.sgr: 1 diff --git a/docs/spmenu.conf b/docs/spmenu.conf index fc21e7c..98e1563 100644 --- a/docs/spmenu.conf +++ b/docs/spmenu.conf @@ -201,6 +201,7 @@ spmenu = { /* Output options */ output = ( { printindex = 0; // Print index instead of actual text (0/1) + incremental = 0; // Print text on every keypress (0/1) } ); /* Mode options */ diff --git a/libs/argv.c b/libs/argv.c index 1e805ae..21be3ec 100644 --- a/libs/argv.c +++ b/libs/argv.c @@ -86,6 +86,10 @@ void readargs(int argc, char *argv[]) { mode = 1; } else if (!strcmp(argv[i], "-f") || (!strcmp(argv[i], "--fast"))) { // grabs keyboard before reading stdin 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 accuratewidth = 1; } 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 -nix, --no-print-index Don't print index instead of actual text\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 -NF, --no-fuzzy Disable fuzzy matching\n" "spmenu -P, --password Hide characters\n" diff --git a/libs/conf/config.c b/libs/conf/config.c index 688a7c9..cda5040 100644 --- a/libs/conf/config.c +++ b/libs/conf/config.c @@ -408,6 +408,7 @@ void conf_init(void) { // look up config_setting_lookup_int(conf, "printindex", &printindex); // spmenu.output.printindex + config_setting_lookup_int(conf, "incremental", &incremental); // spmenu.output.incremental } } diff --git a/libs/event.c b/libs/event.c index 193f229..330f5c8 100644 --- a/libs/event.c +++ b/libs/event.c @@ -31,6 +31,11 @@ void eventloop(void) { grabfocus(); break; case KeyPress: // read key array and call functions + if (incremental) { + puts(text); + fflush(stdout); + } + keypress(&ev); break; case SelectionNotify: // paste selection diff --git a/libs/xresources.h b/libs/xresources.h index e3019f1..0e317b8 100644 --- a/libs/xresources.h +++ b/libs/xresources.h @@ -147,6 +147,7 @@ ResourcePref resources[] = { { "mon", INTEGER, &mon }, { "sortmatches", INTEGER, &sortmatches }, { "printindex", INTEGER, &printindex }, + { "incremental", INTEGER, &incremental }, { "fuzzy", INTEGER, &fuzzy }, { "pango_item", INTEGER, &pango_item }, { "pango_prompt", INTEGER, &pango_prompt }, diff --git a/options.h b/options.h index 09f28ee..1a67249 100644 --- a/options.h +++ b/options.h @@ -226,6 +226,7 @@ static int pango_password = 0; /* Enable support for pango markup f /* Misc */ 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 sgr = 1; /* Support SGR sequences (0/1) */ static char *worddelimiters = " "; /* Word delimiters used for keybinds that change words, Space is default. */ diff --git a/spmenu.1 b/spmenu.1 index ada2d1a..a0c7672 100644 --- a/spmenu.1 +++ b/spmenu.1 @@ -83,6 +83,12 @@ Don\[cq]t print index instead of actual text \f[V]-f, --fast\f[R] Grabs keyboard before reading stdin .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] Enable fuzzy matching .TP diff --git a/spmenu.html b/spmenu.html index dff1b87..2055f38 100644 --- a/spmenu.html +++ b/spmenu.html @@ -235,6 +235,14 @@ Don’t print index instead of actual text
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
Enable fuzzy matching