- split exported functions from implementation - windows: IsConsole(): fix deprecation comment - deprecate Termios in favor of unix.Termios - windows: keyToString(): fix string conversion - gha: update actions, add macOS, and add Go1.20 - gha: add windows full diff: https://github.com/moby/term/compare/c43b287e0e0f...v0.5.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
38 lines
905 B
Go
38 lines
905 B
Go
package term
|
|
|
|
import "golang.org/x/sys/windows"
|
|
|
|
func makeRaw(fd uintptr) (*State, error) {
|
|
state, err := SaveState(fd)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
mode := state.mode
|
|
|
|
// See
|
|
// -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx
|
|
// -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms683462(v=vs.85).aspx
|
|
|
|
// Disable these modes
|
|
mode &^= windows.ENABLE_ECHO_INPUT
|
|
mode &^= windows.ENABLE_LINE_INPUT
|
|
mode &^= windows.ENABLE_MOUSE_INPUT
|
|
mode &^= windows.ENABLE_WINDOW_INPUT
|
|
mode &^= windows.ENABLE_PROCESSED_INPUT
|
|
|
|
// Enable these modes
|
|
mode |= windows.ENABLE_EXTENDED_FLAGS
|
|
mode |= windows.ENABLE_INSERT_MODE
|
|
mode |= windows.ENABLE_QUICK_EDIT_MODE
|
|
if vtInputSupported {
|
|
mode |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT
|
|
}
|
|
|
|
err = windows.SetConsoleMode(windows.Handle(fd), mode)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return state, nil
|
|
}
|