Skip to content
Myr

main/render: add --password=[CHARACTER] command line option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Intended to be used with --dmenu, for password inputs, but _can_ be used with normal mode as well. With “fuzzel --password”, all typed text is rendered as ‘*’. One can specify a different password character with “fuzzel --password=X”. Closes #108

authored by Daniel Eklöf · committed by Daniel Eklöf · parent bd08b63 · Browse files · 5 files+42 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+42 added−2 removed

  • other:+42 added−2 removed

5 files+42 added−2 removed

modified:doc/fuzzel.scd+5 added-1 removed
68 unmodified lines
6970*-I*,*--no-icons*71 Do not render any icons.7273*-F*,*--fields*=FIELDS73*-F*,*--fields*=_FIELDS_74 Comma separated list of XDG Desktop entry fields to match against:75 76 - *filename*: the .desktop file's filename77 - *name*: the application's name (title)
4 unmodified lines
82 - *comment*: the application's comment83 84 Default: _filename,name,generic_8586*--password*=[_CHARACTER_]87 Password input. Render all typed text as _CHARACTER_. If88 _CHARACTER_ is omitted, a *\** will be used.8990*-T*,*--terminal*=_TERMINAL ARGS_91 Command to launch XDG applications with the property92 *Terminal=true* (_htop_, for example). Example: _xterm -e_.93 Default: _not set_.
152 unmodified lines
modified:CHANGELOG.md+4 added
21 unmodified lines
22### Added2324* If `argv[0]` is _dmenu_, fuzzel now starts in dmenu mode25 (https://codeberg.org/dnkl/fuzzel/issues/107).26* `--password=[CHARACTER]` command line option. Intended to be used27 with “password input”; all typed text is rendered as _CHARACTER_,28 defaulting to `*` if _CHARACTER_ is omitted29 (https://codeberg.org/dnkl/fuzzel/issues/108).303132### Changed33
313 unmodified lines
modified:main.c+23 added
208 unmodified lines
209 " -i,--icon-theme=NAME icon theme name (\"hicolor\")\n"210 " -I,--no-icons do not render any icons\n"211 " -F,--fields=FIELDS comma separated list of XDG Desktop entry\n"212 " fields to match\n"213 " --password=[CHARACTER] render all input as CHARACTER ('*' by default)\n"214 " -T,--terminal terminal command to use when launching\n"215 " 'terminal' programs, e.g. \"xterm -e\".\n"216 " Not used in dmenu mode (not set)\n"217 " -l,--lines number of matches to show\n"
256 unmodified lines
474 #define OPT_DMENU_INDEX 263475 #define OPT_LOG_LEVEL 264476 #define OPT_LOG_COLORIZE 265477 #define OPT_LOG_NO_SYSLOG 266478 #define OPT_PASSWORD 267479480 static const struct option longopts[] = {481 {"output" , required_argument, 0, 'o'},482 {"font", required_argument, 0, 'f'},483 {"dpi-aware", required_argument, 0, 'D'},484 {"icon-theme", required_argument, 0, 'i'},485 {"no-icons", no_argument, 0, 'I'},486 {"fields", required_argument, 0, 'F'},487 {"password", optional_argument, 0, OPT_PASSWORD},488 {"lines", required_argument, 0, 'l'},489 {"width", required_argument, 0, 'w'},490 {"horizontal-pad", required_argument, 0, 'x'},491 {"vertical-pad", required_argument, 0, 'y'},
62 unmodified lines
554 .chars = 30,555 .border_size = 1u,556 .border_radius = 10u,557 .pad = {.x = 40, .y = 8, .inner = 0},558 .password = false,559 .background_color = hex_to_rgba(0xfdf6e3dd),560 .border_color = hex_to_rgba(0x002b36ff),561 .text_color = hex_to_rgba(0x657b83ff),562 .match_color = hex_to_rgba(0xcb4b16ff),
106 unmodified lines
669 }670 break;671 }672673 case OPT_PASSWORD: {674 char32_t password_char = U'*';675 if (optarg != NULL) {676 char32_t *wide_optarg = ambstoc32(optarg);677 if (c32len(wide_optarg) != 1) {678 fprintf(679 stderr,680 "%s: password character must be a single character\n",681 optarg);682 free(wide_optarg);683 return EXIT_FAILURE;684 }685 password_char = wide_optarg[0];686 free(wide_optarg);687 }688 render_options.password = password_char;689 break;690 }691692 case 'T':693 terminal = optarg;694 break;695
441 unmodified lines
modified:render.c+9 added-1 removed
172 unmodified lines
173{174 struct fcft_font *font = render->font;175 assert(font != NULL);176177 const struct render_options *opts = &render->options;178179 const char32_t *pprompt = prompt_prompt(prompt);180 const size_t prompt_len = c32len(pprompt);181182 const char32_t *ptext = prompt_text(prompt);
9 unmodified lines
192193 char32_t prev = 0;194195 for (size_t i = 0; i < prompt_len + text_len; i++) {194 char32_t wc = i < prompt_len ? pprompt[i] : ptext[i - prompt_len];196 char32_t wc = i < prompt_len197 ? pprompt[i]198 : (opts->password != 0199 ? opts->password200 : ptext[i - prompt_len]);201202 const struct fcft_glyph *glyph = fcft_rasterize_char_utf32(203 font, wc, subpixel);204205 if (glyph == NULL) {206 prev = wc;207 continue;208 }
546 unmodified lines
modified:render.h+1 added
20 unmodified lines
21 unsigned x;22 unsigned y;23 unsigned inner;24 } pad;25 char32_t password;2627 struct rgba background_color;28 struct rgba border_color;29 struct rgba text_color;
35 unmodified lines