Hello,
another weekend with a free time, so I'm playing around with Nim. I decided I'll try to write a little terminal plaything but after having a good luck with the fact that terminal implements almost everything I wanted I got stuck on getch() — as I guessed it only picks up the alphanumeric characters. ESC or F1 or → all produce 7 when I ord() the return value.
Maybe I'm missing something? Like switching stdout to raw?
import terminal
setForegroundColor(stdout, ForegroundColor.fgRed)
setStyle(stdout, {Style.styleBlink, Style.styleBright})
var c = getch()
echo(c, ord(c))
Any pointers would be welcomed!
(Or maybe I should go directly to ncurses?)
The problem's not with the lib. Go ahead try it in C, you should get the same results.
Yeah, h24, I'll probably get ncurses, I bet I'll get stuck on another solved issue if I'll stick to trying to make RAW work for me.
Thanks for your help!
Check out the console snippet editor snip I did a few months ago. It's far from perfect but works well enough.
The code is mainly in key.nim and keymap.nim.