Next: The Gory Details, Previous: Hello World!!!, Up: Curses Tutorial [Contents][Index]
guile-ncurses-shell
If you would like to try out these functions interactively by typing
them into the scheme shell, instead of typing them and running them
as scripts, the program guile-ncurses-shell
can be used. The
problem with interactive Guile sessions using curses
is that
you are typing into the same screen that curses is trying to manage,
which leads to confusing results. The program
guile-ncurses-shell
, which must be run on X, starts an
interactive guile session and creates and xterm
that will be
managed by curses. The results of the curses function calls will
appear in the xterm
, instead of in the screen where the
interactive guile session occurs.
Here we’ll try four functions: initscr
sets up the screen,
addstr
writes a string to the screen, refresh
redraws
the screen, and endwin
frees the screen.
Upon initialization guile-ncurses-shell
automatically calls these functions.
(use-modules (ncurses curses)) (define %guile-ncurses-shell-stdscr (initscr))
It loads the ncurses module; initializes the screen; and
saves the returned ncurses screen structure in the variable
%guile-ncurses-shell-stdscr
. Thus, you do not need to call
(initscr)
in your interactive session when you use
guile-ncurses-shell
.
The first thing you want to do is to redefine the name of the standard window to something more reasonable.
(define win %guile-ncurses-shell-stdscr)
To check and see if the guile-ncurses-shell is working, you can write a string onto the created xterm.
(addstr win "hello, world!") (refresh win)
The guile-ncurses-shell communicates with the xterm using a read port
and a write port. If, for some obscure reason, you need to access the
read or write port directly, they are stored in the variables
%guile-ncurses-shell-read-port
and
%guile-ncurses-shell-write-port
.
When exiting an interactive session, by C-D for example,
guile-ncurses-shell
automatically calls (endwin)
, so you
do not need to call that yourself.
Next: The Gory Details, Previous: Hello World!!!, Up: Curses Tutorial [Contents][Index]