bug-ncurses
[Top][All Lists]
Advanced

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

Win32 console application displaying characters a pixel too short


From: BENARD Olivier
Subject: Win32 console application displaying characters a pixel too short
Date: Tue, 23 Jul 2013 10:01:57 +0000

Hello,

 

Continuing on the problem I have with mvaddstr() displaying characters a pixel too short, I have written a little test case to demonstrate the problem. Nothing fancy in the code, just the initialization of NCurses with colors + pairings and random display of value of key pressed as an integer on the screen. Clearly, this isn’t related to wide characters at all, but more likely a problem with colors (since the problem doesn’t occur when displaying « white » characters on the screen).

 

Here’s my code :

 

#include <stdlib.h>

#define bool int

#include <curses.h>

 

#define PAIR_WHITE 0

#define PAIR_RED 1

#define PAIR_GREEN 2

#define PAIR_YELLOW 3

#define PAIR_BLUE 4

#define PAIR_MAGENTA 5

#define PAIR_CYAN 6

#define PAIR_BLACK 7

 

int main(int argc, char* argv[])

{

    int colortable[16];

    int x, y, i;

    unsigned short a;

    char s[10];

    int key;

 

    initscr();

    start_color();

    init_pair(PAIR_RED, COLOR_RED, COLOR_BLACK);

    init_pair(PAIR_GREEN, COLOR_GREEN, COLOR_BLACK);

    init_pair(PAIR_YELLOW, COLOR_YELLOW, COLOR_BLACK);

    init_pair(PAIR_BLUE, COLOR_BLUE, COLOR_BLACK);

    init_pair(PAIR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);

    init_pair(PAIR_CYAN, COLOR_CYAN, COLOR_BLACK);

    init_pair(PAIR_BLACK, COLOR_BLACK, COLOR_BLACK);

    colortable[0]  = (COLOR_PAIR(PAIR_WHITE));

    colortable[1]  = (COLOR_PAIR(PAIR_WHITE) | A_BOLD);

    colortable[2]  = (COLOR_PAIR(PAIR_RED));

    colortable[3]  = (COLOR_PAIR(PAIR_RED) | A_BOLD);

    colortable[4]  = (COLOR_PAIR(PAIR_GREEN));

    colortable[5]  = (COLOR_PAIR(PAIR_GREEN) | A_BOLD);

    colortable[6]  = (COLOR_PAIR(PAIR_YELLOW));

    colortable[7]  = (COLOR_PAIR(PAIR_YELLOW) | A_BOLD);

    colortable[8]  = (COLOR_PAIR(PAIR_BLUE));

    colortable[9]  = (COLOR_PAIR(PAIR_BLUE) | A_BOLD);

    colortable[10] = (COLOR_PAIR(PAIR_MAGENTA));

    colortable[11] = (COLOR_PAIR(PAIR_MAGENTA) | A_BOLD);

    colortable[12] = (COLOR_PAIR(PAIR_CYAN));

    colortable[13] = (COLOR_PAIR(PAIR_CYAN) | A_BOLD);

    colortable[14] = (COLOR_PAIR(PAIR_BLACK));

    colortable[15] = (COLOR_PAIR(PAIR_BLACK) | A_BOLD);

    noecho();

    keypad(stdscr, TRUE);

 

    for (i = 0; i < 1000; i++)

    {

        y = random(24);

        x = random(78);

        a = random(16);

        key = getch();

        itoa(key, s, 10);

        attrset(colortable[a]);

        mvaddstr(y, x, s);

    }

 

    endwin();

    return 0;

}

 

When executing this little test case (for example by pressing ‘h’ repeatedly), it’s easy to see that some of the text written on the screen overlaps after a while. Any idea where’s the problem ? In my code ? In the console api ? In NCurses ?


reply via email to

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