Skip to content

Commit ae54718

Browse files
author
James Brundage
committed
Renaming ANSI Regexes to Console (Fixes #188)
Fixing nested references
1 parent f3935ab commit ae54718

4 files changed

Lines changed: 46 additions & 38 deletions

File tree

RegEx/Console/Color.regex.source.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path
33

44
New-RegEx -Description "Matches an ANSI color" |
55
New-RegEx -Atomic -Or @(
6-
New-RegEx -Pattern '?<ANSI_24BitColor>'
7-
New-RegEx -Pattern '?<ANSI_8BitColor>'
8-
New-RegEx -Pattern '?<ANSI_4BitColor>'
9-
New-RegEx -Pattern '?<ANSI_DefaultColor>'
6+
New-RegEx -Pattern '?<Console_24BitColor>'
7+
New-RegEx -Pattern '?<Console_8BitColor>'
8+
New-RegEx -Pattern '?<Console_4BitColor>'
9+
New-RegEx -Pattern '?<Console_DefaultColor>'
1010
) |
1111
Set-Content -Path (Join-Path $myRoot $myName) -PassThru

RegEx/Console/Color.regex.txt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Matches an ANSI color
22
(?>
3-
(?<ANSI_24BitColor>
3+
(?<Console_24BitColor>
44
(?-i)\e # An Escape
55
\[ # Followed by a bracket
66
(?>
@@ -12,7 +12,7 @@
1212
m)
1313
)
1414
|
15-
(?<ANSI_8BitColor>
15+
(?<Console_8BitColor>
1616
(?-i)\e # An Escape
1717
\[ # Followed by a bracket
1818
(?>
@@ -29,17 +29,25 @@ m |
2929
m))
3030
)
3131
|
32-
(?<ANSI_4BitColor>
32+
(?<Console_4BitColor>
3333
\e # An Escape
3434
\[ # Followed by a bracket
3535
(?<Color>(?>
36-
(?<IsBright>1)?\;{0,1}(?<IsForegroundColor>3) |
37-
(?<IsBright>(?<IsForegroundColor>9)) |
38-
(?<IsBright>1)?\;{0,1}(?<IsBackgroundColor>4) |
39-
(?<IsBright>(?<IsBackgroundColor>10)))(?<ColorNumber>[0-7])m)
36+
(?<IsBright>1)?\;{0,1} # A 1 and a semicolon indicate a bright color
37+
(?<IsForegroundColor>3) # A number that starts with 3 indicates foreground color
38+
|
39+
(?<IsBright>(?<IsForegroundColor>9)) # OR it could be a less common bright foreground color, which starts with 9
40+
|
41+
(?<IsBright>1)?\;{0,1} # A 1 and a semicolon indicate a bright color
42+
(?<IsBackgroundColor>4) # A number that starts with 3 indicates foreground color
43+
|
44+
(?<IsBright>(?<IsBackgroundColor>10)) # OR it could be a less common bright foreground color, which starts with 9
45+
)(?<ColorNumber>[0-7]) # The color number will be between 0 and 7
46+
(?:\;{0,1}(?<IsBright>1)?)? # Brightness can also come after a color
47+
m)
4048
)
4149
|
42-
(?<ANSI_DefaultColor>
50+
(?<Console_DefaultColor>
4351
(?-i)\e # An Escape
4452
\[ # Followed by a bracket
4553
(?<Color>(?>

RegEx/Console/Style.regex.source.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path
33

44
New-RegEx -Description "Matches an ANSI style (color or text option)" |
55
New-RegEx -Atomic -Or @(
6-
New-RegEx -Pattern '?<ANSI_Reset>'
7-
New-Regex -Pattern '?<ANSI_Bold>'
8-
New-Regex -Pattern '?<ANSI_Blink>'
9-
New-Regex -Pattern '?<ANSI_Faint>'
10-
New-Regex -Pattern '?<ANSI_Italic>'
11-
New-Regex -Pattern '?<ANSI_Invert>'
12-
New-Regex -Pattern '?<ANSI_Hide>'
13-
New-Regex -Pattern '?<ANSI_Strikethrough>'
14-
New-Regex -Pattern '?<ANSI_Underline>'
15-
New-RegEx -Pattern '?<ANSI_24BitColor>'
16-
New-RegEx -Pattern '?<ANSI_8BitColor>'
17-
New-RegEx -Pattern '?<ANSI_4BitColor>'
18-
New-RegEx -Pattern '?<ANSI_DefaultColor>'
6+
New-RegEx -Pattern '?<Console_Reset>'
7+
New-Regex -Pattern '?<Console_Bold>'
8+
New-Regex -Pattern '?<Console_Blink>'
9+
New-Regex -Pattern '?<Console_Faint>'
10+
New-Regex -Pattern '?<Console_Italic>'
11+
New-Regex -Pattern '?<Console_Invert>'
12+
New-Regex -Pattern '?<Console_Hide>'
13+
New-Regex -Pattern '?<Console_Strikethrough>'
14+
New-Regex -Pattern '?<Console_Underline>'
15+
New-RegEx -Pattern '?<Console_24BitColor>'
16+
New-RegEx -Pattern '?<Console_8BitColor>'
17+
New-RegEx -Pattern '?<Console_4BitColor>'
18+
New-RegEx -Pattern '?<Console_DefaultColor>'
1919
) |
2020
Set-Content -Path (Join-Path $myRoot $myName) -PassThru

RegEx/Console/Style.regex.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Matches an ANSI style (color or text option)
22
(?>
3-
(?<ANSI_Reset>
3+
(?<Console_Reset>
44
\e # An Escape
55
\[ # Followed by a bracket
66
(?<Reset>0m) # 0m indicates reset
77

88
)
99
|
10-
(?<ANSI_Bold>
10+
(?<Console_Bold>
1111
\e # An Escape
1212
\[ # Followed by a bracket
1313
(?>
1414
(?<BoldStart>1m) |
1515
(?<BoldEnd>22m))
1616
)
1717
|
18-
(?<ANSI_Blink>
18+
(?<Console_Blink>
1919
\e # An Escape
2020
\[ # Followed by a bracket
2121
(?>
@@ -28,7 +28,7 @@
2828
)
2929
)
3030
|
31-
(?<ANSI_Faint>
31+
(?<Console_Faint>
3232
\e # An Escape
3333
\[ # Followed by a bracket
3434
(?>
@@ -38,7 +38,7 @@
3838
)
3939
)
4040
|
41-
(?<ANSI_Italic>
41+
(?<Console_Italic>
4242
\e # An Escape
4343
\[ # Followed by a bracket
4444
(?>
@@ -48,7 +48,7 @@
4848
)
4949
)
5050
|
51-
(?<ANSI_Invert>
51+
(?<Console_Invert>
5252
\e # An Escape
5353
\[ # Followed by a bracket
5454
(?>
@@ -58,7 +58,7 @@
5858
)
5959
)
6060
|
61-
(?<ANSI_Hide>
61+
(?<Console_Hide>
6262
\e # An Escape
6363
\[ # Followed by a bracket
6464
(?>
@@ -68,7 +68,7 @@
6868
)
6969
)
7070
|
71-
(?<ANSI_Strikethrough>
71+
(?<Console_Strikethrough>
7272
\e # An Escape
7373
\[ # Followed by a bracket
7474
(?>
@@ -78,7 +78,7 @@
7878
)
7979
)
8080
|
81-
(?<ANSI_Underline>
81+
(?<Console_Underline>
8282
\e # An Escape
8383
\[ # Followed by a bracket
8484
(?>
@@ -90,7 +90,7 @@
9090
)
9191
)
9292
|
93-
(?<ANSI_24BitColor>
93+
(?<Console_24BitColor>
9494
(?-i)\e # An Escape
9595
\[ # Followed by a bracket
9696
(?>
@@ -102,7 +102,7 @@
102102
m)
103103
)
104104
|
105-
(?<ANSI_8BitColor>
105+
(?<Console_8BitColor>
106106
(?-i)\e # An Escape
107107
\[ # Followed by a bracket
108108
(?>
@@ -119,7 +119,7 @@ m |
119119
m))
120120
)
121121
|
122-
(?<ANSI_4BitColor>
122+
(?<Console_4BitColor>
123123
\e # An Escape
124124
\[ # Followed by a bracket
125125
(?<Color>(?>
@@ -137,7 +137,7 @@ m))
137137
m)
138138
)
139139
|
140-
(?<ANSI_DefaultColor>
140+
(?<Console_DefaultColor>
141141
(?-i)\e # An Escape
142142
\[ # Followed by a bracket
143143
(?<Color>(?>

0 commit comments

Comments
 (0)