11<?xml version =" 1.0" encoding =" utf-16" ?>
2- <!-- Generated with EZOut 1.9.8 : Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+ <!-- Generated with EZOut 1.9.9 : Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
33<Configuration >
44 <SelectionSets >
55 <SelectionSet >
@@ -975,7 +975,7 @@ if ($Request -or $Host.UI.SupportsHTML) {
975975 .Notes
976976 Stylized Output works in two contexts at present:
977977 * Rich consoles (Windows Terminal, PowerShell.exe, Pwsh.exe) (when $host.UI.SupportsVirtualTerminal)
978- * Web pages (Based off the presence of a $Request variable, or when $host.UI.SupportsHTML (you must add this property to $host.UI))
978+ * Web pages (Based off the presence of a $Request variable, or when $host.UI.SupportsHTML (you must add this property to $host.UI))
979979 #>
980980 [Management.Automation.Cmdlet("Format","Object")]
981981 [ValidateScript({
@@ -1032,7 +1032,16 @@ if ($Request -or $Host.UI.SupportsHTML) {
10321032 $Link,
10331033
10341034 # If set, will not clear formatting
1035- [switch]$NoClear
1035+ [switch]$NoClear,
1036+
1037+ # The alignment. Defaulting to Left.
1038+ # Setting an alignment will pad the remaining space on each line.
1039+ [ValidateSet('Left','Right','Center')]
1040+ [string]
1041+ $Alignment,
1042+
1043+ # The length of a line. By default, the buffer width
1044+ [int]$LineLength = $($host.UI.RawUI.BufferSize.Width)
10361045 )
10371046
10381047 begin {
@@ -1042,6 +1051,19 @@ if ($Request -or $Host.UI.SupportsHTML) {
10421051 Output='';Error='BrightRed';Warning='BrightYellow';
10431052 Verbose='BrightCyan';Debug='Yellow';Progress='Cyan';
10441053 Success='BrightGreen';Failure='Red';Default=''}
1054+
1055+ $ansiCode = [Regex]::new(@'
1056+ (?< ANSI_Code>
1057+ (?-i)\e # An Escape
1058+ \[ # Followed by a bracket
1059+ (?< ParameterBytes> [\d\:\;\< \=\> \?]{0,}) # Followed by zero or more parameter
1060+ bytes
1061+ (?< IntermediateBytes> [\s\!\"\#\$\%\& \'\(\)\*\+\,\-\.\/]{0,}) # Followed by zero or more
1062+ intermediate bytes
1063+ (?< FinalByte> [\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]\^_\`abcdefghijklmnopqrstuvwxyz\{\|\}\~]) # Followed by a final byte
1064+
1065+ )
1066+ '@)
10451067 $esc = [char]0x1b
10461068 $standardColors = 'Black', 'Red', 'Green', 'Yellow', 'Blue','Magenta', 'Cyan', 'White'
10471069 $brightColors = 'BrightBlack', 'BrightRed', 'BrightGreen', 'BrightYellow', 'BrightBlue','BrightMagenta', 'BrightCyan', 'BrightWhite'
@@ -1227,14 +1249,18 @@ if ($Request -or $Host.UI.SupportsHTML) {
12271249 elseif ($canUseANSI) {'' +$esc + "[21m" }
12281250 }
12291251
1230- if ($Hyperlink) {
1252+ if ($Alignment -and $canUseHTML) {
1253+ "display:block;text-align:$($Alignment.ToLower())"
1254+ }
1255+
1256+ if ($Link) {
12311257 if ($canUseHTML) {
12321258 # Hyperlinks need to be a nested element
12331259 # so we will not add it to style attributes for HTML
12341260 }
12351261 elseif ($canUseANSI) {
12361262 # For ANSI,
1237- '' + $esc + ']8m;;' + $Hyperlink + $esc + '\'
1263+ '' + $esc + ']8m;;' + $Link + $esc + '\'
12381264 }
12391265 }
12401266
@@ -1247,8 +1273,8 @@ if ($Request -or $Host.UI.SupportsHTML) {
12471273 )$(
12481274 if ($cssClasses) { " class='$($cssClasses -join ' ')'"}
12491275 )> " + $(
1250- if ($Hyperlink ) {
1251- "< a href='$hyperLink '> "
1276+ if ($Link ) {
1277+ "< a href='$link '> "
12521278 }
12531279 )
12541280 } elseif ($canUseANSI) {
@@ -1257,21 +1283,47 @@ if ($Request -or $Host.UI.SupportsHTML) {
12571283 }
12581284
12591285 process {
1286+ $inputObjectAsString =
1287+ "$(if ($inputObject) { $inputObject | Out-String})".Trim()
1288+
1289+ $inputObjectAsString =
1290+ if ($Alignment -and -not $canUseHTML) {
1291+ (@(foreach ($inputObjectLine in ($inputObjectAsString -split '(?> \r\n|\n)')) {
1292+ $inputObjectLength = $ansiCode.Replace($inputObjectLine, '').Length
1293+ if ($inputObjectLength -lt $LineLength) {
1294+ if ($Alignment -eq 'Left') {
1295+ $inputObjectLine
1296+ } elseif ($Alignment -eq 'Right') {
1297+ (' ' * ($LineLength - $inputObjectLength)) + $inputObjectLine
1298+ } else {
1299+ $half = ($LineLength - $inputObjectLength)/2
1300+ (' ' * [Math]::Floor($half)) + $inputObjectLine +
1301+ (' ' * [Math]::Ceiling($half))
1302+ }
1303+ }
1304+ else {
1305+ $inputObjectLine
1306+ }
1307+ }) -join [Environment]::NewLine) + [Environment]::newline
1308+ } else {
1309+ $inputObjectAsString
1310+ }
1311+
12601312 $allOutput +=
12611313 if ($header) {
1262- "$header" + "$(if ($inputObject) { $inputObject | Out-String})".Trim()
1314+ "$header" + $inputObjectAsString
12631315 }
12641316 elseif ($inputObject) {
1265- ($inputObject | Out-String).Trim()
1266- }
1317+ $inputObjectAsString
1318+ }
12671319 }
12681320
12691321 end {
12701322
12711323 if (-not $NoClear) {
12721324 $allOutput +=
12731325 if ($canUseHTML) {
1274- if ($Hyperlink ) {
1326+ if ($Link ) {
12751327 "< /a> "
12761328 }
12771329 "< /span> "
@@ -1305,7 +1357,7 @@ if ($Request -or $Host.UI.SupportsHTML) {
13051357 "$esc[49m"
13061358 }
13071359
1308- if ($Hyperlink ) {
1360+ if ($Link ) {
13091361 "$esc]8;;$esc\"
13101362 }
13111363
0 commit comments