enforce_n1
enforce_n1

Reputation: 23

ncurses - No output from pad

Trying to get output from pad, but getting only a blank screen.

#include "curses.h"

int main()
{
    initscr();
    WINDOW *pad = newpad(25, 80);

    wprintw(pad, "Hello, World!\n");
    prefresh(pad, 0, 0, 0, 0, 25, 80);

    wgetch(pad);

    delwin(pad);
    endwin();
}

Upvotes: 2

Views: 762

Answers (1)

Thomas Dickey
Thomas Dickey

Reputation: 54475

Running in a 40x80 screen, I get output (the "Hello, World!" message). Perhaps your screen is only 24x80. The parameters for the prefresh call cannot exceed the screen-size, and since you did not enable scrolling (scrollok), the wgetch hangs without displaying anything.

This example works for instance:

#include <curses.h>

int main(void)
{   
    initscr();
    WINDOW *pad = newpad(LINES+1, COLS);

    wprintw(pad, "Hello, World!\n");
    prefresh(pad, 0, 0, 0, 0, LINES-1, COLS);

    wgetch(pad);

    delwin(pad);
    endwin();
    return 0;
}

Upvotes: 1

Related Questions