AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 350 forks source link

Added customisable hide character for password inputs. #431

Closed SirRegion closed 1 year ago

SirRegion commented 2 years ago

Hi @AlecAivazis and @mislav!

I had some free time so I tried my hand on implementing #386.

Changing the hide character of the password field works as expected. However, using an empty rune just results in the characters not getting hidden at all.

The best workaround for this is setting the custom hide character to an zero width space. This results in the behaviour required by the original poster.

I included an example for the password input, but I did not write a test for the behaviour. I also noticed that the existing password tests don't actually validate that the input is hidden, just that is is stored correctly. I'm sadly incapable of fixing those two issues.

AlecAivazis commented 1 year ago

Thanks for putting this together @SirRegion! Mind putting a little note in the docs about the zero space width?

AlecAivazis commented 1 year ago

@SirRegion there is now a merge conflct. I'd be happy to merge this once its ready (I can add the documentation after)