config: allow password-character to be the empty string
Before adoption: this commit came in with the history the project adopted, so no landing records it.
When it is, nothing is rendered on the prompt, and the cursor is not advanced. Closes #263
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 7270665 · Browse files · 5 files·+33 added−7 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+33 added−7 removed
- other:+33 added−7 removed
Provenance
- Commit
df1e754- Tree
3d104bd- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
7270665
5 files changed+33 added−7 removed
modified:CHANGELOG.md+3 added
60 unmodified lines61 * Exact matches (of the application title) are now sorted first62 ([#259][259]).63 * Set default log level to warning ([#266][266]).64 * Rename `delete-line` binding to `delete-line-forward` ([#307][307]).65+* `password-character` can now be set to the empty string66+ ([#263][263]).67 68 [255]: https://codeberg.org/dnkl/fuzzel/issues/25569 [259]: https://codeberg.org/dnkl/fuzzel/issues/25970 [266]: https://codeberg.org/dnkl/fuzzel/pulls/26671+[263]: https://codeberg.org/dnkl/fuzzel/issues/26372 73 74 ### Deprecated75 ### Removed555 unmodified linesmodified:config.c+8 added-1 removed
838 unmodified lines839 }840 841 else if (strcmp(key, "password-character") == 0) {842 char32_t *password_chars = ambstoc32(value);843- if (password_chars == NULL || c32len(password_chars) != 1) {843+ if (password_chars == NULL) {844 LOG_CONTEXTUAL_ERR("invalid password character");845+ return false;846+ }847+848+ if (c32len(password_chars) > 1) {849+ LOG_CONTEXTUAL_ERR(850+ "password character must be a single character, or empty");851 free(password_chars);852 return false;853 }854 855 conf->password_mode.character = password_chars[0];856+ conf->password_mode.character_set = true;857 free(password_chars);858 return true;859 }860 791 unmodified linesmodified:config.h+1 added
95 unmodified lines96 97 struct {98 char32_t character;99 bool enabled;100+ bool character_set;101 } password_mode;102 103 char *terminal;104 char *launch_prefix;73 unmodified linesmodified:main.c+14 added-6 removed
784 unmodified lines785 case OPT_PASSWORD: {786 char32_t password_char = U'\0';787 if (optarg != NULL) {788 char32_t *wide_optarg = ambstoc32(optarg);789+ if (wide_optarg == NULL){790+ fprintf(stderr, "%s: invalid password character\n", optarg);791+ return EXIT_FAILURE;792+ }793+789- if (c32len(wide_optarg) != 1) {794+ if (c32len(wide_optarg) > 1) {795 fprintf(796 stderr,797 "%s: password character must be a single character\n",798 optarg);799 free(wide_optarg);800 return EXIT_FAILURE;801 }802+803 password_char = wide_optarg[0];804 free(wide_optarg);805+ cmdline_overrides.conf.password_mode.character_set = true;806 }807+808 cmdline_overrides.conf.password_mode.enabled = true;809 cmdline_overrides.conf.password_mode.character = password_char;810 break;811 }428 unmodified lines1240 }1241 if (cmdline_overrides.conf.password_mode.enabled) {1242 conf.password_mode.enabled = true;1243 conf.password_mode.character =1236- cmdline_overrides.conf.password_mode.character != U'\0'1237- ? cmdline_overrides.conf.password_mode.character1238- : conf.password_mode.character != U'\0'1239- ? conf.password_mode.character1240- : U'*';1244+ cmdline_overrides.conf.password_mode.character_set1245+ ? cmdline_overrides.conf.password_mode.character1246+ : conf.password_mode.character_set1247+ ? conf.password_mode.character1248+ : U'*';1249 }1250 if (cmdline_overrides.conf.terminal != NULL) {1251 free(conf.terminal);1252 conf.terminal = strdup(cmdline_overrides.conf.terminal);300 unmodified linesmodified:render.c+7 added
229 unmodified lines230 231 char32_t prev = 0;232 233 for (size_t i = 0; i < prompt_len + text_len; i++) {234+ if (i >= prompt_len &&235+ conf->password_mode.enabled &&236+ conf->password_mode.character == U'\0')237+ {238+ continue;239+ }240+241 char32_t wc = i < prompt_len242 ? pprompt[i]243 : (conf->password_mode.enabled244 ? conf->password_mode.character620 unmodified lines