pdcurses buggy?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

pdcurses buggy?

Mark Junker
Hi,

is the pdcurses version (from the MinGW web site) buggy?

When you compile my test application with MinGW (pdcurses), you get the
following output:

H 0, 0, 1, 8, 64
0, 1
00000048, 00000000, 00000000, 48, H
0000, 0000
0000, 0000, 0000
0000, 0000, 0000

but it should be something like this (cygwin)

H 0, 0, 0, 8, 64
0, 1
00000048, 00000000, 00000000, 48, H
0007, 0000
02a8, 02a8, 02a8
0000, 0000, 0000

Meaning:

H(test character) current_curses_x, current_curses_y,
start_color_result, colors, pairs
current_curses_x, current_curses_y
character(hex), attributes, color, chtype_value, character(char)
color_foreground, color_background
color_foreground_red, color_foreground_green, color_foreground_blue
color_background_red, color_background_green, color_background_blue

As you can see, start_color() returns OK (=1) when using pdcurses. But
for the given color_pair, it returns 0 as fore- and background color.
Any idea what might go wrong?

Regards,
Mark


CFLAGS := -Wall -O2
CXXFLAGS := -Wall -O2
LDFLAGS := -lpdcurses

all: test_curses_001

clean:
        rm -f *~ *.exe *.o *.a *.bak *.~*

test_curses_001: test_curses_001.o
        g++ -o $@ $^ $(LDFLAGS)

%.o: %.cpp
        g++ $(CXXFLAGS) -c -o $@ $^

%.o: %.c
        gcc $(CFLAGS) -c -o $@ $^


#include <windows.h>

#include <curses.h>

void gotoxy(int x, int y)
{
    //mvwprintw(stdscr, y, x, "");
    move(y-1, x-1);
}

int wherex(void) {
    int y, x;
    getyx(stdscr, y, x);
    return x;
}

int wherey(void) {
    int y, x;
    getyx(stdscr, y, x);
    return y;
}

#if 0
#define _NOCURSOR             0
#define _NORMALCURSOR         1
#define _SOLIDCURSOR          2

void _setcursortype(int cur_t) {
    switch (cur_t) {
    case _NOCURSOR:
        leaveok(stdscr, TRUE);
        curs_set(0);
        break;
    case _NORMALCURSOR:
        leaveok(stdscr, FALSE);
        curs_set(1);
    case _SOLIDCURSOR:
        leaveok(stdscr, FALSE);
        curs_set(2);
        break;
    }
}
#endif

class conio {
public:
    conio(void) {
        initscr();
        col_result = start_color();
        cbreak();
        noecho();
        nonl();
        intrflush(stdscr, FALSE);
        keypad(stdscr, TRUE);
        scrollok(stdscr, FALSE);
        meta(stdscr, TRUE);
        nodelay(stdscr, TRUE);
    }

    ~conio(void)
    {
        endwin();
    }

    int col_result;
};

static conio _conio;

int main(int argc, char **argv)
{
    gotoxy(1,1);
    printw("H %d, %d, %d, %d, %d",
           wherex(),
           wherey(),
           _conio.col_result,
           COLORS,
           COLOR_PAIRS);
    gotoxy(1,2);
    printw("%d, %d", wherex(), wherey());
    refresh();

    chtype ch = mvinch(0,0);
    gotoxy(1,3);
    printw("%08lx, %08lx, %08lx, %lx, %c",
           (long) (ch & A_CHARTEXT),
           (long) (ch & A_ATTRIBUTES),
           (long) (ch & A_COLOR),
           (long) ch,
           (char) (ch & A_CHARTEXT));

    if (has_colors()) {
        short f=0, b=0;
        pair_content(PAIR_NUMBER(ch), &f, &b);
        gotoxy(1,4);
        printw("%04hx, %04hx",
               f,
               b);

        short rf=0, gf=0, bf=0;
        short rb=0, gb=0, bb=0;

        color_content(f, &rf, &gf, &bf);
        color_content(b, &rb, &gb, &bb);

        gotoxy(1,5);
        printw("%04hx, %04hx, %04hx",
               rf, gf, bf);
        gotoxy(1,6);
        printw("%04hx, %04hx, %04hx",
               rb, gb, bb);

        refresh();
    }

    Sleep(5000);
    return 0;
}