Introduction
Introduction Statistics Contact Development Disclaimer Help
dmenu-password-5.0.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dmenu-password-5.0.diff (3106B)
---
1 From c4de1032bd4c247bc20b6ab92a10a8d778966679 Mon Sep 17 00:00:00 2001
2 From: Mehrad Mahmoudian <[email protected]>
3 Date: Tue, 4 May 2021 12:05:09 +0300
4 Subject: [PATCH] patched with password patch
5
6 ---
7 dmenu.1 | 5 ++++-
8 dmenu.c | 21 +++++++++++++++++----
9 2 files changed, 21 insertions(+), 5 deletions(-)
10
11 diff --git a/dmenu.1 b/dmenu.1
12 index 323f93c..762f707 100644
13 --- a/dmenu.1
14 +++ b/dmenu.1
15 @@ -3,7 +3,7 @@
16 dmenu \- dynamic menu
17 .SH SYNOPSIS
18 .B dmenu
19 -.RB [ \-bfiv ]
20 +.RB [ \-bfivP ]
21 .RB [ \-l
22 .IR lines ]
23 .RB [ \-m
24 @@ -47,6 +47,9 @@ is faster, but will lock up X until stdin reaches end\…
25 .B \-i
26 dmenu matches menu items case insensitively.
27 .TP
28 +.B \-P
29 +dmenu will not directly display the keyboard input, but instead replace…
30 +.TP
31 .BI \-l " lines"
32 dmenu lists items vertically, with the given number of lines.
33 .TP
34 diff --git a/dmenu.c b/dmenu.c
35 index 65f25ce..ad8f63b 100644
36 --- a/dmenu.c
37 +++ b/dmenu.c
38 @@ -37,7 +37,7 @@ struct item {
39 static char text[BUFSIZ] = "";
40 static char *embed;
41 static int bh, mw, mh;
42 -static int inputw = 0, promptw;
43 +static int inputw = 0, promptw, passwd = 0;
44 static int lrpad; /* sum of left and right padding */
45 static size_t cursor;
46 static struct item *items = NULL;
47 @@ -132,6 +132,7 @@ drawmenu(void)
48 unsigned int curpos;
49 struct item *item;
50 int x = 0, y = 0, w;
51 + char *censort;
52
53 drw_setscheme(drw, scheme[SchemeNorm]);
54 drw_rect(drw, 0, 0, mw, mh, 1, 1);
55 @@ -143,7 +144,12 @@ drawmenu(void)
56 /* draw input field */
57 w = (lines > 0 || !matches) ? mw - x : inputw;
58 drw_setscheme(drw, scheme[SchemeNorm]);
59 - drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
60 + if (passwd) {
61 + censort = ecalloc(1, sizeof(text));
62 + memset(censort, '.', strlen(text));
63 + drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0);
64 + free(censort);
65 + } else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
66
67 curpos = TEXTW(text) - TEXTW(&text[cursor]);
68 if ((curpos += lrpad / 2 - 1) < w) {
69 @@ -524,6 +530,11 @@ readstdin(void)
70 char buf[sizeof text], *p;
71 size_t i, imax = 0, size = 0;
72 unsigned int tmpmax = 0;
73 + if(passwd){
74 + inputw = lines = 0;
75 + return;
76 + }
77 +
78
79 /* read each line from stdin and add it to the item list */
80 for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
81 @@ -689,7 +700,7 @@ setup(void)
82 static void
83 usage(void)
84 {
85 - fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] […
86 + fputs("usage: dmenu [-bfivP] [-l lines] [-p prompt] [-fn font] …
87 " [-nb color] [-nf color] [-sb color] [-sf co…
88 exit(1);
89 }
90 @@ -712,7 +723,9 @@ main(int argc, char *argv[])
91 else if (!strcmp(argv[i], "-i")) { /* case-insensitive …
92 fstrncmp = strncasecmp;
93 fstrstr = cistrstr;
94 - } else if (i + 1 == argc)
95 + } else if (!strcmp(argv[i], "-P")) /* is the input a …
96 + passwd = 1;
97 + else if (i + 1 == argc)
98 usage();
99 /* these options take one argument */
100 else if (!strcmp(argv[i], "-l")) /* number of lines i…
101 --
102 2.31.1
103
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.