Files
odo/pkg/watch/key_watcher_windows.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

21 lines
626 B
Go

package watch
import (
"golang.org/x/sys/windows"
)
// enableCharInput is inspired from Windows 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://docs.microsoft.com/en-us/windows/console/setconsolemode for reference
func enableCharInput(fd int) error {
var st uint32
if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
return err
}
raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT)
if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
return err
}
return nil
}