| ... | @@ -264,16 +264,17 @@ pub fn getOrEnableAnsiEscapeSupport(self: File) bool { | ... | @@ -264,16 +264,17 @@ pub fn getOrEnableAnsiEscapeSupport(self: File) bool { |
| 264 | | 264 | |
| 265 | // For Windows Console, VT Sequences processing support was added in Windows 10 build 14361, but disabled by default. | 265 | // For Windows Console, VT Sequences processing support was added in Windows 10 build 14361, but disabled by default. |
| 266 | // https://devblogs.microsoft.com/commandline/tmux-support-arrives-for-bash-on-ubuntu-on-windows/ | 266 | // https://devblogs.microsoft.com/commandline/tmux-support-arrives-for-bash-on-ubuntu-on-windows/ |
| 267 | // Use Microsoft's recommended way to enable virtual terminal processing. | 267 | // |
| | 268 | // Note: In Microsoft's example for enabling virtual terminal processing, it |
| | 269 | // shows attempting to enable `DISABLE_NEWLINE_AUTO_RETURN` as well: |
| 268 | // https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example-of-enabling-virtual-terminal-processing | 270 | // https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example-of-enabling-virtual-terminal-processing |
| 269 | var requested_console_modes: windows.DWORD = windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING | windows.DISABLE_NEWLINE_AUTO_RETURN; | 271 | // This is avoided because in the old Windows Console, that flag causes \n (as opposed to \r\n) |
| 270 | var console_mode = original_console_mode | requested_console_modes; | 272 | // to behave unexpectedly (the cursor moves down 1 row but remains on the same column). |
| 271 | if (windows.kernel32.SetConsoleMode(self.handle, console_mode) != 0) return true; | 273 | // Additionally, the default console mode in Windows Terminal does not have |
| 272 | | 274 | // `DISABLE_NEWLINE_AUTO_RETURN` set, so by only enabling `ENABLE_VIRTUAL_TERMINAL_PROCESSING` |
| 273 | // An application receiving ERROR_INVALID_PARAMETER with one of the newer console mode | 275 | // we end up matching the mode of Windows Terminal. |
| 274 | // flags in the bit field should gracefully degrade behavior and try again. | 276 | const requested_console_modes = windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING; |
| 275 | requested_console_modes = windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING; | 277 | const console_mode = original_console_mode | requested_console_modes; |
| 276 | console_mode = original_console_mode | requested_console_modes; | | |
| 277 | if (windows.kernel32.SetConsoleMode(self.handle, console_mode) != 0) return true; | 278 | if (windows.kernel32.SetConsoleMode(self.handle, console_mode) != 0) return true; |
| 278 | } | 279 | } |
| 279 | | 280 | |