YaY i finaly got the box working.. but i cant seem to make it move =( can anyone help please..
Code:
WINDOW *windows(int x, int y, int height, int width);
int main()
{
WINDOW *win;
int ch;
int x,y;
int height = 3;
int width = 10;
initscr();
cbreak();
start_color();
keypad(stdscr,TRUE);
x = (LINES - height) / 2;
y = (COLS - width) / 2;
printw("Press F1 to exit\n");
win = windows(height, width, x, y);
while(1)
{
ch = getch();
if(ch == KEY_F(1))
{
refresh();
endwin();
return 0;
}
switch(ch)
{
case KEY_LEFT:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
win = windows(height, width, x, y);
attroff(COLOR_PAIR(2));
break;
case KEY_RIGHT:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
win = windows(height, width, x, y);
attroff(COLOR_PAIR(2));
break;
case KEY_UP:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
win = windows(height, width, x, y);
break;
case KEY_DOWN:
init_pair(2,COLOR_RED, COLOR_BLACK);
attron(COLOR_PAIR(2));
win = windows(height, width, x, y);
break;
}
}
refresh();
endwin();
return 0;
}
WINDOW *windows(int x, int y, int height, int width)
{
WINDOW *local_win;
local_win = newwin(height, width, x, y);
box(local_win,0,0);
wrefresh(local_win);
return local_win;
}