I'm writing a program in curses
and sometimes happens that if I leave the program opened and I use other terminal tabs for a while, when I go using the program again it seems like it has refreshed something and something has disappeared... I cannot show pics or screenshots because I haven't understood yet well when and how it happens... Is there a way to prevent or fix this?

- 69,918
- 32
- 186
- 246

- 476
- 1
- 6
- 20
-
There's not enough information to guess what you are seeing. – Thomas Dickey Jun 16 '15 at 23:53
-
I know in fact I didn't know if pubblishthis question... but I reallly don't know why it happens... – Alessio Ragno Jun 16 '15 at 23:54
-
For example I use a window with many boxes... When this happens all the boxes disappear like something has been refreshed over...It's like the window refreshes over the boxes.. – Alessio Ragno Jun 17 '15 at 00:01
-
getch/wgetch refreshes the window which it refers to (stdscr in the case of getch). You are likely seeing that. – Thomas Dickey Jun 17 '15 at 00:04
-
I have a similar window like this: http://stackoverflow.com/questions/30828804/how-to-make-a-scrolling-menu-in-python-curses ... but with more boxes... Sometimes, when I switch terminal tabs and then I reopen the tab where the script was running, the box disappears... I can make it refresh by pressing a key because it refreshes every keypress but i have also more boxes wich do not refresh every keypress so I can't make them refresh... I hope you could understand something.. – Alessio Ragno Jun 17 '15 at 00:05
1 Answers
screen.getch
reads from stdscr
, and if it refreshes (due to any change on the screen), will overwrite boxes
. You could change that to box.getch
, as I did in scroll page by page or line by line using python curses
The manual page for getch
says
If the window is not a pad, and it has been moved or modified since the last call to wrefresh, wrefresh will be called before another character is read.
In your sample program you used
screen.keypad( 1 )
which only applies to reading from the standard screen. If you read from the box
window, you should set the keypad flag on that:
box.keypad( 1 )
The manual page for keypad
says
The default value for keypad is FALSE
that is, it is the default for each window.
A curses program with multiple windows can choose to read from different windows at different times. There is only one input buffer for each screen, but the side-effect of refreshing the current window makes it simpler to manage updates to the windows. (For complicated window stacking order, you would use the panel
library rather than rely upon this side-effect).

- 1
- 1

- 51,086
- 7
- 70
- 105
-
I cannot use box.getch() because I have seen that if I use it, it gives me problems: Sometimes in fact it didn't get the right char or something similar.. – Alessio Ragno Jun 17 '15 at 00:13