ps/Modules/Cole.PowerShell.Developer/Public/Get-ConsoleDisplayWidth.ps1
2023-05-30 22:51:22 -07:00

19 lines
528 B
PowerShell

function Get-ConsoleDisplayWidth {
<#
.SYNOPSIS
Get the width of the current UI, if possible
.PARAMETER DefaultDisplayWidth
Supply a value if you want the default to be considered something else
#>
param(
$DefaultDisplayWidth = 80
)
$maxDisplayWidth = $DefaultDisplayWidth
if (($null -ne $host) -and ($null -ne $host.UI) -and ($null -ne $host.UI.RawUI) -and ($null -ne $host.UI.RawUI.WindowSize)) {
$maxDisplayWidth = $host.UI.RawUI.WindowSize.Width
}
return $maxDisplayWidth
}