void windowing02( ) { WIN win; int ch; init_pair( 5, COLOR_CYAN, COLOR_BLACK ); // erase the text on the window erase( ); move( 0, 0 ); // Assign border characters and starting width/height/position init_win_params( &win ); print_win_params( &win ); // Draw bold backgrounded text at the top of the screen attron( COLOR_PAIR(5) | A_BOLD ); printw( "Press X to exit" ); refresh( ); attroff( COLOR_PAIR(5) | A_BOLD ); attrset( A_NORMAL ); // Draw the box onto the screen create_box( &win ); // While the input character isn't an x, perform some actions while( (ch = getch()) != 'x' ) { // Use the keyboard keys to "move" the box (destroy and recreate it) switch ( ch ) { case KEY_LEFT: destroy_box( &win ); win.startx--; create_box( &win ); break; case KEY_RIGHT: destroy_box( &win ); win.startx++; create_box( &win ); break; case KEY_UP: destroy_box( &win ); win.starty--; create_box( &win ); break; case KEY_DOWN: destroy_box( &win ); win.starty++; create_box( &win ); break; default: break; } } return; }
int init_gui() { WIN win; int ch; int i; char ** files; initscr(); /* Start curses mode */ start_color(); /* Start the color functionality */ cbreak(); /* Line buffering disabled, Pass on * everty thing to me */ keypad(stdscr, TRUE); /* I need that nifty F1 */ noecho(); init_pair(1, COLOR_CYAN, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); /* Initialize the window parameters */ init_win_params(&win); print_win_params(&win); attron(COLOR_PAIR(1)); printw("F2: Ouvrir un fichier"); printw("\t F3: Lancer l'émulation"); printw("\t F5: Quitter"); attron(A_BOLD); attron(COLOR_PAIR(2)); char chaine[]="Welcome to ProcSI emulator"; mvprintw((LINES/2) -3,(COLS-strlen(chaine))/2,chaine); attroff(A_BOLD); refresh(); attroff(COLOR_PAIR(1)); create_box(&win, TRUE); draw_menu(choices, execute_main_menu, "", 3); while((ch = getch()) != KEY_F(5)) { switch(ch) { case KEY_F(5): mvprintw(LINES-2, 0, "Exiting..."); endwin(); /* End curses mode */ exit(0); case KEY_F(2): files = list_file("", &i); draw_menu(files, execute_file_menu, "", i); } } endwin(); /* End curses mode */ return 0; }
int main( int argc, char *argv[] ) { WIN win; int ch; initscr(); // start CURSES mode start_color(); // start color functionality cbreak(); // disable line buffering keypad( stdscr, TRUE ); // enable Fx notify noecho(); init_pair( 1, COLOR_CYAN, COLOR_BLACK ); init_win_params( &win ); // initialize window parameter print_win_params( &win ); attron( COLOR_PAIR( 1 ) ); printw( "Press F12 to exit" ); refresh(); attroff( COLOR_PAIR( 1 ) ); create_box( &win, TRUE ); while( ( ch = getch() ) != KEY_F( 12 ) ) { switch( ch ) { case KEY_LEFT: create_box( &win, FALSE ); --win.startx; create_box( &win, TRUE ); break; case KEY_RIGHT: create_box( &win, FALSE ); ++win.startx; create_box( &win, TRUE ); break; case KEY_UP: create_box( &win, FALSE ); --win.starty; create_box( &win, TRUE ); break; case KEY_DOWN: create_box( &win, FALSE ); ++win.starty; create_box( &win, TRUE ); break; } } endwin(); // end CURSES mode return 0; }
int main(int argc, char *argv[]) { WIN win; int ch; initscr(); /* Start curses mode */ start_color(); /* Start the color functionality */ cbreak(); /* Line buffering disabled, Pass on * everty thing to me */ keypad(stdscr, TRUE); /* I need that nifty F1 */ noecho(); init_pair(1, COLOR_CYAN, COLOR_BLACK); /* Initialize the window parameters */ init_win_params(&win); print_win_params(&win); attron(COLOR_PAIR(1)); printw("Press F1 to exit"); refresh(); attroff(COLOR_PAIR(1)); create_box(&win, TRUE); while((ch = getch()) != KEY_F(1)) { switch(ch) { case KEY_LEFT: create_box(&win, FALSE); --win.startx; create_box(&win, TRUE); break; case KEY_RIGHT: create_box(&win, FALSE); ++win.startx; create_box(&win, TRUE); break; case KEY_UP: create_box(&win, FALSE); --win.starty; create_box(&win, TRUE); break; case KEY_DOWN: create_box(&win, FALSE); ++win.starty; create_box(&win, TRUE); break; } } endwin(); /* End curses mode */ return 0; }
int main(int argc, char const *argv[]) { WIN win; int ch; initscr(); start_color(); cbreak(); keypad(stdscr, TRUE); noecho(); init_pair(1, COLOR_CYAN, COLOR_BLACK); init_win_params(&win); print_win_params(&win); attron(COLOR_PAIR(1)); printw("Press F1 to exit"); refresh(); attroff(COLOR_PAIR(1)); create_box(&win, TRUE); while ((ch = getch()) != KEY_F(1)) { switch (ch) { case KEY_LEFT: create_box(&win, FALSE); --win.startx; create_box(&win, TRUE); break; case KEY_RIGHT: create_box(&win, FALSE); ++win.startx; create_box(&win, TRUE); break; case KEY_UP: create_box(&win, FALSE); --win.starty; create_box(&win, TRUE); break; case KEY_DOWN: create_box(&win, FALSE); ++win.starty; create_box(&win, TRUE); break; } } endwin(); return 0; }
void printWin(int arr[HIGHT][WIDTH]) { init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_YELLOW, COLOR_BLACK); init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(5, COLOR_MAGENTA, COLOR_BLACK); init_pair(6, COLOR_CYAN, COLOR_BLACK); init_pair(7, COLOR_WHITE, COLOR_BLACK); init_pair(8, COLOR_WHITE, COLOR_YELLOW); WIN win[HIGHT][WIDTH]; int i, j; for(i = 0; i < HIGHT; i++) { for(j = 0; j < WIDTH; j++) { int offset; WIN *thewin = &win[i][j]; init_win_params(&win[i][j], j-3, i-3); print_win_params(&win[i][j]); attron(COLOR_PAIR(7)); create_box(&win[i][j], TRUE); attroff(COLOR_PAIR(7)); mvprintw(thewin->starty + WINY/2 , thewin->startx + WINX/2-4,"%s", " "); if(arr[i][j] == 0){ attron(COLOR_PAIR(1)); offset = 0; } else { attron(COLOR_PAIR((int)log2((double)arr[i][j])%7 + 1)); offset = (int)(log10((double)arr[i][j])/2); } mvprintw(thewin->starty + WINY/2 , thewin->startx + WINX/2-offset,"%d", arr[i][j]); if(arr[i][j] == 0){ attroff(COLOR_PAIR(1)); } else { attroff(COLOR_PAIR((int)log2((double)arr[i][j])%7 + 1)); } mvprintw(10,10,"%s%d","Your Score: ", SCORE); move(1000,10000); } } refresh(); }