I use codiva to do my coding on a chromebook. I was just wondering if I could create graphics in a console output. For example, my text right now is plain and normal(it prints in the console as plain text). Is there a way to bold, emphasize, or even change the color of the text if I can only use the console for output(no canvas, Jframe, popup, etc.)?
I have tried "\u001B[1m (bold text)" and all I get is (see Output). Same goes for the italic one.
Output:

The interpretation of control sequences is subject of the specific console and it seems, codiva.ioβs console doesnβt interpret any control sequences.
However, since itβs displayed in a browser and browsers usually have broad Unicode support, you can achieve a limited formatting using special codepoints. E.g.
class HelloCodiva {
public static void main(String[] args) {
System.out.println("Formatted: "
+ bold("bold") + " " + italic("italic") + " " + bold(italic("both")));
}
static CharSequence bold(CharSequence cs) {
return trans(cs, 0x1D400, 0x1D41A);
}
static CharSequence italic(CharSequence cs) {
return trans(cs, 0x1D434, 0x1D44e);
}
static CharSequence trans(CharSequence cs, int upper, int lower) {
return cs.codePoints()
.map(cp -> cp >= 'A' && cp <= 'Z'? cp + upper - 'A':
cp >= 'a' && cp <= 'z'? cp + lower - 'a':
cp >= 0x1D400 && cp <= 0x1D433? cp + 104:
cp >= 0x1D434 && cp <= 0x1D467? cp + 52:
cp)
.collect(StringBuilder::new,
StringBuilder::appendCodePoint, StringBuilder::append);
}
}
prints
Formatted: ππ¨π₯π ππ‘ππππ ππππ
In codiva.ioβs console.
The limitation is that it only works for letters. But for highlighting important words, it might be sufficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With