diff options
author | justsaumit <justsaumit@draconyan.xyz> | 2022-03-02 09:51:28 +0530 |
---|---|---|
committer | justsaumit <justsaumit@draconyan.xyz> | 2022-03-02 09:51:28 +0530 |
commit | 2781cf2a74772f02a7dad181a251d839c6d21385 (patch) | |
tree | 0393431ca40c2b4e3933d0cbc74e727ecc14c388 /dmenu.c | |
parent | 21aa33f08ff6ba1fc9181c25da718a07f4b18154 (diff) |
instant patch (-n)
Diffstat (limited to 'dmenu.c')
-rw-r--r-- | dmenu.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -323,6 +323,13 @@ match(void) matchend = substrend; } curr = sel = matches; + + if(instant && matches && matches==matchend && !lsubstr) { + puts(matches->text); + cleanup(); + exit(0); + } + calcoffsets(); } @@ -773,7 +780,7 @@ setup(void) static void usage(void) { - fputs("usage: dmenu [-bfivP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + fputs("usage: dmenu [-bfinvP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n" " [-hb color] [-hf color] [-hp items]\n", stderr); @@ -828,14 +835,17 @@ main(int argc, char *argv[]) exit(0); } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ topbar = 0; - else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ + else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = 1; - else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; - } else if (!strcmp(argv[i], "-P")) /* is the input a password */ + } + else if (!strcmp(argv[i], "-P")) /* is the input a password */ passwd = 1; - else if (i + 1 == argc) + else if (!strcmp(argv[i], "-n")) /* instant select only match */ + instant = 1; + else if (i + 1 == argc) usage(); /* these options take one argument */ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ |