Hacker News new | past | comments | ask | show | jobs | submit login

Happy was the day I gave up on curses and just started splatting crap at the terminal with my own control codes.

For too long did I think that curses was the one and only way to do anything with a terminal.




Care to elaborate on the control codes over curses? I’m curious :]


At its simplest, manage screen state yourself and redraw it by moving the cursor and colouring with ANSI codes:

https://gist.github.com/fnky/458719343aabd01cfb17a3a4f729679...

Turning the cursor on and off, 24 bit color, etc. A lot is possible though you potential sacrifice portability (which in 2021 translates to “don’t expect your stuff to render properly if your at the Linux console, and everywhere else it is fine.”)


I 'maintain' a shell script/library that can do a lot of the basic things like color controls, control getch, move the screen cursor, etc. [0]

Taking a peek under covers to see how easy it is. A couple printfs from whatever language is way way less overhead than bundling in the whole of curses.

[0] https://git.sr.ht/~shakna/damned


Yes, it's unquestionably always good to know how things work.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: