Вопрос

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!

Это было полезно?

Решение

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.)

Другие советы

+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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top