Password input now works
This commit is contained in:
parent
619fcb0681
commit
c2ef6c986b
@ -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 {
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user