Some improvements for terminal mode

This commit is contained in:
Laurence Withers 2023-04-28 12:31:12 +01:00
parent bd0d1aaebe
commit 50da13d169
1 changed files with 12 additions and 0 deletions

12
main.go
View File

@ -32,9 +32,21 @@ func main() {
if res.column > 1 { if res.column > 1 {
unix.Write(1, []byte("🚫\n")) // U+1F6AB unix.Write(1, []byte("🚫\n")) // U+1F6AB
} }
term, _ := unix.IoctlGetTermios(1, unix.TCGETS)
if term != nil {
term.Lflag = term.Lflag &^ unix.ECHO
unix.IoctlSetTermios(1, unix.TCSETS, term)
}
for _, b := range res.extraBytes { for _, b := range res.extraBytes {
unix.Syscall(unix.SYS_IOCTL, 0, unix.TIOCSTI, uintptr(unsafe.Pointer(&b))) unix.Syscall(unix.SYS_IOCTL, 0, unix.TIOCSTI, uintptr(unsafe.Pointer(&b)))
} }
if term != nil {
term.Lflag = term.Lflag | unix.ECHO
unix.IoctlSetTermios(1, unix.TCSETS, term)
}
} }
func awaitDSR() <-chan dsrResult { func awaitDSR() <-chan dsrResult {