1
+ <#
2
+ . SYNOPSIS
3
+ Gets a box's middle vertical wall character
4
+ . DESCRIPTION
5
+ Gets the middle vertical wall in a box.
6
+ . NOTES
7
+ If the box only has one line, and it is less than 5 characters, the second character will be considered the top wall.
8
+
9
+ If it only has one character, it will be considered the middle wall.
10
+
11
+ Otherwise, the character directly left of the middle will be considered the middle wall.
12
+ #>
13
+ $theseLines = @ ($this -split ' [\r\n]+' -ne ' ' )
14
+
15
+ if (-not $theseLines ) { return }
16
+ $theLine = $theseLines [[Math ]::Floor ($theseLines.Length / 2 )]
17
+ if ($theLine.Length -lt 5 ) {
18
+ # If there is only one line, it is between two and five characters
19
+ if ($theLine.Length -ge 2 ) {
20
+ # pick the second character as the top wall
21
+ $theLine.Substring (1 , 1 )
22
+ } else {
23
+ # (if there was only one character, it's the top wall)
24
+ $theLine.Substring (0 , 1 )
25
+ }
26
+ }
27
+ elseif ($theseLines.Length -gt 1 ) {
28
+ $theLine = $theseLines [[Math ]::Floor ($theseLines.Length / 2 ) - 1 ]
29
+ $theLine.Substring (([Math ]::Floor($theLine.Length / 2 )), 1 )
30
+ }
31
+ else {
32
+ # Otherwise, pick one left of the middle in the line
33
+ $theLine.Substring (([Math ]::Floor($theLine.Length / 2 ) - 1 ), 1 )
34
+ }
0 commit comments