aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdmenubin0 -> 44544 bytes
-rw-r--r--dmenu.15
-rw-r--r--dmenu.c21
-rwxr-xr-xstestbin0 -> 17680 bytes
4 files changed, 21 insertions, 5 deletions
diff --git a/dmenu b/dmenu
new file mode 100755
index 0000000..4a32929
--- /dev/null
+++ b/dmenu
Binary files differ
diff --git a/dmenu.1 b/dmenu.1
index 323f93c..762f707 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -3,7 +3,7 @@
3dmenu \- dynamic menu 3dmenu \- dynamic menu
4.SH SYNOPSIS 4.SH SYNOPSIS
5.B dmenu 5.B dmenu
6.RB [ \-bfiv ] 6.RB [ \-bfivP ]
7.RB [ \-l 7.RB [ \-l
8.IR lines ] 8.IR lines ]
9.RB [ \-m 9.RB [ \-m
@@ -47,6 +47,9 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
47.B \-i 47.B \-i
48dmenu matches menu items case insensitively. 48dmenu matches menu items case insensitively.
49.TP 49.TP
50.B \-P
51dmenu will not directly display the keyboard input, but instead replace it with dots. All data from stdin will be ignored.
52.TP
50.BI \-l " lines" 53.BI \-l " lines"
51dmenu lists items vertically, with the given number of lines. 54dmenu lists items vertically, with the given number of lines.
52.TP 55.TP
diff --git a/dmenu.c b/dmenu.c
index 635f204..b1f1d3d 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -41,7 +41,7 @@ struct item {
41static char text[BUFSIZ] = ""; 41static char text[BUFSIZ] = "";
42static char *embed; 42static char *embed;
43static int bh, mw, mh; 43static int bh, mw, mh;
44static int inputw = 0, promptw; 44static int inputw = 0, promptw, passwd = 0;
45static int lrpad; /* sum of left and right padding */ 45static int lrpad; /* sum of left and right padding */
46static size_t cursor; 46static size_t cursor;
47static struct item *items = NULL; 47static struct item *items = NULL;
@@ -198,6 +198,7 @@ drawmenu(void)
198 unsigned int curpos; 198 unsigned int curpos;
199 struct item *item; 199 struct item *item;
200 int x = 0, y = 0, w; 200 int x = 0, y = 0, w;
201 char *censort;
201 202
202 drw_setscheme(drw, scheme[SchemeNorm]); 203 drw_setscheme(drw, scheme[SchemeNorm]);
203 drw_rect(drw, 0, 0, mw, mh, 1, 1); 204 drw_rect(drw, 0, 0, mw, mh, 1, 1);
@@ -209,7 +210,12 @@ drawmenu(void)
209 /* draw input field */ 210 /* draw input field */
210 w = (lines > 0 || !matches) ? mw - x : inputw; 211 w = (lines > 0 || !matches) ? mw - x : inputw;
211 drw_setscheme(drw, scheme[SchemeNorm]); 212 drw_setscheme(drw, scheme[SchemeNorm]);
212 drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); 213 if (passwd) {
214 censort = ecalloc(1, sizeof(text));
215 memset(censort, '.', strlen(text));
216 drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0);
217 free(censort);
218 } else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
213 219
214 curpos = TEXTW(text) - TEXTW(&text[cursor]); 220 curpos = TEXTW(text) - TEXTW(&text[cursor]);
215 if ((curpos += lrpad / 2 - 1) < w) { 221 if ((curpos += lrpad / 2 - 1) < w) {
@@ -687,6 +693,11 @@ readstdin(void)
687 size_t i, junk, size = 0; 693 size_t i, junk, size = 0;
688 ssize_t len; 694 ssize_t len;
689 695
696 if(passwd){
697 inputw = lines = 0;
698 return;
699 }
700
690 /* read each line from stdin and add it to the item list */ 701 /* read each line from stdin and add it to the item list */
691 for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++, line = NULL) { 702 for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++, line = NULL) {
692 if (i + 1 >= size / sizeof *items) 703 if (i + 1 >= size / sizeof *items)
@@ -847,7 +858,7 @@ setup(void)
847static void 858static void
848usage(void) 859usage(void)
849{ 860{
850 die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" 861 die("usage: dmenu [-bfivP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
851 " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]"); 862 " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
852} 863}
853 864
@@ -871,7 +882,9 @@ main(int argc, char *argv[])
871 else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ 882 else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
872 fstrncmp = strncasecmp; 883 fstrncmp = strncasecmp;
873 fstrstr = cistrstr; 884 fstrstr = cistrstr;
874 } else if (i + 1 == argc) 885 } else if (!strcmp(argv[i], "-P")) /* is the input a password */
886 passwd = 1;
887 else if (i + 1 == argc)
875 usage(); 888 usage();
876 /* these options take one argument */ 889 /* these options take one argument */
877 else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ 890 else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
diff --git a/stest b/stest
new file mode 100755
index 0000000..d2d6ca3
--- /dev/null
+++ b/stest
Binary files differ