Question

I'm building a small script where I'd need to maintain two windows in a terminal (TTY). I'd like to do something like tmux's status bar, but can't manage to get the bottom bar to update meanwhile I'm printing stuff on the rest of the screen. I want it to look like:

|------------------------------------------|
| Whatever I 'puts' here                   |
|                                          |
|                                          |
|                                          |
|                                          |
|------------------------------------------|
| Status bar with whatever I 'puts' here   |
|------------------------------------------|

I've tried with Ruby curses lib, but I think it's an overkill for what I want to do, plus I'm sure there's an easier approach. Thanks!

Was it helpful?

Solution

curses is the right way to do this. You could manually use ANSI scroll regions and cursor positioning but this will be less portable and more work in the long run.

If you want more information on how ANSI terminals work, this wikipedia page is a good starting place with lots of links.

I strongly recommend curses though. Dealing with straight ANSI on one terminal emulator can be a headache; supporting multiple OSes and slight differences in popular terminal emulators isn't worth the trouble (in my opinion.)

OTHER TIPS

+1 for curses (although you probably want ncurses for ongoing development) - it has support for windowed areas of the terminal.

eg. http://linux.die.net/man/3/newwin

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top