Skip to contentSkip to conversation

Bug or hidden feature ?

DISCUSSION Alain Birtz 1 participant 1 message Jul 30, 1999

lore
Share & tools
lore
#0 lore raw

/*
In the code below, the second loop print char exactly is the same place as the first loop. The only change is the char printed. Hit 3 time a key

A strange thing happen when the last half end of the line hold only blanck space character.
Normally the blank must erase the underscore. This not happen. Instead the remaining of the line (after the underscore) is erased.

This seem happen only in the X term window
Tested in Gnome terminal (linucPPC R5)
Is it an hidden feature ? Or is there something wrong with the code ? */

// gcc -I/usr/include/ncurses tst_addch.c -g -o tst -lncurses

#include <curses.h>

int main()
{
int r, c;

initscr();

for (r = 0; r < LINES; r++) /* fill screen of letter, so we can see
what happen */
{
for (c = 0; c < COLS; c++)
mvaddch(r, c, 'A'+ r);
}
refresh();
getchar();

// FIRST LOOP

for (r = 2; r < LINES - 2; r++) /* write in middle of the screen */
{
for (c = 3; c < COLS / 2; c++)
if (c < COLS / 5)

    mvaddch(r, c, '*');
   else
    mvaddch(r, c, '_');  /* first loop -> use underscore */

}
refresh();
getchar();

// SECOND LOOP

for (r = 2; r < LINES - 2; r++) /* write in same place */
{
for (c = 3; c < COLS / 2; c++)
if (c < COLS / 5)

    mvaddch(r, c, '/');
   else
    mvaddch(r, c, ' ');  /* second loop -> use blanck space char */

}
refresh();
getchar();

endwin();
exit(0);
}

// the second loop is same as the first loop, except for the char printed
// the underscore is not replaced by the blank char
// but the remainning of the line (after the unserscore) is erased // if the terminal window is small, this not happen

[[ This message was sent via the linuxppc-dev mailing list. Replies are ]] [[ not forced back to the list, so be sure to Cc linuxppc-dev if your ]] [[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting. ]]