From 94f9dae9d4c68069ed8ea023769c0f98a435b202 Mon Sep 17 00:00:00 2001 From: "Paul \"TBBle\" Hampson" Date: Thu, 15 Jul 2021 04:58:40 +1000 Subject: [PATCH 1/2] Correct SGR code to terminate blinking range The test-script is incorrectly using SGR 26 to cancel SGR 6, but SGR 5 and SGR 6 are _both_ cancelled by SGR 25. SGR 26 is unrelated. This fixes the issue that the 'no rapid blink' text is blinking in Windows Terminal, which implements all of SGR 5, 6 and 25; although it does not differentiate SGR 5 and SGR 6's blink speed. References: * https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters * Page 61 of https://www.ecma-international.org/wp-content/uploads/ECMA-48_5th_edition_june_1991.pdf * https://www.real-world-systems.com/docs/ANSIcode.html Signed-off-by: Paul "TBBle" Hampson --- PowerShell/Attributes.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/Attributes.ps1 b/PowerShell/Attributes.ps1 index 494b168..e5ca477 100644 --- a/PowerShell/Attributes.ps1 +++ b/PowerShell/Attributes.ps1 @@ -103,8 +103,8 @@ function Do-It { CUP 10 0 ; [console]::Write("Standard attributes:") CUP 11 4 ; SGR 4 ; [console]::Write("Underline") ; SGR 24 ; [console]::Write(" - no underline") ; SGR 0 - CUP 12 4 ; SGR 5 ; [console]::Write("Slow blink") ; SGR 25 ; [console]::Write(" - no slow blink") ; SGR 0 - CUP 13 4 ; SGR 6 ; [console]::Write("Rapid blink") ; SGR 26 ; [console]::Write(" - no rapid blink") ; SGR 0 + CUP 12 4 ; SGR 5 ; [console]::Write("Slow blink") ; SGR 25 ; [console]::Write(" - no blink") ; SGR 0 + CUP 13 4 ; SGR 6 ; [console]::Write("Rapid blink") ; SGR 25 ; [console]::Write(" - no blink") ; SGR 0 CUP 14 4 ; SGR 7 ; [console]::Write("Inverse") ; SGR 27 ; [console]::Write(" - no inverse") ; SGR 0 CUP 15 4 ; SGR 8 ; [console]::Write("Invisible") ; SGR 28 ; [console]::Write(" - no invisible") ; SGR 0 CUP 16 4 ; SGR 9 ; [console]::Write("Strikethrough") ; SGR 29 ; [console]::Write(" - no strikethrough") ; SGR 0 From 74d6bb5e9892feb0e1473b0f108c059fdecb7164 Mon Sep 17 00:00:00 2001 From: "Paul \"TBBle\" Hampson" Date: Thu, 15 Jul 2021 05:57:35 +1000 Subject: [PATCH 2/2] Correct ITU T.416-conformant SGR codes for colour selection Per the standard, the `:` character is the separator for the elements of the parameter substring. However, the parameter substring itself is still separated from the SGR value using `;`. References: * 13.1.8 of ISO/IEC 8613-6:1994 (E), aka IT-T Rec. T.416 (1993 E) * https://github.com/csdvrx/sixel-testsuite/blob/master/ansi-vte52.sh Signed-off-by: Paul "TBBle" Hampson --- PowerShell/ColourMatrix.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PowerShell/ColourMatrix.ps1 b/PowerShell/ColourMatrix.ps1 index 0ad8178..4a5461f 100644 --- a/PowerShell/ColourMatrix.ps1 +++ b/PowerShell/ColourMatrix.ps1 @@ -60,8 +60,8 @@ function Set-16Colour { } "V" { $sgr = if ($isbg) {48} else {38} - $pn = if ($script:conformant) { ECMA48SubParams $sgr, 5, $index } else { ECMA48Params $sgr, 5, $index } - [console]::Write([string]::format("{0}{1}m", $CSI, $pn)) + $param = if ($script:conformant) { $(ECMA48SubParams 5, $index) } else { $(ECMA48Params 5, $index) } + [console]::Write([string]::format("{0}{1}m", $CSI, $(ECMA48Params $sgr, $param))) } "T" { $sgr = if ($isbg) {48} else {38} @@ -75,8 +75,8 @@ function Set-16Colour { $g = (($index -band 2) / 2) * $v $b = (($index -band 4) / 4) * $v } - $pn = if ($script:conformant) { ECMA48SubParams $sgr, 2, $null, $r, $g, $b } else { ECMA48Params $sgr, 2, $r, $g, $b } - [console]::Write([string]::format("{0}{1}m", $CSI, $pn)) + $param = if ($script:conformant) { ECMA48SubParams 2, $null, $r, $g, $b } else { ECMA48Params 2, $r, $g, $b } + [console]::Write([string]::format("{0}{1}m", $CSI, $(ECMA48Params $sgr, $param))) } } } else { @@ -105,14 +105,14 @@ function Set-Greyscale { } "V" { $sgr = if ($isbg) {48} else {38} - $pn = if ($script:conformant) { ECMA48SubParams $sgr, 5, $($index + 232) } else { ECMA48Params $sgr, 5, $($index + 232) } - [console]::Write([string]::format("{0}{1}m", $CSI, $pn)) + $param = if ($script:conformant) { ECMA48SubParams 5, $($index + 232) } else { ECMA48Params 5, $($index + 232) } + [console]::Write([string]::format("{0}{1}m", $CSI, $(ECMA48Params $sgr, $param))) } "T" { $index = 8 + $index * 10 $sgr = if ($isbg) {48} else {38} - $pn = if ($script:conformant) { ECMA48SubParams $sgr, 2, $null, $index, $index, $index } else { ECMA48Params $sgr, 2, $index, $index, $index } - [console]::Write([string]::format("{0}{1}m", $CSI, $pn)) + $param = if ($script:conformant) { ECMA48SubParams 2, $null, $index, $index, $index } else { ECMA48Params 2, $index, $index, $index } + [console]::Write([string]::format("{0}{1}m", $CSI, $(ECMA48Params $sgr, $param))) } } } else {