Repository navigation
Expand file tree
/
Copy pathPX2PS.psm1
More file actions
58 lines (53 loc) · 2 KB
/
Copy pathPX2PS.psm1
File metadata and controls
58 lines (53 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Enable Virtual Terminal Processing for ANSI colors (Windows PowerShell 5.1 compatibility)
if ($PSVersionTable.PSVersion.Major -le 5 -and $env:OS -eq 'Windows_NT' -and $Host.Name -ne 'Windows PowerShell ISE Host') {
$vtEnabled = $false
try {
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class VTConsole {
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
public static void EnableVT() {
IntPtr handle = GetStdHandle(-11);
uint mode;
GetConsoleMode(handle, out mode);
SetConsoleMode(handle, mode | 0x4);
}
}
"@ -ErrorAction SilentlyContinue
[VTConsole]::EnableVT()
$vtEnabled = $true
} catch {
# VT processing may already be enabled or not available
}
}
Add-Type -AssemblyName System.IO.Compression
# Module-scoped constants
$script:LowerHalfBlock = [char]0x2584
$script:UpperHalfBlock = [char]0x2580
$script:ESC = [char]27
# Dot source private functions
$privateFunctions = @(Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -ErrorAction SilentlyContinue)
foreach ($function in $privateFunctions) {
try {
. $function.FullName
} catch {
Write-Error "Failed to import function $($function.FullName): $_"
}
}
# Dot source public functions
$publicFunctions = @(Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -ErrorAction SilentlyContinue)
foreach ($function in $publicFunctions) {
try {
. $function.FullName
} catch {
Write-Error "Failed to import function $($function.FullName): $_"
}
}
# Export public functions and their aliases
Export-ModuleMember -Function ($publicFunctions | ForEach-Object { $_.BaseName }) -Alias *