Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix length with Add-Border when using ANSI #79

Closed
jdhitsolutions opened this issue May 15, 2020 · 1 comment
Closed

Fix length with Add-Border when using ANSI #79

jdhitsolutions opened this issue May 15, 2020 · 1 comment
Assignees
Labels

Comments

@jdhitsolutions
Copy link
Owner

When using ANSI escapes in the text, the length of the text is being calculated including the ANSI escapes. Need to subtract that count to get the "real" length.

$s = �[38;5;47mBOVINE320�[0m Up:2.21:40:11 %FreeMem:�[92m52.1�[0m %FreeC:�[93m40.29�[0m %FreeD:�[93m20.86�[0m


[regex]$a="$([char]0x1b)\[\d+[\d;]+m"

[regex]$b="$([char]0x1b)\[0m"

$adjust = 0
$adjust+= ($a.matches($s) | measure length -sum).sum
$adjust+= ($b.matches($s) | measure length -sum).sum

#real length
$s.length - $adjust
@jdhitsolutions jdhitsolutions self-assigned this May 15, 2020
@jdhitsolutions
Copy link
Owner Author

This should be fixed in v2.24.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant