forked from speedie/spmenu
add option to change the password character
This commit is contained in:
parent
38b568b997
commit
e6be5d5aad
|
@ -26,6 +26,7 @@ On top of this, you can specify arguments to change the behavior of spmenu. See
|
||||||
- spmenu -f - Grabs keyboard before reading stdin
|
- spmenu -f - Grabs keyboard before reading stdin
|
||||||
- spmenu -F - Enable fuzzy matching
|
- spmenu -F - Enable fuzzy matching
|
||||||
- spmenu -P - Hide characters
|
- spmenu -P - Hide characters
|
||||||
|
- spmenu -Ps symbol - Set the password symbol to symbol
|
||||||
- spmenu -p text - Set spmenu prompt text to text
|
- spmenu -p text - Set spmenu prompt text to text
|
||||||
- spmenu -a - Enable alpha
|
- spmenu -a - Enable alpha
|
||||||
- spmenu -na - Disable alpha
|
- spmenu -na - Disable alpha
|
||||||
|
|
|
@ -58,6 +58,7 @@ spmenu.type: 1
|
||||||
spmenu.class: spmenu
|
spmenu.class: spmenu
|
||||||
spmenu.leftarrow: <
|
spmenu.leftarrow: <
|
||||||
spmenu.rightarrow: >
|
spmenu.rightarrow: >
|
||||||
|
spmenu.password: .
|
||||||
spmenu.imagewidth: 86
|
spmenu.imagewidth: 86
|
||||||
spmenu.imageheight: 86
|
spmenu.imageheight: 86
|
||||||
spmenu.imagegaps: 0
|
spmenu.imagegaps: 0
|
||||||
|
|
|
@ -96,6 +96,8 @@ readargs(int argc, char *argv[])
|
||||||
else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
|
else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
|
||||||
columns = atoi(argv[++i]);
|
columns = atoi(argv[++i]);
|
||||||
if (lines == 0) lines = 1;
|
if (lines == 0) lines = 1;
|
||||||
|
} else if (!strcmp(argv[i], "-Ps")) { /* password symbol */
|
||||||
|
password = argv[++i];
|
||||||
} else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
|
} else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
|
||||||
lines = atoi(argv[++i]);
|
lines = atoi(argv[++i]);
|
||||||
} else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
|
} else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
|
||||||
|
@ -252,6 +254,7 @@ usage(void)
|
||||||
"spmenu -f Grabs keyboard before reading stdin\n"
|
"spmenu -f Grabs keyboard before reading stdin\n"
|
||||||
"spmenu -F Enable fuzzy matching\n"
|
"spmenu -F Enable fuzzy matching\n"
|
||||||
"spmenu -P Hide characters\n"
|
"spmenu -P Hide characters\n"
|
||||||
|
"spmenu -Ps <symbol> Set the password symbol to <symbol>\n"
|
||||||
"spmenu -p <text> Set spmenu prompt text to <text>\n"
|
"spmenu -p <text> Set spmenu prompt text to <text>\n"
|
||||||
"spmenu -a Enable alpha\n"
|
"spmenu -a Enable alpha\n"
|
||||||
"spmenu -na Disable alpha\n"
|
"spmenu -na Disable alpha\n"
|
||||||
|
|
|
@ -143,13 +143,14 @@ drawmenu(void)
|
||||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||||
drw_setscheme(drw, scheme[SchemeInput]);
|
drw_setscheme(drw, scheme[SchemeInput]);
|
||||||
if (passwd && !hideprompt) {
|
if (passwd && !hideprompt) {
|
||||||
censort = ecalloc(1, sizeof(text));
|
censort = ecalloc(pango_input ? TEXTWM(password) : TEXTW(password), sizeof(text));
|
||||||
memset(censort, '.', strlen(text));
|
memset(censort, *password, strlen(text));
|
||||||
|
|
||||||
apply_fribidi(censort);
|
apply_fribidi(censort);
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, isrtl ? fribidi_text : censort, 0, pango_password ? True : False);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, isrtl ? fribidi_text : censort, 0, pango_password ? True : False);
|
||||||
|
|
||||||
curpos = TEXTW(censort) - TEXTW(&text[cursor]);
|
curpos = TEXTW(censort) - TEXTW(&text[cursor]);
|
||||||
|
|
||||||
free(censort);
|
free(censort);
|
||||||
} else if (!passwd && !hideprompt) {
|
} else if (!passwd && !hideprompt) {
|
||||||
apply_fribidi(text);
|
apply_fribidi(text);
|
||||||
|
|
|
@ -41,6 +41,7 @@ static char font[] = "Noto Sans Mono 8"; /* Font to draw tex
|
||||||
/* Symbol options */
|
/* Symbol options */
|
||||||
static char *leftarrow = "<"; /* Left arrow, used to indicate you can move to the left */
|
static char *leftarrow = "<"; /* Left arrow, used to indicate you can move to the left */
|
||||||
static char *rightarrow = ">"; /* Right arrow, used to indicate you can move to the right */
|
static char *rightarrow = ">"; /* Right arrow, used to indicate you can move to the right */
|
||||||
|
static char *password = "."; /* Password character, when the -P argument is active this will replace all characters typed */
|
||||||
|
|
||||||
/* Match options */
|
/* Match options */
|
||||||
static int type = 1; /* Allow typing into spmenu or only allow keybinds. */
|
static int type = 1; /* Allow typing into spmenu or only allow keybinds. */
|
||||||
|
|
2
spmenu.1
2
spmenu.1
|
@ -63,6 +63,8 @@ spmenu -F - Enable fuzzy matching
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
spmenu -P - Hide characters
|
spmenu -P - Hide characters
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
spmenu -Ps symbol - Set the password symbol to symbol
|
||||||
|
.IP \[bu] 2
|
||||||
spmenu -p text - Set spmenu prompt text to text
|
spmenu -p text - Set spmenu prompt text to text
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
spmenu -a - Enable alpha
|
spmenu -a - Enable alpha
|
||||||
|
|
6
spmenu.c
6
spmenu.c
|
@ -223,8 +223,10 @@ setimgsize(const Arg *arg)
|
||||||
imageheight += arg->i;
|
imageheight += arg->i;
|
||||||
imagewidth += arg->i;
|
imagewidth += arg->i;
|
||||||
|
|
||||||
if (!imageheight || !imagewidth)
|
if (!imageheight || !imagewidth || !longestedge) {
|
||||||
imageheight = imagewidth = 1;
|
imageheight = imagewidth = longestedge = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
drawmenu();
|
drawmenu();
|
||||||
drawimage();
|
drawimage();
|
||||||
|
|
|
@ -98,6 +98,7 @@ ResourcePref resources[] = {
|
||||||
{ "type", INTEGER, &type },
|
{ "type", INTEGER, &type },
|
||||||
{ "preselected", INTEGER, &preselected },
|
{ "preselected", INTEGER, &preselected },
|
||||||
{ "colorprompt", INTEGER, &colorprompt },
|
{ "colorprompt", INTEGER, &colorprompt },
|
||||||
|
{ "password", STRING, &password },
|
||||||
{ "prompt", STRING, &prompt },
|
{ "prompt", STRING, &prompt },
|
||||||
{ "class", STRING, &class },
|
{ "class", STRING, &class },
|
||||||
{ "leftarrow", STRING, &leftarrow },
|
{ "leftarrow", STRING, &leftarrow },
|
||||||
|
|
Loading…
Reference in a new issue