-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStyles.ps1
89 lines (79 loc) · 2.18 KB
/
Styles.ps1
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class PromptStyle {
[string]$SegmentSeparator = [char]::ConvertFromUtf32(0xE0B0)
[string]$InnerSeparator = [char]::ConvertFromUtf32(0xE0B1)
[string]$InitialSymbol = ''
[bool]$RenderInitialSymbol = $false
[bool]$ReverseColor = $false
}
$PromptStyleInfo = @{
PromptStyles = @{
Powerline = [PromptStyle]::new()
}
CurrentPromptStyle = 'Powerline'
}
function New-PromptStyle {
return [PromptStyle]::new()
}
function Add-PromptStyle {
param (
[parameter(Mandatory=$true)]
[string]$Name,
[parameter(Mandatory=$true)]
[PromptStyle]$Style
)
if ($PromptStyleInfo.PromptStyles.ContainsKey($Name)) {
throw "Style '$Name' already exists."
}
$PromptStyleInfo.PromptStyles[$Name] = $Style
}
function Get-PromptStyle {
param (
[string]$Name
)
if ($Name.Length -gt 0) {
return $PromptStyleInfo.PromptStyles[$Name]
}
return $PromptStyleInfo.PromptStyles
}
function Remove-PromptStyle {
param (
[parameter(Mandatory=$true)]
[string]$Name
)
if (-not $PromptStyleInfo.PromptStyles.ContainsKey($Name)) {
throw "Style '$Name' does not exist."
}
if ($Name -eq $PromptStyleInfo.CurrentPromptStyle) {
throw "Style '$Name' is currently in use."
}
$PromptStyleInfo.PromptStyles.Remove($Name)
}
function Get-CurrentPromptStyle {
return $PromptStyleInfo.PromptStyles[$PromptStyleInfo.CurrentPromptStyle]
}
function Set-CurrentPromptStyle {
param (
[parameter(Mandatory=$true)]
[string]$Name
)
if (-not $PromptStyleInfo.PromptStyles.ContainsKey($Name)) {
throw "Style '$Name' does not exist."
}
$PromptStyleInfo.CurrentPromptStyle = $Name
}
function Get-CurrentPromptStyleName {
return $PromptStyleInfo.CurrentPromptStyle
}
function Get-InnerSeparatorSymbol {
$PromptStyleInfo.PromptStyles[$PromptStyleInfo.CurrentPromptStyle].InnerSeparator
}
Export-ModuleMember -Function @(
'New-PromptStyle',
'Add-PromptStyle',
'Get-PromptStyle',
'Remove-PromptStyle',
'Get-CurrentPromptStyle',
'Set-CurrentPromptStyle',
'Get-CurrentPromptStyleName',
'Get-InnerSeparatorSymbol'
)