| 109 | } |
| 110 | |
| 111 | bool AttachWindowsConsole() |
| 112 | { |
| 113 | auto stdinType = GetFileType(GetStdHandle(STD_INPUT_HANDLE)); |
| 114 | auto stdoutType = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); |
| 115 | auto stderrType = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); |
| 116 | |
| 117 | bool bindStdIn = false; |
| 118 | bool bindStdOut = false; |
| 119 | bool bindStdErr = false; |
| 120 | |
| 121 | if (stdinType == FILE_TYPE_CHAR || stdinType == FILE_TYPE_UNKNOWN) { |
| 122 | bindStdIn = true; |
| 123 | } |
| 124 | if (stdoutType == FILE_TYPE_CHAR || stdoutType == FILE_TYPE_UNKNOWN) { |
| 125 | bindStdOut = true; |
| 126 | } |
| 127 | if (stderrType == FILE_TYPE_CHAR || stderrType == FILE_TYPE_UNKNOWN) { |
| 128 | bindStdErr = true; |
| 129 | } |
| 130 | |
| 131 | if (AttachConsole(ATTACH_PARENT_PROCESS)) { |
| 132 | BindCrtHandlesToStdHandles(bindStdIn, bindStdOut, bindStdErr); |
| 133 | return true; |
| 134 | } |
| 135 | |
| 136 | return false; |
| 137 | } |
| 138 | |
| 139 | std::error_code EnableAnsiSupport() |
| 140 | { |
no test coverage detected