Skip to content

Commit

Permalink
This is ConciseView
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed Sep 30, 2024
1 parent ef79331 commit acb6387
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions source/private/TruncateString.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
filter TruncateString {
[CmdletBinding()]
param(
# The input string will be wrapped to a certain length, with optional padding on the front
[Parameter(ValueFromPipeline)]
[string]$InputObject,

[Parameter(Position = 0)]
[Alias('Length')]
[int]$Width = ($Host.UI.RawUI.BufferSize.Width)
)
# $wrappableChars = [char[]]" ,.?!:;-`n`r`t"
# $maxLength = $width - $IndentPadding.Length -1
$wrapper = [Regex]::new("((?:$AnsiPattern)*[^-=,.?!:;\s\r\n\t\\\/\|]+(?:$AnsiPattern)*)", "Compiled")

if ($InputObject.Length -le $Width) {
return $InputObject
}

($InputObject.Substring(0,$length) -split $wrapper,-2)[0]
}

0 comments on commit acb6387

Please sign in to comment.