[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: endwin, and temporarily leaving curses mode
From: |
Thomas Dickey |
Subject: |
Re: endwin, and temporarily leaving curses mode |
Date: |
Fri, 21 Apr 2006 12:49:35 -0400 (EDT) |
On Fri, 21 Apr 2006, Mike Mueller wrote:
I'm working on a program which spends all its time in
curses/raw/noecho mode. Recently I started working on a feature that
lets users drop out to a shell temporarily. This seems to be a common
thing to do, and the answer in the docs is endwin() before the shell,
and refresh() after, as seen here:
http://www.roseindia.net/linux/tutorial/linux-howto/NCURSES-Programming-HOWTO/misc.html#TEMPLEAVE
However, I run endwin(), then invoke the shell (via system()) and the
result is somewhat correct, but not completely. The shell displays a
normal prompt, but typed characters are not echoed back to the
terminal. 'ls' displays things in neat columns, so it seems like
I don't see this (checking with ncurses' test program - menu 'a', 's' to
shell-out).
we're in a semi-cooked mode. Finally, when the user exits the shell,
I prompt "press enter to continue" and call fgets() to wait for that
'enter' before anything else happens. Unfortunately, hitting enter
(or ^M) doesn't do anything at this prompt. Hitting ^J, on the other
hand, does work.
When I call refresh(), curses is back to normal and my app is working
fine. So the problem is only in the endwin-shell part of the process.
That part is expected behavior: refresh() checks to see if there was an
endwin() which reset the terminal modes. I don't recall(*) a bug in this
area - but it is possible to confuse things by saving the ncurses terminal
modes as the default, e.g.,
The def_prog_mode and def_shell_mode routines save the current terminal
modes as the "program" (in curses) or "shell" (not in curses) state for
use by the reset_prog_mode and reset_shell_mode routines. This is done
automatically by initscr. There is one such save area for each screen
context allocated by newterm().
(*) but if I knew the version of ncurses and the platform, something might
come to mind.
--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net