int main(int argc, char *argv[]) { Bool fast = False; int i; for(i = 1; i < argc; i++) /* these options take no arguments */ if(!strcmp(argv[i], "-v")) { /* prints version information */ puts("dmenu-"VERSION", © 2006-2012 dmenu engineers, see LICENSE for details"); exit(EXIT_SUCCESS); } else if(!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ topbar = False; else if(!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = True; else if(!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; } else if(i+1 == argc) usage(); /* these options take one argument */ else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; else if(!strcmp(argv[i], "-fn")) /* font or font set */ font = argv[++i]; else if(!strcmp(argv[i], "-nb")) /* normal background color */ normbgcolor = argv[++i]; else if(!strcmp(argv[i], "-nf")) /* normal foreground color */ normfgcolor = argv[++i]; else if(!strcmp(argv[i], "-sb")) /* selected background color */ selbgcolor = argv[++i]; else if(!strcmp(argv[i], "-sf")) /* selected foreground color */ selfgcolor = argv[++i]; else if(!strcmp(argv[i], "-hist")) histfile = argv[++i]; else usage(); dc = initdc(); initfont(dc, font ? font : DEFFONT); normcol = initcolor(dc, normfgcolor, normbgcolor); selcol = initcolor(dc, selfgcolor, selbgcolor); if(fast) { grabkeyboard(); readitems(); } else { readitems(); grabkeyboard(); } setup(); run(); cleanup(); return ret; }
VInit () { # ifdef MSDOS DOSgetinfo (&LINES, &COLS, &DOSstdattr); scrool = 1; # else CapGet (outtab); if (LINES <= 6 || COLS <= 30) return (0); if (! CM) return (0); scrool = AL && DL; if (! (rscrool = SF && SR)) SF = SR = 0; if (NF) initcolor (); else if (ME) initbold (); if (G1 || G2 || GT) initgraph (); # endif if (curscr.y) delwin (&curscr); if (VScreen.y) delwin (&VScreen); if (! newwin (&curscr) || ! newwin (&VScreen)) { VClose (); return (0); } curscr.flgs = curscr.clear = 1; resetattr (0); return (1); }
void UpdateConfiguration() { extern Boolean init_dvi_file(void); extern void ReopenDviFile(void); initcolor(); /* FIXME : this should happen only if mode or bdpi changed or shrink factor has changed. */ reset_fonts(); reconfig(); SendMessage(hWndDraw, WM_ERASEBKGND, (WPARAM)GetDC(hWndDraw), 0); ChangePage(0); }
void threadmain(int argc, char **argv) { char *p; int lfd; p = "300x40@100,100"; ARGBEGIN{ case 'W': p = ARGF(); break; case 't': textmode = 1; break; case 'k': nokill = 1; break; default: usage(); }ARGEND; if(argc != 1) usage(); winsize = p; title = argv[0]; lfd = dup(0, -1); Binit(&b, lfd, OREAD); rbar = Rect(0, 0, 60, 1); if (!textmode){ if(initdraw(0, nil, "bar") < 0) sysfatal("initdraw: %r"); initcolor(); if((mc = initmouse(nil, screen)) == nil) sysfatal("initmouse: %r"); if((kc = initkeyboard(nil)) == nil) sysfatal("initkeyboard: %r"); display->locking = 1; threadcreate(resizethread, nil, STACK); threadcreate(keyboardthread, nil, STACK); threadcreate(mousethread, nil, STACK); resize(); unlockdisplay(display); } proccreate(updateproc, nil, STACK); }
LRESULT CmdViewConfigOK(HWND hdlg, WORD wCommand, WORD wNotify, HWND hwndCtrl) { /* Retrieve the values in the dialog and set them as current */ /* EndDialog(hdlg, TRUE); /* Exit the dialog */ #if PS ps_destroy(); #endif initcolor(); reconfig(); redraw_page(); return 0; }
Calculator::Calculator(std::vector<ButtonAttribute> button_attributes) { ncurses::initscr(); ncurses::cbreak(); ncurses::keypad(ncurses::stdscr, TRUE); initcolor(); // set up main display main_display = std::make_unique<DisplayComponent>(); // set up key help though hidden key_help = std::make_unique<KeyHelpComponent>(); // for each ComponentAttributes // setup Component and append it to "components" for (auto it = button_attributes.begin(); it != button_attributes.end(); it++){ buttons.push_back(std::make_unique<ButtonComponent>(*it)); } resize(); };
void startmenu(menu *mp, char *mtitle) { initscr(); incurses = TRUE; initcolor(); wtitl = subwin(stdscr, th, bw, 0, 0); wmain = subwin(stdscr, mh, bw, th, 0); wbody = subwin(stdscr, bh, bw, th + mh, 0); wstat = subwin(stdscr, sh, bw, th + mh + bh, 0); colorbox(wtitl, TITLECOLOR, 0); colorbox(wmain, MAINMENUCOLOR, 0); colorbox(wbody, BODYCOLOR, 0); colorbox(wstat, STATUSCOLOR, 0); if (mtitle) titlemsg(mtitle); cbreak(); /* direct input (no newline required)... */ noecho(); /* ... without echoing */ curs_set(0); /* hide cursor (if possible) */ nodelay(wbody, TRUE); /* don't wait for input... */ halfdelay(10); /* ...well, no more than a second, anyway */ keypad(wbody, TRUE); /* enable cursor keys */ scrollok(wbody, TRUE); /* enable scrolling in main window */ leaveok(stdscr, TRUE); leaveok(wtitl, TRUE); leaveok(wmain, TRUE); leaveok(wstat, TRUE); mainmenu(mp); cleanup(); }
void initvmd() { // Assume that VMD should not initialize or use MPI // It is conceivable we would want to be able to load the VMD // Python module into a MPI-based Python run, and enable the // MPI features of VMD, but we'll have to determine the best way // to detect this and it will need to be tested since we may have // to handle this case differently than the normal MPI case where // VMD explicitly does MPI initialization and shutdown itself. int mpienabled = 0; // If there's already a VMDapp in get_vmdapp, then we must be running // inside a standalone VMD instead of being loaded as a python extension. // Don't throw an error - just load the methods for interoperability // in case vmd.so is in the PYTHONPATH of the standalone application. if (get_vmdapp() != NULL) { (void)Py_InitModule((char *)"vmd", VMDAppMethods); return; } int argc=1; char *argv[1]; argv[0] = Py_GetProgramFullPath(); if (!VMDinitialize(&argc, (char ***) &argv, mpienabled)) { return; } // XXX this is a hack, and it would be better to tie this into // VMDApp more directly at some later point, but the regular // VMD startup code is similarly lame, so we'll use it for now. const char *disp = getenv("VMDDISPLAYDEVICE"); if (!disp) disp="text"; int loc[2] = { 50, 50 }; int size[2] = { 400, 400 }; VMDgetDisplayFrame(loc, size); VMDApp *app = new VMDApp(1, argv, mpienabled); app->VMDinit(1, argv, disp, loc, size); // read application defaults VMDreadInit(app); // read user-defined startup files VMDreadStartup(app); set_vmdapp(app); // set my local static the_app = app; PyObject *vmdmodule = Py_InitModule((char *)"vmd", VMDAppMethods); initanimate(); initatomsel(); initaxes(); initcolor(); initdisplay(); initgraphics(); initimd(); initlabel(); initmaterial(); initmolecule(); initmolrep(); initmouse(); initrender(); inittrans(); initvmdmenu(); #ifdef VMDNUMPY initvmdnumpy(); #endif if (PyErr_Occurred()) return; static const char *modules[] = { "animate", "atomsel", "axes", "color", "display", "graphics", "imd", "label", "material", "molecule", "molrep", "mouse", "render", "trans", "vmdmenu", "vmdnumpy" }; for (unsigned i=0; i<sizeof(modules)/sizeof(const char *); i++) { const char *m = modules[i]; #if (PY_MAJOR_VERSION == 2) && (PY_MINOR_VERSION < 5) #define CAST_HACK (char *) #else #define CAST_HACK #endif PyModule_AddObject(vmdmodule, CAST_HACK m, PyImport_ImportModule( CAST_HACK m)); } event_tstate = PyThreadState_Get(); #if defined(VMD_SHARED) PyOS_InputHook = vmd_input_hook; #endif }
int main(int argc, char **argv) { unsigned char buffer[BUFSIZE]; int dumpstyle = ASCII; int size; int s; char *port = NULL, *dev = NULL; struct sockaddr sa; socklen_t asize = sizeof(sa); struct ifreq ifr; int proto = ETH_P_AX25; int exit_code = EXIT_SUCCESS; timestamp = 0; while ((s = getopt(argc, argv, "8achip:rtv")) != -1) { switch (s) { case '8': sevenbit = 0; break; case 'a': proto = ETH_P_ALL; break; case 'c': color = 1; break; case 'h': dumpstyle = HEX; break; case 'i': ibmhack = 1; break; case 'p': port = optarg; break; case 'r': dumpstyle = READABLE; break; case 't': timestamp = 1; break; case 'v': printf("listen: %s\n", VERSION); return 0; case ':': fprintf(stderr, "listen: option -p needs a port name\n"); return 1; case '?': fprintf(stderr, "Usage: listen [-8] [-a] [-c] [-h] [-i] [-p port] [-r] [-t] [-v]\n"); return 1; } } if (ax25_config_load_ports() == 0) fprintf(stderr, "listen: no AX.25 port data configured\n"); if (port != NULL) { if ((dev = ax25_config_get_dev(port)) == NULL) { fprintf(stderr, "listen: invalid port name - %s\n", port); return 1; } } if ((sock = socket(PF_PACKET, SOCK_PACKET, htons(proto))) == -1) { perror("socket"); return 1; } if (color) { color = initcolor(); /* Initialize color support */ if (!color) printf("Could not initialize color support.\n"); } setservent(1); while (!sigint) { asize = sizeof(sa); signal(SIGINT, handle_sigint); signal(SIGTERM, handle_sigint); if ((size = recvfrom(sock, buffer, sizeof(buffer), 0, &sa, &asize)) == -1) { /* * Signals are cared for by the handler, and we * don't want to abort on SIGWINCH */ if (errno == EINTR) { refresh(); continue; } else if (!(errno == EBADF && sigint)) { perror("recv"); exit_code = errno; } break; } signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); if (sock == -1 || sigint) break; if (dev != NULL && strcmp(dev, sa.sa_data) != 0) continue; if (proto == ETH_P_ALL) { strcpy(ifr.ifr_name, sa.sa_data); signal(SIGINT, handle_sigint); signal(SIGTERM, handle_sigint); if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) { if (!(errno == EBADF && sigint)) { perror("SIOCGIFHWADDR"); exit_code = errno; break; } } signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); if (sock == -1 || sigint) break; if (ifr.ifr_hwaddr.sa_family == AF_AX25) { display_port(sa.sa_data); #ifdef NEW_AX25_STACK ax25_dump(buffer, size, dumpstyle); #else ki_dump(buffer, size, dumpstyle); #endif /* lprintf(T_DATA, "\n"); */ } } else { display_port(sa.sa_data); #ifdef NEW_AX25_STACK ax25_dump(buffer, size, dumpstyle); #else ki_dump(buffer, size, dumpstyle); #endif /* lprintf(T_DATA, "\n"); */ } if (color) refresh(); } if (color) endwin(); return exit_code; }