handle backspace when entering password

This commit is contained in:
sehraf 2018-06-03 17:11:11 +02:00
parent 6bb1d3c509
commit 9a64f80182
No known key found for this signature in database
GPG Key ID: DF09F6EAE356B2C6

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