commit 1d362372b0ef0dfa9060086d6197990273d8cd1b
parent f2ef8fa16fa732cc3fe645ace1f8a64d0763060c
Author: hhvn <dev@hhvn.uk>
Date: Sat, 12 Jun 2021 17:04:35 +0100
dmenu.c config.h dmenu.1: apply and fix incremental patch
Diffstat:
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/config.h b/config.h
@@ -3,6 +3,7 @@
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
static int centered = 1; /* -c option; centers dmenu on screen */
+static int incremental = 0; /* -r option; incrementally output text */
static int fuzzy = 1;
static int lineheight = 20;
static unsigned int dmw = 600;
diff --git a/dmenu.1 b/dmenu.1
@@ -3,7 +3,7 @@
dmenu \- dynamic menu
.SH SYNOPSIS
.B dmenu
-.RB [ \-bfivP ]
+.RB [ \-bfivPr ]
.RB [ \-l
.IR lines ]
.RB [ \-m
@@ -84,6 +84,9 @@ from 0.
.BI \-p " prompt"
defines the prompt to be displayed to the left of the input field.
.TP
+.B \-r
+dmenu outputs text each time a key is pressed.
+.TP
.BI \-fn " font"
defines the font or font set used.
.TP
diff --git a/dmenu.c b/dmenu.c
@@ -626,6 +626,10 @@ keypress(XKeyEvent *ev)
match();
break;
}
+ if (incremental) {
+ puts(text);
+ fflush(stdout);
+ }
draw:
drawmenu();
@@ -849,7 +853,7 @@ setup(void)
static void
usage(void)
{
- fputs("usage: dmenu [-bfiPv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ fputs("usage: dmenu [-bfiPvr] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
" [-h height] [-w width]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
exit(1);
@@ -870,6 +874,8 @@ main(int argc, char *argv[])
topbar = 0;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
+ else if (!strcmp(argv[i], "-r"))
+ incremental = 1;
else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
centered = 0;
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */