The missing console mode constants were added to go-ansiterm in
Azure/go-ansiterm#23. Use these constants instead of defining them
locally.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
| ... | ... |
@@ -23,14 +23,7 @@ type Winsize struct {
|
| 23 | 23 |
Width uint16 |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-const ( |
|
| 27 |
- // https://msdn.microsoft.com/en-us/library/windows/desktop/ms683167(v=vs.85).aspx |
|
| 28 |
- enableVirtualTerminalInput = 0x0200 |
|
| 29 |
- enableVirtualTerminalProcessing = 0x0004 |
|
| 30 |
- disableNewlineAutoReturn = 0x0008 |
|
| 31 |
-) |
|
| 32 |
- |
|
| 33 |
-// vtInputSupported is true if enableVirtualTerminalInput is supported by the console |
|
| 26 |
+// vtInputSupported is true if winterm.ENABLE_VIRTUAL_TERMINAL_INPUT is supported by the console |
|
| 34 | 27 |
var vtInputSupported bool |
| 35 | 28 |
|
| 36 | 29 |
// StdStreams returns the standard streams (stdin, stdout, stderr). |
| ... | ... |
@@ -40,8 +33,8 @@ func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
| 40 | 40 |
var emulateStdin, emulateStdout, emulateStderr bool |
| 41 | 41 |
fd := os.Stdin.Fd() |
| 42 | 42 |
if mode, err := winterm.GetConsoleMode(fd); err == nil {
|
| 43 |
- // Validate that enableVirtualTerminalInput is supported, but do not set it. |
|
| 44 |
- if err = winterm.SetConsoleMode(fd, mode|enableVirtualTerminalInput); err != nil {
|
|
| 43 |
+ // Validate that winterm.ENABLE_VIRTUAL_TERMINAL_INPUT is supported, but do not set it. |
|
| 44 |
+ if err = winterm.SetConsoleMode(fd, mode|winterm.ENABLE_VIRTUAL_TERMINAL_INPUT); err != nil {
|
|
| 45 | 45 |
emulateStdin = true |
| 46 | 46 |
} else {
|
| 47 | 47 |
vtInputSupported = true |
| ... | ... |
@@ -53,21 +46,21 @@ func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
| 53 | 53 |
|
| 54 | 54 |
fd = os.Stdout.Fd() |
| 55 | 55 |
if mode, err := winterm.GetConsoleMode(fd); err == nil {
|
| 56 |
- // Validate disableNewlineAutoReturn is supported, but do not set it. |
|
| 57 |
- if err = winterm.SetConsoleMode(fd, mode|enableVirtualTerminalProcessing|disableNewlineAutoReturn); err != nil {
|
|
| 56 |
+ // Validate winterm.DISABLE_NEWLINE_AUTO_RETURN is supported, but do not set it. |
|
| 57 |
+ if err = winterm.SetConsoleMode(fd, mode|winterm.ENABLE_VIRTUAL_TERMINAL_PROCESSING|winterm.DISABLE_NEWLINE_AUTO_RETURN); err != nil {
|
|
| 58 | 58 |
emulateStdout = true |
| 59 | 59 |
} else {
|
| 60 |
- winterm.SetConsoleMode(fd, mode|enableVirtualTerminalProcessing) |
|
| 60 |
+ winterm.SetConsoleMode(fd, mode|winterm.ENABLE_VIRTUAL_TERMINAL_PROCESSING) |
|
| 61 | 61 |
} |
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
fd = os.Stderr.Fd() |
| 65 | 65 |
if mode, err := winterm.GetConsoleMode(fd); err == nil {
|
| 66 |
- // Validate disableNewlineAutoReturn is supported, but do not set it. |
|
| 67 |
- if err = winterm.SetConsoleMode(fd, mode|enableVirtualTerminalProcessing|disableNewlineAutoReturn); err != nil {
|
|
| 66 |
+ // Validate winterm.DISABLE_NEWLINE_AUTO_RETURN is supported, but do not set it. |
|
| 67 |
+ if err = winterm.SetConsoleMode(fd, mode|winterm.ENABLE_VIRTUAL_TERMINAL_PROCESSING|winterm.DISABLE_NEWLINE_AUTO_RETURN); err != nil {
|
|
| 68 | 68 |
emulateStderr = true |
| 69 | 69 |
} else {
|
| 70 |
- winterm.SetConsoleMode(fd, mode|enableVirtualTerminalProcessing) |
|
| 70 |
+ winterm.SetConsoleMode(fd, mode|winterm.ENABLE_VIRTUAL_TERMINAL_PROCESSING) |
|
| 71 | 71 |
} |
| 72 | 72 |
} |
| 73 | 73 |
|
| ... | ... |
@@ -183,9 +176,9 @@ func SetRawTerminalOutput(fd uintptr) (*State, error) {
|
| 183 | 183 |
return nil, err |
| 184 | 184 |
} |
| 185 | 185 |
|
| 186 |
- // Ignore failures, since disableNewlineAutoReturn might not be supported on this |
|
| 186 |
+ // Ignore failures, since winterm.DISABLE_NEWLINE_AUTO_RETURN might not be supported on this |
|
| 187 | 187 |
// version of Windows. |
| 188 |
- winterm.SetConsoleMode(fd, state.mode|disableNewlineAutoReturn) |
|
| 188 |
+ winterm.SetConsoleMode(fd, state.mode|winterm.DISABLE_NEWLINE_AUTO_RETURN) |
|
| 189 | 189 |
return state, err |
| 190 | 190 |
} |
| 191 | 191 |
|
| ... | ... |
@@ -215,7 +208,7 @@ func MakeRaw(fd uintptr) (*State, error) {
|
| 215 | 215 |
mode |= winterm.ENABLE_INSERT_MODE |
| 216 | 216 |
mode |= winterm.ENABLE_QUICK_EDIT_MODE |
| 217 | 217 |
if vtInputSupported {
|
| 218 |
- mode |= enableVirtualTerminalInput |
|
| 218 |
+ mode |= winterm.ENABLE_VIRTUAL_TERMINAL_INPUT |
|
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 | 221 |
err = winterm.SetConsoleMode(fd, mode) |