From 9a64f80182f8c03fe65586f4bc098f65decdd268 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 3 Jun 2018 17:11:11 +0200 Subject: [PATCH] handle backspace when entering password --- retroshare-nogui/src/TerminalApiClient.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/retroshare-nogui/src/TerminalApiClient.cpp b/retroshare-nogui/src/TerminalApiClient.cpp index f4ffa4af1..b90ed7dbc 100644 --- a/retroshare-nogui/src/TerminalApiClient.cpp +++ b/retroshare-nogui/src/TerminalApiClient.cpp @@ -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