forked from sloum/bombadillo
Handle input errors while returning to correct terminal mode
This commit is contained in:
parent
97b74ea767
commit
2f8eedded7
|
@ -102,6 +102,7 @@ func Getch() rune {
|
||||||
|
|
||||||
func GetLine(prefix string) (string, error) {
|
func GetLine(prefix string) (string, error) {
|
||||||
termios.SetLineMode()
|
termios.SetLineMode()
|
||||||
|
defer termios.SetCharMode()
|
||||||
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
fmt.Print(prefix)
|
fmt.Print(prefix)
|
||||||
|
@ -110,7 +111,6 @@ func GetLine(prefix string) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
termios.SetCharMode()
|
|
||||||
return text[:len(text)-1], nil
|
return text[:len(text)-1], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue