diff options
author | sewn <sewn@disroot.org> | 2024-03-10 18:00:48 +0300 |
---|---|---|
committer | adnano <me@adnano.co> | 2024-03-17 07:33:55 -0400 |
commit | 9e9284666c9fcf3278ad17f98a247658db8b2269 (patch) | |
tree | bcbba30593e468ee5e8186291ccad6556a3c21ab /render.c | |
parent | 6ad7a303ef2ff130b84cfa718ace423a3101dbbb (diff) | |
download | wmenu-9e9284666c9fcf3278ad17f98a247658db8b2269.tar.gz |
port dmenu password patch
Diffstat (limited to 'render.c')
-rw-r--r-- | render.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -1,4 +1,7 @@ +#define _POSIX_C_SOURCE 200809L #include <cairo/cairo.h> +#include <stdlib.h> +#include <string.h> #include "render.h" @@ -72,8 +75,22 @@ static void render_prompt(struct menu *menu, cairo_t *cairo) { // Renders the input text. static void render_input(struct menu *menu, cairo_t *cairo) { - render_text(menu, cairo, menu->input, menu->promptw, 0, 0, - 0, menu->normalfg, menu->padding, menu->padding); + char *censort = NULL; + + if (menu->passwd) { + censort = calloc(1, sizeof(menu->input)); + if (!censort) { + return; + } + memset(censort, '*', strlen(menu->input)); + } + + render_text(menu, cairo, menu->passwd ? censort : menu->input, + menu->promptw, 0, 0, 0, menu->normalfg, menu->padding, menu->padding); + + if (censort) { + free(censort); + } } // Renders a cursor for the input field. |