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

what you ask is impossible. unless you do:

1. get the screen height 2. draw a block with ascii art with that height. 3. when done put height*line breaks to clean the screen.

or do you want something to handle termcap for you? `dialog` i think does that




I said ANSI-capable. I also assumed the terminal dimensions are either fixed or can be retrieved somehow, e.g. from the environment or via an ioctl like in Unixy systems.

So TIOCGWINSZ for the dimensions. And printf("\033[7m") to get a background for the box (you can use colors too, though I think they're mostly fugly). printf("\033[2J") to clean the screen.

https://en.wikipedia.org/wiki/ANSI_escape_sequence

Using an API wrapping the database of terminal incompatibility might've been a good idea in the days of hardwired glass terminals. But nowadays it can cause more problems than it solves, plus it's ugly as hell. Also, we now have standards and emulators to rely on for when you can't otherwise adapt.

Try get to your shell on an older Solaris box connecting via rxvt-unicode. Oh, missing a terminfo entry? That's easy (if you know how to add it, as a user). But, wait, the name of the terminal is too long! So all applications which rely on curses or term(info|crap) will give you grief. Even though all terminals (terminal emulators really) people use these days support a reasonable subset of the ANSI escape codes -- and when they don't, you can run something like GNU screen between your terminal and the application. Things would just work if applications assumed a standard and didn't rely on a huge database and thousands of lines of code to deal with it.




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

Search: