Hi,
Is there an equivalent of this C line in Roc? I would like to use colors and cursor motion.
printf("\033[%dm %3d\033[m", n, n);
Don't have a full answer, but probably not really tested yet.
The first %d
is pretty straight forward:
xStr = Num.toStr x
"\(xStr)"
We don't currently have something like %3d
to my knowledge. You would have to make it programmatically.
oh, I meant the color thing, not the params
The rest, not sure what is/isn't supported currently
It might depend on the platform since we would be passing a Str to the platform
I took it from here https://en.wikipedia.org/wiki/ANSI_escape_code#In_C
I also tried this (which works in Rust):
println!("\x1b[93mHello\x1b[0m");
But compiler complains that the escape sequence is not recognized
Ah. Ok. Yeah i think we currently have limited escape sequences. Not sure the plan here.
@Richard Feldman do we have a way to support arbitrary Unicode? For you have to convert from int to str or should it be escapable?
we already do, although it may not be documented
I'm on my phone and haven't used it in over a year, but if I remember right it's "\u(1234)"
yep, that's it!
Awesome!
Last updated: Jul 06 2025 at 12:14 UTC