bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

refresh before wrefresh


From: Dan Gookin
Subject: refresh before wrefresh
Date: Sun, 22 Aug 2010 22:27:03 -0700

Is a refresh() required to display a window before a wrefresh() is used?

I have a program that makes four windows within the terminal window. Each 
window is created with newwin(). Text is written with mvwaddstr() to each 
window, followed by a wrefresh() command on that window. But the text doesn't 
show up unless there is an initial refresh() command given earlier in the code. 
Is that normal behavior? The reason I'm asking is that the code worked for 
older versions of Ncurses, but doesn't work now.

Also, internally, doesn't wrefresh() call the same function as refresh()?

Thanks for any insight.

Relevant code:

#include <ncurses.h>
#include <stdlib.h>

void bomb(void);

int main(void)
{
        WINDOW *a,*b,*c,*d;
        int maxx,maxy,halfx,halfy;
                
        initscr();
        refresh();

/* calculate window sizes and locations */
        getmaxyx(stdscr,maxy,maxx);
        halfx = maxx >> 1;
        halfy = maxy >> 1;

/* create four windows to fill the screen */
        if( (a = newwin(halfy,halfx,0,0)) == NULL) bomb();
        if( (b = newwin(halfy,halfx,0,halfx)) == NULL) bomb();
        if( (c = newwin(halfy,halfx,halfy,0)) == NULL) bomb();
        if( (d = newwin(halfy,halfx,halfy,halfx)) == NULL) bomb();
        
/* Write to each window */
        mvwaddstr(a,0,0,"This is window A\n");
        wrefresh(a);
        mvwaddstr(b,0,0,"This is window B\n");
        wrefresh(b);
        mvwaddstr(c,0,0,"This is window C\n");
        wrefresh(c);
        mvwaddstr(d,0,0,"This is window D\n");
        wrefresh(d);
        getch();

        endwin();
        return 0;
}

void bomb(void)
{
        addstr("Unable to allocate memory for new window.\n");
        refresh();
        endwin();
        exit(1);
}



Best,
DAN




reply via email to

[Prev in Thread] Current Thread [Next in Thread]