-
-
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.
Merge pull request #148 from StartAutomating/IrregularANSIFix
Irregular ansi fix
- Loading branch information
Showing
20 changed files
with
193 additions
and
84 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
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
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
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,7 +1,10 @@ | ||
# Matches an ANSI 24-bit color | ||
(?-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) |
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,4 +1,8 @@ | ||
# Matches an ANSI 3 or 4-bit color | ||
\e # An Escape | ||
\[ # Followed by a bracket | ||
(?<Color>(?<IsBright>1)?\;?(?<ForegroundColor>3[0-7])?(?(ForegroundColor)(m)|((?<BackgroundColor>4[0-7])m))) | ||
(?<Color>(?> | ||
(?<IsBright>1)?\;{0,1}(?<IsForegroundColor>3) | | ||
(?<IsBright>(?<IsForegroundColor>9)) | | ||
(?<IsBright>1)?\;{0,1}(?<IsBackgroundColor>4) | | ||
(?<IsBright>(?<IsBackgroundColor>10)))(?<ColorNumber>[0-7])m) |
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe 'Irregular and ANSI' { | ||
it 'Can match any ANSI sequence' { | ||
"$([char]0x1b)[0m" | ?<ANSI_Code> | Select-Object -ExpandProperty Length | Should -be 4 | ||
|
||
"$([char]0x1b)[1;3;5,~" | ?<ANSI_Code> | Select-Object -ExpandProperty Length | Should -be 9 | ||
} | ||
context 'ANSI Colors' { | ||
it 'Can Match a 4-bit color' { | ||
$x = "$([char]0x1b)[32m" | ?<ANSI_4BitColor> -Extract | ||
$x.ColorNumber | Should -Be 2 | ||
$x.IsForegroundColor | Should -Be 3 | ||
} | ||
|
||
it 'Can Match a 24-bit color' { | ||
$x = "$([char]0x1b)[38;2;255;100;0m" | ?<ANSI_24BitColor> -Extract | ||
$x.Red | Should -be 255 | ||
$x.Green | Should -be 100 | ||
$x.Blue | Should -be 0 | ||
} | ||
} | ||
|
||
context 'ANSI Styles' { | ||
it 'Can Match ANSI Styles' { | ||
@("$([char]0x1b)[3m Italics $([char]0x1b)[23m" | ?<ANSI_Style>).Count | Should -be 2 | ||
} | ||
} | ||
} |
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
Oops, something went wrong.