A Word about Windows

NCURSES Programming HOWTO
Prev |  | Next

# 5. A Word about Windows

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

A Window is an imaginary screen defined by curses system. A window does not mean a bordered window which you usually see on Win9X platforms. When curses is initialized, it creates a default window 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 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

        printw("Hi There !!!");
        refresh();

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

Say you have created windows then you have to call a function with a 'w' added to the usual function.

        wprintw(win, "Hi There !!!");
        wrefresh(win);

As you will see in the rest of the document, naming of functions follow the same convention. For each function there usually are three more functions.

        printw(string);        /* Print on stdscr at present cursor position */
        mvprintw(y, x, string);/* Move to (y, x) then print string     */
        wprintw(win, string);  /* Print on window win at present cursor position */
                               /* in the window */
        mvwprintw(win, y, x, string);   /* Move to (y, x) relative to window */
                                        /* co-ordinates and then print         */

Usually the w-less functions are macros which expand to corresponding w-function with stdscr as the window parameter.

Prev | Home | Next
Initialization |  | Output functions