Last active
June 4, 2024 15:22
-
-
Save dsandler/a638057381eb3bae4b28b1ed0adcaef8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val TEMPLATE = "┏━┓┃ ┃┗━┛".toCharArray().map { it.toString() } | |
val TEMPLATE2 = listOf("┌", "─", "┒", | |
"│", " ", "┃", | |
"┕", "━", "┛") | |
val TEMPLATE3 = listOf("┌─", "─", "─┒", | |
"│ ", " ", " ┃", | |
"┕━", "━", "━┛") | |
val ASCII = listOf( | |
"+-", "-", "-+", | |
"| ", " ", " |", | |
"+-", "-", "-+") | |
fun boxLines(lines: List<String>, template: List<String> = TEMPLATE): List<String> { | |
val maxLen = lines.maxOf { it.length } | |
val top = template[0] + template[1].repeat(maxLen) + template[2] | |
val bottom = template[6] + template[7].repeat(maxLen) + template[8] | |
val middleLines = lines.map { | |
template[3] + it + template[4].repeat(maxLen - it.length) + template[5] | |
} | |
return listOf(top) + middleLines + listOf(bottom) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment