Next: , Previous: Initialization, Up: Curses Tutorial   [Contents][Index]

4.5 A word about windows

Before we plunge into the myriad ncurses functions, let me clear a few things about windows. Windows are explained in detail in the following sections.

A window is an imaginary screen defined by the curses system. A window does not mean a bordered window which you usually see in GNOME or KDE system. When curses is initialized, it creates a default window conventionally named stdscr which represents your 80x25 (or the size of window in which you are running) screen. If you are doing simple tasks like printing a few strings, reading input, etc., you can safely use this single window for all of your purposes. You can also create windows and call functions which explicitly work on the specified window.

For example, if you call

(addstr stdscr "Hi There!!!")
(refresh stdscr)

It prints the string on stdscr at the present cursor position. Similarly, the call to refresh works on stdscr only.

Say you have created multiple windows, then you have to call the functions separately on each window. When you call refresh, you need to call it on the window that was updated.

(addstr win "Hi There!!!")
(refresh win)

For many functions, there are optional key parameters.

(addstr stdscr string)             ; Print on stdscr at present
                                   ; cursor location
(addstr stdscr string #:y y #:x x) ; Move to (y, x) then print string