int main(int ac, char **av) { WINDOW *my_wins[3]; PANEL *my_panels[3]; setlocale(LC_ALL, ""); Explorer exp((ac < 2) ? "/" : av[1]); exp.sort(); MenuLeft menu_left(&exp); MenuRight menu_right(&exp); initCurses(); initColor(); init_wins(my_wins, 3); menu_left.setup(my_wins[0]); menu_right.setup(my_wins[1]); traceExplorateur(); refresh(); setUpPanel(my_panels, my_wins); eventManager(&menu_left, &menu_right, my_wins[2], my_panels); endwin(); std::cout << exp << std::endl; return 0; }
int main() { initCurses(); CGame game; game.Init(); while(game.GameLoop()) {} stopCurses(); return 0; }
int main(int argc, const char *argv[]) { int fd; char filename[MAX_FILENAME]; static META_DATA meta; //File specified in command line if (argc == 2) { memcpy(filename, argv[1], MAX_FILENAME); getLock(filename); if (open(filename, O_RDONLY, 0600) == -1){ printf("ERROR: File doesn't exist\n"); close(fd); removeLock(filename); exit(1); } close(fd); removeLock(filename); } if (argc == 1) { //Read filename from .draw_config getLock(filename); fd = open (".draw_config", O_RDONLY, 0600); read (fd, filename, MAX_FILENAME); close (fd); removeLock(filename); } if (argc == 1 || argc == 2) { initCurses(); //Open canvas file fd = open (filename, O_RDONLY, 0600); //read metadata from file read (fd, &meta, sizeof(META_DATA)); //read first FIGURE from file if(meta.numP > 0) { showPeople(fd, meta); } } close(fd); removeLock(filename); refresh(); endCurses(); return 0; }
int main() { do { initCurses(); drawBoard(); } while (playGame()); endwin(); return(0); }
Game::Game() { //init vars seed = 0; if(DEBUG) std::cout << "Game object created...\n"; initCurses(); console = Console::instance(); newGame(); }
void Engine::start() { //start console thread console_thread = new sf::Thread(&Engine::console, this); console_thread->launch(); //init curses std::cout << "Initializing SFMLCurs..."; if(initCurses()) std::cout << "done.\n"; else std::cout << "failed.\n"; //init screen std::cout << "Initializing screen..."; if(initScreen()) std::cout << "done.\n"; else std::cout << "failed.\n"; std::cout << "Initializing liquids..."; if(initLiquids()) std::cout << "done.\n"; else std::cout << "failed.\n"; std::cout << "Initializing map tiles..."; if(initMapTiles()) std::cout << "done.\n"; else std::cout << "failed.\n"; std::cout << "Initializing monster database list..."; if(initMonsters()) std::cout << "done.\n"; else std::cout << "failed.\n"; std::cout << "Initializing item database list..."; if(initItems()) std::cout << "done.\n"; else std::cout << "failed.\n"; //debug noise //noisetest(); std::cout << "Starting new game.\n"; newGame(); //start mainloop std::cout << "Starting main loop...\n"; mainLoop(); //if player died... if(!m_Player->isAlive()) playerDeath(); }
/* Initialize the program Starts ncurses and draws the initial screen Creates all the pipes Forks all the children */ int main() { initCurses(); drawScreen(); setupSigs(); screenHeight = getHeight(); screenWidth = getWidth(); int i; copper = (gvpipe_t *) calloc (NUM_PIPE, sizeof(gvpipe_t)); seedDroneRand(); Drone drone = createDrone(screenWidth, screenHeight); int giveDrone = findQuad(drone.locX, drone.locY); //creating all pipes for (i = 0; i < NUM_PIPE; i++) pipe (copper[i]); //create children for (i = 0; i < NUM_CHILD; i++) { pids[i] = fork (); if (pids[i] == 0) { if(i == giveDrone) begin(i, copper, NUM_CHILD, NUM_PIPE, drone, 1, screenHeight, screenWidth); else begin(i, copper, NUM_CHILD, NUM_PIPE, drone, 0, screenHeight, screenWidth); exit (0); } } waitForChildren(); free(copper); return; }
int main(int argc, char *argv[]) { if(argc >= 2) { if(strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0) { printf("\nConway\n"); printf("Copyright 2015 Harley Wiltzer\n\n"); printf("conway:\t\tOpen conway with a random color\n"); printf("conway 1:\tOpen conway blue theme\n"); printf("conway 2:\tOpen conway red theme\n"); printf("conway 3:\tOpen conway green theme\n"); printf("conway 4:\tOpen conway yellow theme\n"); printf("conway 5:\tOpen conway light blue theme\n"); printf("conway 6:\tOpen conway orange theme\n"); printf("conway 7:\tOpen conway white theme\n"); printf("\n"); printf("While running conway...\n"); printf("=======================\n"); printf("q:\t\tClose conway\n"); printf("space:\t\tActivate/Kill cell\n"); printf("enter:\t\tStart ticking\n"); printf("h:\t\tMove cursor left\n"); printf("j:\t\tMove cursor down\n"); printf("k:\t\tMove cursor up\n"); printf("l:\t\tMove cursor right\n"); printf("d:\t\tClear all cells\n"); printf("=:\t\tIncrease the amount of ticks by 10\n"); printf("-:\t\tDecrease the amount of ticks by 10\n"); printf("+:\t\tIncrease the amount of ticks by 1\n"); printf("_:\t\tDecrease the amount of ticks by 1\n"); return 0; } } int i, c; initCurses(); showSplash(); totalTicks = 0; refresh(); getch(); win = createWindow(WIN_WIDTH,rows,0,cols - WIN_WIDTH - 1); cols = cols - WIN_WIDTH - 1; xs = rows; ys = cols / 2; area = rows * cols; game = createWindow(cols - 1,rows,0,0); ticks = DEFAULT_TICKS; int cells[area / 2]; for(i = 0; i < area/2; i++) { cells[i] = 0; } x = y = row = col = 0; if(has_colors() == 0) wprintw(game,"NO COLORS\n"); if(argc < 2) { srand(time(NULL)); color = rand()%7 + 1; } else { if(atoi(argv[1]) > 7 || atoi(argv[1]) < 1) { srand(time(NULL)); color = rand()%7 + 1; } else { color = atoi(argv[1]); } } x = ys/2; y = xs/2; wmove(game,y, x * 2); x = 2; y = 2; wrefresh(game); updateWin(cells,area/2); wmove(game,y,x * 2); x = ys/2; y = xs/2; wmove(game,y,x * 2); while((ch = getch()) != 'q') { wclear(game); wclear(win); int r, c; render(cells,area/2); wmove(game,y, x * 2); switch(ch) { case 'h': if (x % ys == 0) break; x -= 1; wmove(game,y, x * 2); wrefresh(game); break; case 'j': if ((y + 1) % xs == 0) break; y += 1; wmove(game,y, x * 2); wrefresh(game); break; case 'k': if (y % xs == 0) break; y -= 1; wmove(game,y, x * 2); wrefresh(game); break; case 'l': if((x+1)%ys == 0) break; x += 1; wmove(game,y, x * 2); wrefresh(game); break; case ' ': cells[y * ys + x] = !cells[y * ys + x]; if(cells[y * ys + x]) drawCell(x,y); else eraseCell(x,y); updateWin(cells,area/2); break; case '\n': update(cells, area/2); break; case 'd': memset(cells,0,area/2); int q; for(q = 0; q < area/2; q++) { cells[q] = 0; } totalTicks = 0; render(cells, area/2); updateWin(cells,area/2); break; case '=': ticks += 10; updateWin(cells,area/2); break; case '-': if(ticks >= 20) ticks -= 10; updateWin(cells,area/2); break; case '+': ticks++; updateWin(cells,area/2); break; case '_': if(ticks > 2) ticks--; updateWin(cells, area/2); break; default: break; } updateWin(cells,area/2); wrefresh(game); } destroyWindow(game); destroyWindow(win); endwin(); return 0; }
int main (int argc, char **argv) { int c; int ret; proz_init (argc, argv); //init libprozilla set_defaults (); //set some reasonable defaults load_prefs (); //load values from the config file while ((c = getopt_long (argc, argv, "?hvrfk:1Lt:VgsP:", long_opts, NULL)) != EOF) { switch (c) { case 'L': license (); exit (0); case 'h': help (); exit (0); case 'V': version (); exit (0); case 'r': rt.resume_mode = RESUME; break; case 'f': rt.force_mode = TRUE; break; case 'k': if (setargval (optarg, &rt.num_connections) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the -k option\n" "Please type proz --help for help\n")); exit (0); } if (rt.num_connections == 0) { printf (_("Hey! How can I download anything with 0 (Zero)" " connections!?\n" "Please type proz --help for help\n")); exit (0); } break; case 't': if (setargval (optarg, &rt.max_attempts) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the -t or --tries option(s)\n" "Please type proz --help for help\n")); exit (0); } break; case 'n': /* * Don't use ~/.netrc" */ rt.use_netrc = FALSE; break; case 'P': /* * Save the downloaded file to DIR */ rt.output_dir = kstrdup (optarg); break; case '?': help (); exit (0); break; case '1': rt.num_connections = 1; break; case 'g': /* * TODO solve this soon */ printf ("Error: GTK interface is not supported in " "the development version currently\n"); exit (0); break; case 129: /* * lets use PORT as the default then */ rt.ftp_use_pasv = FALSE; break; case 130: /* * retry-delay option */ if (setargval (optarg, &rt.retry_delay) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --retry-delay option\n" "Please type proz --help for help\n")); exit (0); } break; case 131: /*--timout option */ if (setargval (optarg, &rt.itimeout) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --timeout option\n" "Please type proz --help for help\n")); exit (0); } break; case 132: /* --no-getch option */ rt.dont_prompt = TRUE; break; case 133: /* --debug option */ rt.debug_mode = TRUE; rt.libdebug_mode=TRUE; break; case 'v': /* --verbose option */ rt.quiet_mode = FALSE; break; case 's': /* --ftpsearch option */ rt.ftp_search = TRUE; break; case 135: /* --no-search option */ rt.ftp_search = FALSE; break; case 136: /* --pt option */ if (setargval (optarg, &rt.max_ping_wait) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --pt option\n" "Please type proz --help for help\n")); exit (0); } if (rt.max_ping_wait == 0) { printf (_("Hey! Does waiting for a server response for Zero(0)" " seconds make and sense to you!?\n" "Please type proz --help for help\n")); exit (0); } break; case 137: /* --pao option */ if (setargval (optarg, &rt.max_simul_pings) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --pao option\n" "Please type proz --help for help\n")); exit (0); } if (rt.max_simul_pings == 0) { printf (_("Hey you! Will pinging Zero(0) servers at once" " achive anything for me!?\n" "Please type proz --help for help\n")); exit (0); } break; case 138: /* --max-ftp-servers option */ if (setargval (optarg, &rt.ftps_mirror_req_n) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --pao option\n" "Please type proz --help for help\n")); exit (0); } if (rt.ftps_mirror_req_n == 0) { printf (_("Hey! Will requesting Zero(0) servers at once" "from the ftpearch achive anything!?\n" "Please type proz --help for help\n")); exit (0); } break; case 139: /* --max-bps */ if (setlongargval (optarg, &rt.max_bps_per_dl) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --max-bps option\n" "Please type proz --help for help\n")); exit (0); } break; case 140: rt.display_mode = DISP_STDOUT; break; case 141: /* --min-size */ if (setlongargval (optarg, &rt.min_search_size) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --min-size option\n" "Please type proz --help for help\n")); exit (0); } break; case 142: /* --ftpsid */ if (setargval (optarg, &rt.ftpsearch_server_id) != 1) { /* * The call failed due to a invalid arg */ printf (_("Error: Invalid arguments for the --ftpsid option\n" "Please type proz --help for help\n")); exit (0); } if (rt.ftpsearch_server_id < 0 || rt.ftpsearch_server_id >1) { printf (_("The available servers are (0) filesearching.com and (1) ftpsearch.elmundo.es\n" "Please type proz --help for help\n")); exit (0); } break; default: printf (_("Error: Invalid option\n")); exit (0); } } set_runtime_values (); //tell libprozilla about any changed settings if (optind == argc) { help (); } else { /* Gettext stuff */ setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); /*delete the ~/.prozilla/debug.log file if present at the start of each run */ proz_debug_delete_log (); if (rt.display_mode == DISP_CURSES) initCurses(); /* we will now see whether the user has specfied any urls in the command line and add them */ for (int i = optind; i < argc; i++) { uerr_t err; urlinfo *url_data; url_data = (urlinfo *) malloc (sizeof (urlinfo)); memset (url_data, 0, sizeof (urlinfo)); //parses and validates the command-line parm err = proz_parse_url (argv[i], url_data, 0); if (err != URLOK) { PrintMessage (_ ("%s does not seem to be a valid URL"), argv[optind]); proz_debug ("%s does not seem to be a valid URL", argv[optind]); exit (0); } PrintMessage("Starting....."); //In to %s\n",url_data->host); // start the download ret=open_new_dl_win (url_data, rt.ftp_search); /*If the download failed the return -1 */ if(ret==-1) { free(url_data); delete(dl_win); shutdown(); return -1; } delete(dl_win); free (url_data); } } shutdown(); }
int main(void) { //extern variables char *help_topic=NULL,*fname=NULL,buff[5000]={'\0'},file[50]={}; int logc,logr,ch,i,j,k,flag; FILE *fp; // initialise curses mode and colors initCurses(); noecho(); cbreak(); keypad(stdscr,TRUE); mousemask(ALL_MOUSE_EVENTS,NULL); curs_set(0); //displays starting blue screen Screen(); while(1) { int ch; ch=getResponse(); switch(ch) { //file menu case 1: //pop up menu file (WINDOW**)draw_menu(fmenu,SIZE(fmenu),1,0); break; //new item case 2: refresh(); //draws black screen new_file(); noecho(); //displays filename and line number on black screen New(); break; //Return To Shell case 5: clear(); refresh(); endwin(); system("sh"); clear(); refresh(); Screen(); break; //exit menu case 6: clear(); refresh(); endwin(); exit(EXIT_SUCCESS); break; /*compile menu case 7: //pop up menu compile (WINDOW**)draw_menu(cmenu,SIZE(cmenu),1,12); break; */ /*compile item case 8: compile(); break;*/ //help menu case 11: //pop up help menu (WINDOW**)draw_menu(hmenu,SIZE(hmenu),1,27); break; //help index case KEY_F(1): case 12: Help(); break; //help topic case 13: help_topic=(char*)calloc(30,sizeof(char)); help_topic=dialog("| Help |"," Find "," Cancel "); break; //open file case KEY_F(3): case 3: k=0; for(i=2;i<22;++i) { for(j=0;j<78;++j) buff[k++]=(mvinch(i,j)&A_CHARTEXT); buff[k++]='\n'; } new_file(); //pops up open dialogbox fname=(char*)calloc(30,sizeof(char)); fname=dialog("| Open |"," Open "," Cancel "); //if user press cancel display screen contents if((strlen(fname)==0)) { logc=1;logr=2; for(k=0;buff[k]!='\0';++k) { refresh(); if(buff[k]=='\n') { logr+=1; logc=1; move(logr+1,logc); } else { mvaddch(logr,logc,buff[k]); logc+=1; } } } //othewise open a file and display it's contents else { //redraws new screen new_file(); if(!(fp=fopen(fname,"r"))) { warning("| Warning |"," No such file ","Press a key to return !!!"); getch(); //new_file(); logc=1;logr=2; for(k=0;buff[k]!='\0';++k) { refresh(); if(buff[k]=='\n') { logr+=1; logc=1; move(logr+1,logc); } else { mvaddch(logr,logc,buff[k]); logc+=1; } } } //if file is exist display contents else { new_file(); logc=1;logr=2; while((ch=fgetc(fp))!=EOF) { if(ch=='\n') { logr+=1; logc=1; move(logr+1,logc); } else { mvaddch(logr,logc,ch); logc+=1; } } fclose(fp); move(2,2); refresh(); //displays file name move(1,2); hline(ACS_HLINE,75); strcat(file,"| "); strcat(file,fname); strcat(file," |"); //move(1,2); //hline(ACS_HLINE,60); writeString(stdscr,1,35,file,white_black); } } break; } } }