Files
odo/pkg/watch/key_watcher_unix.go
Philippe Martin 59f4f8348a Manual sync of files pressing p (#6089)
* Set character mode for input stream

* Move watchers in receiver + sync when p pressed

* Integration tests manual sync

* Add a console to DevSession

* Vendor

* Skip pressKey tests on Windows

* Add interactive test for p press

* Add info about pressing p key

* Doc

* Review

* Rephrase Manul sync

* Fix HotReloadCapable

* Document timers

* Document enableCharInput

* Document geyKey and getKeyWatcher functions

* Avoid to Kill in AfterEach after running Kill before
2022-09-09 18:54:54 +02:00

25 lines
739 B
Go

//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
package watch
import (
"golang.org/x/sys/unix"
)
// enableCharInput is inspired from the Unix implementation of MakeRaw in golang.org/x/term
// It enables the treatment of input stream char by char instead of line by line
// See https://man7.org/linux/man-pages/man3/termios.3.html for reference
func enableCharInput(fd int) error {
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
if err != nil {
return err
}
termios.Lflag &^= unix.ICANON
if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, termios); err != nil {
return err
}
return nil
}