|
|
@ -1028,6 +1028,7 @@ git checkout "${scriptroot}.cmd" |
|
|
|
git branch --set-upstream-to=origin/master master |
|
|
|
git branch --set-upstream-to=origin/master master |
|
|
|
|
|
|
|
|
|
|
|
Set-Location $launchdir #restore original CWD |
|
|
|
Set-Location $launchdir #restore original CWD |
|
|
|
|
|
|
|
#see also: https://github.com/jdhitsolutions/WTToolbox |
|
|
|
|
|
|
|
|
|
|
|
# Define the necessary Win32 API functions and constants |
|
|
|
# Define the necessary Win32 API functions and constants |
|
|
|
Add-Type -TypeDefinition @" |
|
|
|
Add-Type -TypeDefinition @" |
|
|
@ -1038,6 +1039,14 @@ public class WinAPI |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Console Input/Output Handles |
|
|
|
// Console Input/Output Handles |
|
|
|
public const int STD_OUTPUT_HANDLE = -11; |
|
|
|
public const int STD_OUTPUT_HANDLE = -11; |
|
|
|
|
|
|
|
public const uint ENABLE_QUICK_EDIT_MODE = 0x0040; |
|
|
|
|
|
|
|
public const uint ENABLE_EXTENDED_FLAGS = 0x0080; |
|
|
|
|
|
|
|
public const uint ENABLE_MOUSE_INPUT = 0x0010; |
|
|
|
|
|
|
|
public const uint ENABLE_WINDOW_INPUT = 0x0008; |
|
|
|
|
|
|
|
public const uint ENABLE_INSERT_MODE = 0x0020; |
|
|
|
|
|
|
|
public const uint ENABLE_LINE_INPUT = 0x0002; |
|
|
|
|
|
|
|
public const uint ENABLE_ECHO_INPUT = 0x0004; |
|
|
|
|
|
|
|
public const uint ENABLE_PROCESSED_INPUT = 0x0001; |
|
|
|
|
|
|
|
|
|
|
|
// Console Modes |
|
|
|
// Console Modes |
|
|
|
public const uint ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004; |
|
|
|
public const uint ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004; |
|
|
@ -1045,10 +1054,8 @@ public class WinAPI |
|
|
|
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)] |
|
|
|
[DllImport("kernel32.dll", SetLastError = true)] |
|
|
|
public static extern IntPtr GetStdHandle(int nStdHandle); |
|
|
|
public static extern IntPtr GetStdHandle(int nStdHandle); |
|
|
|
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)] |
|
|
|
[DllImport("kernel32.dll", SetLastError = true)] |
|
|
|
public static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode); |
|
|
|
public static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode); |
|
|
|
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)] |
|
|
|
[DllImport("kernel32.dll", SetLastError = true)] |
|
|
|
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode); |
|
|
|
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode); |
|
|
|
} |
|
|
|
} |
|
|
@ -1058,7 +1065,7 @@ public class WinAPI |
|
|
|
$stdoutHandle = [WinAPI]::GetStdHandle([WinAPI]::STD_OUTPUT_HANDLE) |
|
|
|
$stdoutHandle = [WinAPI]::GetStdHandle([WinAPI]::STD_OUTPUT_HANDLE) |
|
|
|
|
|
|
|
|
|
|
|
# Get the current console mode |
|
|
|
# Get the current console mode |
|
|
|
[uint]$currentMode = 0 |
|
|
|
[uint32]$currentMode = 0 |
|
|
|
if (![WinAPI]::GetConsoleMode($stdoutHandle, [ref]$currentMode)) { |
|
|
|
if (![WinAPI]::GetConsoleMode($stdoutHandle, [ref]$currentMode)) { |
|
|
|
Write-Error "Failed to get console mode. Error code: $($LAST_ERROR)" |
|
|
|
Write-Error "Failed to get console mode. Error code: $($LAST_ERROR)" |
|
|
|
return |
|
|
|
return |
|
|
@ -1068,7 +1075,7 @@ if (![WinAPI]::GetConsoleMode($stdoutHandle, [ref]$currentMode)) { |
|
|
|
$newMode = $currentMode -bor [WinAPI]::ENABLE_VIRTUAL_TERMINAL_PROCESSING |
|
|
|
$newMode = $currentMode -bor [WinAPI]::ENABLE_VIRTUAL_TERMINAL_PROCESSING |
|
|
|
|
|
|
|
|
|
|
|
# Set the new console mode |
|
|
|
# Set the new console mode |
|
|
|
if (![WinAPI]::SetConsoleMode($stdoutHandle, $newMode)) { |
|
|
|
if (-not [WinAPI]::SetConsoleMode($stdoutHandle, $newMode)) { |
|
|
|
Write-Error "Failed to set console mode. Error code: $($LAST_ERROR)" |
|
|
|
Write-Error "Failed to set console mode. Error code: $($LAST_ERROR)" |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|