mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Center.
This commit is contained in:
parent
70a23f0d27
commit
5be21a7647
2 changed files with 9 additions and 3 deletions
|
@ -42,7 +42,7 @@ class AsciiArt {
|
||||||
val maxString: String = strings.maxBy { it.length } ?: ""
|
val maxString: String = strings.maxBy { it.length } ?: ""
|
||||||
val max = maxString.length
|
val max = maxString.length
|
||||||
val result = arrayListOf(ul + r(max + 2, h) + ur)
|
val result = arrayListOf(ul + r(max + 2, h) + ur)
|
||||||
result.addAll(strings.map { "$v $it ${fill(max - it.length)}$v" })
|
result.addAll(strings.map { "$v ${center(it, max - 2)} $v" })
|
||||||
result.add(bl + r(max + 2, h) + br)
|
result.add(bl + r(max + 2, h) + br)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,13 @@ class AsciiArt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun logBox(s: String, print: (String) -> Unit = defaultLog) {
|
fun logBox(s: String, print: (String) -> Unit = defaultLog) {
|
||||||
logBox(listOf(s))
|
logBox(listOf(s), print)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun center(s: String, width: Int) : String {
|
||||||
|
val diff = width - s.length
|
||||||
|
val spaces = diff / 2 + 1
|
||||||
|
return fill(spaces) + s + fill(spaces + if (diff % 2 == 1) 1 else 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ResolveDependency @Inject constructor(val repoFinder: RepoFinder) {
|
||||||
val repoResult = repoFinder.findCorrectRepo(id)
|
val repoResult = repoFinder.findCorrectRepo(id)
|
||||||
|
|
||||||
val simpleDep = SimpleDep(MavenId(id))
|
val simpleDep = SimpleDep(MavenId(id))
|
||||||
val url = "Full URL: " + repoResult.repoUrl + simpleDep.toJarFile(repoResult)
|
val url = repoResult.repoUrl + simpleDep.toJarFile(repoResult)
|
||||||
AsciiArt.logBox(listOf(id, url), {s -> println(s) })
|
AsciiArt.logBox(listOf(id, url), {s -> println(s) })
|
||||||
|
|
||||||
display(root.children)
|
display(root.children)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue