Merge pull request #1278 from sehraf/pr_improve-nogui-password-entry

handle backspace when entering password
This commit is contained in:
csoler 2018-07-08 16:59:52 +02:00 committed by GitHub
commit 0bc77749d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,6 +103,15 @@ static std::string readStringFromKeyboard(bool passwd_mode)
while((c=getchar()) != '\n')
{
// handle backspace
if (c == 127) {
if(s.length()!=0) {
std::cout << "\b \b";
s.resize(s.length()-1);
}
continue;
}
if(passwd_mode)
putchar('*') ;
else