-
-
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 #152 from StartAutomating/IrregularANSI
Irregular ansi
- Loading branch information
Showing
19 changed files
with
204 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,51 @@ | ||
# Matches an ANSI color | ||
(?> | ||
(?<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)) | ||
) | ||
) |
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,64 @@ | ||
$myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' | ||
$myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path | ||
|
||
New-RegEx -Description "Matches an ANSI cursor control" | | ||
New-RegEx -CharacterClass Escape | | ||
New-RegEx -LiteralCharacter '[' | | ||
New-RegEx -Atomic -Or @( | ||
New-RegEx -Pattern '6n' -Name 'DeviceStatusReport' -Comment '6n will request the cursor position' | ||
New-RegEx -Pattern ( | ||
New-RegEx -Name Row -Pattern '\d+' | | ||
New-RegEx -LiteralCharacter ';' | | ||
New-RegEx -Name Column -Pattern '\d+' | | ||
New-RegEx -Pattern 'R' | ||
) -Comment "A Device Status Report will return CursorPosition in the form <row>;<column> R" -Name CursorPosition | ||
New-RegEx -Name CursorUp -Comment "Cursor Up is a digit followed by A" -Pattern ( | ||
New-RegEx -Name RowCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'A' | ||
) | ||
New-RegEx -Name CursorDown -Comment "Cursor Down is a digit followed by B" -Pattern ( | ||
New-RegEx -Name RowCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'B' | ||
) | ||
New-RegEx -Name CursorForward -Comment "Cursor Forward is a digit followed by C" -Pattern ( | ||
New-RegEx -Name ColumnCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'C' | ||
) | ||
New-RegEx -Name CursorBack -Comment "Cursor Back is a digit followed by D" -Pattern ( | ||
New-RegEx -Name ColumnCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'D' | ||
) | ||
New-RegEx -Name CursorNextLine -Comment "Cursor Next Line is a digit followed by E" -Pattern ( | ||
New-RegEx -Name LineCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'E' | ||
) | ||
New-RegEx -Name CursorNextLine -Comment "Cursor Next Line is a digit followed by F" -Pattern ( | ||
New-RegEx -Name LineCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'F' | ||
) | ||
New-RegEx -Name CursorAbsolute -Comment "Cursor Absolute Position is a digit followed by G" -Pattern ( | ||
New-RegEx -Name AbsolutePosition -Pattern '\d+' | | ||
New-RegEx -Pattern 'G' | ||
) | ||
New-RegEx -Name CursorPosition -Comment "Cursor Positions are two optional digits, separated by semicolon, ending with H" -Pattern ( | ||
New-RegEx -Name Row -Pattern '\d{0,}' | | ||
New-RegEx -LiteralCharacter ';' | | ||
New-RegEx -Name Column -Pattern '\d{0,}' | | ||
New-RegEx -LiteralCharacter 'H' | ||
) | ||
New-RegEx -Name ScrollUp -Comment "Scroll Up is a digit followed by S" -Pattern ( | ||
New-RegEx -Name PageCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'S' | ||
) | ||
New-RegEx -Name ScrollDown -Comment "Scroll Down is a digit followed by T" -Pattern ( | ||
New-RegEx -Name PageCount -Pattern '\d+' | | ||
New-RegEx -Pattern 'T' | ||
) | ||
New-RegEx -Name CursorHide -Comment 'Cursors can be hidden with 25h' ( | ||
New-RegEx -Pattern '25h' | ||
) | ||
New-RegEx -Name CursorShow -Comment 'Cursors can be hidden with 25l' ( | ||
New-RegEx -Pattern '25l' | ||
) | ||
) | | ||
Set-Content -Path (Join-Path $myRoot $myName) -PassThru |
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,30 @@ | ||
# Matches an ANSI cursor control | ||
\e\[(?> | ||
(?<DeviceStatusReport>6n) # 6n will request the cursor position | ||
| | ||
(?<CursorPosition>(?<Row>\d+)\;(?<Column>\d+)R) # A Device Status Report will return CursorPosition in the form <row>;<column> R | ||
| | ||
(?<CursorUp>(?<RowCount>\d+)A) # Cursor Up is a digit followed by A | ||
| | ||
(?<CursorDown>(?<RowCount>\d+)B) # Cursor Down is a digit followed by B | ||
| | ||
(?<CursorForward>(?<ColumnCount>\d+)C) # Cursor Forward is a digit followed by C | ||
| | ||
(?<CursorBack>(?<ColumnCount>\d+)D) # Cursor Back is a digit followed by D | ||
| | ||
(?<CursorNextLine>(?<LineCount>\d+)E) # Cursor Next Line is a digit followed by E | ||
| | ||
(?<CursorNextLine>(?<LineCount>\d+)F) # Cursor Next Line is a digit followed by F | ||
| | ||
(?<CursorAbsolute>(?<AbsolutePosition>\d+)G) # Cursor Absolute Position is a digit followed by G | ||
| | ||
(?<CursorPosition>(?<Row>\d{0,})\;(?<Column>\d{0,})H) # Cursor Positions are two optional digits, separated by semicolon, ending with H | ||
| | ||
(?<ScrollUp>(?<PageCount>\d+)S) # Scroll Up is a digit followed by S | ||
| | ||
(?<ScrollDown>(?<PageCount>\d+)T) # Scroll Down is a digit followed by T | ||
| | ||
(?<CursorHide>25h) # Cursors can be hidden with 25h | ||
| | ||
(?<CursorShow>25l) # Cursors can be hidden with 25l | ||
) |
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
Oops, something went wrong.