-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Brundage
committed
Sep 29, 2022
1 parent
a46a113
commit e540b6f
Showing
2 changed files
with
71 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,141 @@ | ||
# Matches an ANSI style (color or text option) | ||
(?> | ||
(?<ANSI_Reset> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?<Reset>0m) # 0m indicates reset | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?<Reset>0m) # 0m indicates reset | ||
|
||
) | ||
| | ||
(?<ANSI_Bold> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<BoldStart>1m) | | ||
(?<BoldEnd>22m)) | ||
) | ||
| | ||
(?<ANSI_Blink> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?> | ||
(?<BlinkStart>(?<BlinkSlow>5m) # 5m starts a slow blink | ||
(?<BlinkStart>(?<BlinkSlow>5m) # 5m starts a slow blink | ||
| | ||
(?<BlinkFast>6m) # 6m starts a slow blink | ||
(?<BlinkFast>6m) # 6m starts a slow blink | ||
)) | | ||
(?<BlinkEnd>25m) # 25m stops blinks | ||
(?<BlinkEnd>25m) # 25m stops blinks | ||
) | ||
) | ||
| | ||
(?<ANSI_Faint> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<FaintStart>2m) # 2m starts faint | ||
(?<FaintStart>2m) # 2m starts faint | ||
| | ||
(?<FaintEnd>22m) # 22m stops faint | ||
(?<FaintEnd>22m) # 22m stops faint | ||
) | ||
) | ||
| | ||
(?<ANSI_Italic> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<ItalicStart>3m) # 3m starts italic | ||
(?<ItalicStart>3m) # 3m starts italic | ||
| | ||
(?<ItalicEnd>23m) # 23m stops italic | ||
(?<ItalicEnd>23m) # 23m stops italic | ||
) | ||
) | ||
| | ||
(?<ANSI_Invert> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<InvertStart>7m) # 7m starts invert | ||
(?<InvertStart>7m) # 7m starts invert | ||
| | ||
(?<InvertEnd>27m) # 27m stops invert | ||
(?<InvertEnd>27m) # 27m stops invert | ||
) | ||
) | ||
| | ||
(?<ANSI_Hide> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<HideStart>8m) # 8m starts hide | ||
(?<HideStart>8m) # 8m starts hide | ||
| | ||
(?<HideEnd>28m) # 28m stops hide | ||
(?<HideEnd>28m) # 28m stops hide | ||
) | ||
) | ||
| | ||
(?<ANSI_Strikethrough> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<StrikethroughStart>9m) # 9m starts Strikethrough | ||
| | ||
(?<StrikethroughEnd>29m) # 29m stops Strikethrough | ||
) | ||
) | ||
| | ||
?<ANSI_Strikethru> | | ||
(?<ANSI_Underline> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<UnderlineStart>4m) # 4m starts underline | ||
(?<UnderlineStart>4m) # 4m starts underline | ||
| | ||
(?<DoubleUnderlineStart>21m) # 21m start a double underline | ||
(?<DoubleUnderlineStart>21m) # 21m start a double underline | ||
| | ||
(?<UnderlineEnd>24m) # 24m stops underline | ||
(?<UnderlineEnd>24m) # 24m stops underline | ||
) | ||
) | ||
| | ||
(?<ANSI_24BitColor> | ||
(?-i)\e # An Escape | ||
\[ # Followed by a bracket | ||
38;2;(?<Color>(?<Red>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Red is the first 0-255 value | ||
;(?<Red>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Green is the second 0-255 value | ||
;(?<Blue>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Blue is the third 0-255 value | ||
(?-i)\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<IsForegroundColor>38) | | ||
(?<IsBackgroundColor>48) | | ||
(?<IsUnderlineColor>58));2;(?<Color>(?<Red>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Red is the first 0-255 value | ||
;(?<Green>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Green is the second 0-255 value | ||
;(?<Blue>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Blue is the third 0-255 value | ||
m) | ||
) | ||
| | ||
(?<ANSI_8BitColor> | ||
(?-i)\e # An Escape | ||
\[ # Followed by a bracket | ||
38;5;(?<Color>(?> | ||
(?<StandardColor>[0-7]) # 0 -7 are standard colors | ||
(?-i)\e # An Escape | ||
\[ # Followed by a bracket | ||
(?> | ||
(?<IsForegroundColor>38) | | ||
(?<IsBackgroundColor>48) | | ||
(?<IsUnderlineColor>58));5;(?<Color>(?> | ||
(?<StandardColor>[0-7]) # 0 -7 are standard colors | ||
m | | ||
(?<BrightColor>(?>[8-9]|1[0-5])) # 8-15 are bright colors | ||
(?<BrightColor>(?>[8-9]|1[0-5])) # 8-15 are bright colors | ||
m | | ||
(?<CubeColor>(?>[0-2][0-3][0-1]|[0-1]\d\d|\d{1,2})) # 16-231 are cubed colors | ||
(?<CubeColor>(?>[0-2][0-3][0-1]|[0-1]\d\d|\d{1,2})) # 16-231 are cubed colors | ||
m | | ||
(?<GrayscaleColor>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # 232-255 are grayscales | ||
(?<GrayscaleColor>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # 232-255 are grayscales | ||
m)) | ||
) | ||
| | ||
(?<ANSI_4BitColor> | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?<Color>(?<IsBright>1)?\;?(?<ForegroundColor>3[0-7])?(?(ForegroundColor)(m)|((?<BackgroundColor>4[0-7])m))) | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?<Color>(?> | ||
(?<IsBright>1)?\;{0,1}(?<IsForegroundColor>3) | | ||
(?<IsBright>(?<IsForegroundColor>9)) | | ||
(?<IsBright>1)?\;{0,1}(?<IsBackgroundColor>4) | | ||
(?<IsBright>(?<IsBackgroundColor>10)))(?<ColorNumber>[0-7])m) | ||
) | ||
| | ||
(?<ANSI_DefaultColor> | ||
(?-i)\e # An Escape | ||
\[ # Followed by a bracket | ||
(?-i)\e # An Escape | ||
\[ # Followed by a bracket | ||
(?<Color>(?> | ||
(?<DefaultForeground>39) # 39 Represents the default foreground color | ||
(?<DefaultForeground>39) # 39 Represents the default foreground color | ||
m | | ||
(?<DefaultForeground>49) # 49 Represents the default background color | ||
(?<DefaultForeground>49) # 49 Represents the default background color | ||
m)) | ||
) | ||
) |