Well this code works almost perfect.. but there is just one thing... i check this out
Code:
you have typed the down key
you have typed the down key
you have typed the down key
you have typed left arrow
you have typed left arrow
you have typed left arrow
you have typed the down key
you have typed the down key
you have typed the down key
you have typed the down keyyou have typed the down keyyou have typed the down
well the prob here is that once it gets to the end
it wont pring on a new line anymore.. as you can see... so how can i make it so it can print on a new line..
heres the code...
Code:
start_color();
keypad(stdscr,TRUE);
box(stdscr,0,0);
while(1)
{
ch = getch();
switch(ch)
{
case KEY_LEFT:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
printw("you have typed left arrow\n");
attroff(COLOR_PAIR(2));
break;
case KEY_RIGHT:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
printw("you have typed right arrow\n");
attroff(COLOR_PAIR(2));
break;
case KEY_UP:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
printw("you have typed up arrow\n");
break;
case KEY_DOWN:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
printw("you have typed the down key\n");
break;
}
}
refresh();
endwin();
return 0;
}
i added the top part as code cause i didt now what else to use.. to keep it neat =)