On Tuesday, 17 October 2017 at 15:02:29 UTC, Adam D. Ruppe wrote:
Or try this newest commit https://github.com/adamdruppe/arsd/blob/master/terminal.d and see if it works better for you.

- Here is what I use in one of my tools... and I never had problems with German password so far ;)

string getPassword(char mask = '*')
{
        import std.stdio;
        import libs.terminal;
        auto term = Terminal(ConsoleOutputType.linear);
        auto input = RealTimeConsoleInput(&term, ConsoleInputFlags.raw);
        string pass;
        dchar ch;
        ch = input.getch();
        while(ch != '\r' && ch != '\n')
        {
                import std.range;
                if(ch == '\b' && !pass.empty)
                {
                        pass = pass[0..$-1];
                        write('\b');
                        stdout.flush;
                }
                else
                {
                        pass ~= ch;
                        write(mask);
                        stdout.flush();
                }
                ch = input.getch();
        }
        return pass;
}

Reply via email to