bug-ncurses
[Top][All Lists]
Advanced

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

Problem with color and windows


From: Pure Acetone
Subject: Problem with color and windows
Date: Sat, 17 Apr 2010 20:27:07 +0200

Hi

I'm reading a ncurses' book and one of the examples has a rare behavior. The example is here.


#include <ncurses.h>
#include <stdlib.h>
void bomb(void);
int main(void)
{
    WINDOW *a,*b,*c,*d;
    int maxx,maxy,halfx,halfy;
    int ch;
    initscr();
    start_color();
    init_pair(1,COLOR_BLACK,COLOR_BLUE);
    init_pair(2,COLOR_BLACK,COLOR_RED);
    init_pair(3,COLOR_BLACK,COLOR_GREEN);
    init_pair(4,COLOR_BLACK,COLOR_CYAN);


    getmaxyx(stdscr,maxy,maxx);
    halfx = maxx >> 1;
    halfy = maxy >> 1;


    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();

    wbkgd(a,COLOR_PAIR(1));
    mvwaddstr(a,0,0,"This is window A\n");
    wrefresh(a);
    wbkgd(b,COLOR_PAIR(2));
    mvwaddstr(b,0,0,"This is window B\n");
    wrefresh(b);
    wbkgd(c,COLOR_PAIR(3));
    mvwaddstr(c,0,0,"This is window C\n");
    wrefresh(c);
    wbkgd(d,COLOR_PAIR(4));
    mvwaddstr(d,0,0,"This is window D\n");
    wrefresh(d);

/* IF I REMOVE THIS COMMENT THE GNOME TERMINAL PRINTS  THE SCREEN WITH COLORS AND DIVISIONS
    do
    {
        ch = wgetch(a);
        waddch(b,ch);
        waddch(c,ch);
        waddch(d,ch);
        wrefresh(b);
        wrefresh(c);
        wrefresh(d);
    } while(ch != '~'); */

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


I'm using Debian  with ncurses Versión: 5.7+20100313-2.
Why this behavior?


Regards from Spain.



reply via email to

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