Password input now works

This commit is contained in:
Kovid Goyal 2022-08-24 22:39:46 +05:30
parent 619fcb0681
commit c2ef6c986b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -68,7 +68,7 @@ func (self *Loop) handle_csi(raw []byte) error {
}
func (self *Loop) handle_key_event(ev *KeyEvent) error {
// self.controlling_term.DebugPrintln(ev)
// self.DebugPrintln(ev)
if self.OnKeyEvent != nil {
err := self.OnKeyEvent(self, ev)
if err != nil {

View File

@ -43,13 +43,13 @@ func ReadPassword(prompt string, kill_if_signaled bool) (password string, err er
}
loop.OnKeyEvent = func(loop *Loop, event *KeyEvent) error {
if event.MatchesPressOrRepeat("backscape") || event.MatchesPressOrRepeat("delete") {
if event.MatchesPressOrRepeat("backspace") || event.MatchesPressOrRepeat("delete") {
event.Handled = true
if len(password) > 0 {
old_width := wcswidth.Stringwidth(password)
password = password[:len(password)-1]
new_width := wcswidth.Stringwidth(password)
delta := new_width - old_width
delta := old_width - new_width
if delta > 0 {
if delta > len(shadow) {
delta = len(shadow)