crossword
0.4.0indexedA 2D text canvas for rendering in console applications, handling multi-character codepoints and ANSI control sequences for colored text output without overwriting issues.
163
Stars
—
Used by
dependents
—
Health
/ 100
A 2D text canvas for rendering in console applications, handling multi-character codepoints and ANSI control sequences for colored text output without overwriting issues.
A 2D canvas for rendering text, usually for console applications.
val canvas = TextCanvas(40, 8)
canvas.write(1, 20, "Such canvas")
canvas.write(6, 30, "Very 2D")
canvas.write(4, 7, "Much monospace")
println(canvas)
Such canvas
Much monospace
Very 2D
Not very impressive. However, TextCanvas automatically handles multi-char codepoints and ANSI
control sequences.
For example, rendering a red X at (0,0) and a blue O at (0, 2) means writing 10 characters each:
canvas.write(0, 0, "\u001B[31mX\u001B[0m")
canvas.write(0, 2, "\u001B[34mO\u001B[0m")
X O
Such canvas
Much monospace
Very 2D
(Note: GitHub/markdown do not allow coloring text so use your imagination)
If TextCanvas was a naive 2D char[] the O would have overwritten almost all of the X's ANSI
escape sequence.
repositories {
mavenCentral()
}
dependencies {
implementation 'com.jakewharton.crossword:crossword:0.4.0'
}
repositories {
maven {
url 'https://central.sonatype.com/repository/maven-snapshots/'
}
}
dependencies {
implementation 'com.jakewharton.crossword:crossword:0.5.0-SNAPSHOT'
}
Copyright 2020 Jake Wharton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
Surfaced from shared tags and platforms — no rankings paid for.