int main(void) { use_env(FALSE); initscr(); printw("LINES = %d\n",LINES); printw("COLS = %d\n",COLS); refresh(); getch(); endwin(); return 0; }
int main(int argc, char *argv[]) { int i; char *test_path = NULL; #ifdef HAVE_SETLOCALE setlocale(LC_ALL, ""); #endif if (argc < 2) { goto usage; } for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "--strip")) conf.strip = 1; else if (!strcmp(argv[i], "--env")) conf.use_env = 1; else test_path = argv[i]; } if (conf.use_env) return use_env(); else { if (!test_path) goto usage; return use_conf(test_path); } usage: fprintf(stderr, "argc =%d\n", argc); fprintf(stderr, "usage: %s [--strip] [--env] test_dir\n", argv[0]); return 2; }
int load_termcap(char *termtype){ #if HAVE_TERMINFO || HAVE_TERMCAP #if HAVE_TERMINFO use_env(TRUE); int ret; if (setupterm(termtype, 1, &ret) != OK) { /* try again, with with "ansi" terminal if it was unset before */ if (!termtype) termtype = getenv("TERM"); if (!termtype || *termtype == '\0') termtype = "ansi"; if (setupterm(termtype, 1, &ret) != OK) { if (ret < 0) { printf("Could not access the 'terminfo' data base.\n"); return 0; } else { printf("Couldn't use terminal `%s' for input.\n", termtype); return 0; } } } #else static char term_buffer[2048]; if (!termtype) termtype = getenv("TERM"); if (!termtype) termtype = "ansi"; int success = tgetent(term_buffer, termtype); if (success < 0) { printf("Could not access the 'termcap' data base.\n"); return 0; } else if (success == 0) { printf("Terminal type `%s' is not defined.\n", termtype); return 0; } #endif ensure_cap(&termcap_buf, 2048); static char term_buf[64]; char *buf_ptr = &term_buf[0]; erase_to_end_of_line = tgetstr("ce", &buf_ptr); screen_width = tgetnum("co"); screen_height = tgetnum("li"); if (screen_width < 1 || screen_width > 255) screen_width = 80; if (screen_height < 1 || screen_height > 255) screen_height = 24; term_smkx = tgetstr("ks", &buf_ptr); term_rmkx = tgetstr("ke", &buf_ptr); cap_key_pair keys[] = { {"kP", MP_KEY_PGUP}, {"kN", MP_KEY_PGDWN}, {"kh", MP_KEY_HOME}, {"kH", MP_KEY_END}, {"kI", MP_KEY_INS}, {"kD", MP_KEY_DEL}, /* on PC keyboards */ {"@7", MP_KEY_END}, {"kl", MP_KEY_LEFT}, {"kd", MP_KEY_DOWN}, {"ku", MP_KEY_UP}, {"kr", MP_KEY_RIGHT}, {"do", MP_KEY_ENTER}, {"kb", MP_KEY_BS}, {"k1", MP_KEY_F+1}, {"k2", MP_KEY_F+2}, {"k3", MP_KEY_F+3}, {"k4", MP_KEY_F+4}, {"k5", MP_KEY_F+5}, {"k6", MP_KEY_F+6}, {"k7", MP_KEY_F+7}, {"k8", MP_KEY_F+8}, {"k9", MP_KEY_F+9}, {"k;", MP_KEY_F+10}, {"k0", MP_KEY_F+0}, /* K2 is the keypad center */ {"K2", MP_KEY_KP5}, /* EOL */ {NULL}, }; for (int i = 0; keys[i].id; i++) { termcap_add(keys[i]); } termcap_add_extra_f_keys(); #endif /* special cases (hardcoded, no need for HAVE_TERMCAP) */ /* it's important to use keys_push_once as we can't have duplicates */ /* many terminals, for emacs compatibility, use 0x7f instead of ^H when typing backspace, even when the 'kb' cap says otherwise. */ keys_push_once("\177", MP_KEY_BS); /* mintty always sends these when using the numpad arrows, even in application mode, for telling them from regular arrows. */ keys_push_once("\033[A", MP_KEY_UP); keys_push_once("\033[B", MP_KEY_DOWN); keys_push_once("\033[C", MP_KEY_RIGHT); keys_push_once("\033[D", MP_KEY_LEFT); /* mintty uses this instead of the "K2" cap for keypad center */ keys_push_once("\033OE", MP_KEY_KP5); return getch2_keys.len; }
int main(int argc, char *argv[]) /* main program */ { int x, retval = 1; /* counters, etc. */ off_t val, len; /* len need to be off_t*/ windows = (WINS *) calloc(1, sizeof(WINS)); /* malloc windows */ head = llalloc(); /* malloc list space */ fpINfilename = NULL; /* allocate in and */ fpOUTfilename = NULL; /* out file name ptrs */ printHex = TRUE; /* address format */ USE_EBCDIC = FALSE; /*use ascii by default*/ /* get cmd line args */ len = parseArgs(argc, argv); MIN_ADDR_LENGTH = getMinimumAddressLength(len); use_env(TRUE); /* use env values */ slk_init(0); /* init menu bar */ init_screen(); /* init visuals */ init_colors(); if ((COLS < MIN_COLS) || (LINES < MIN_LINES)) /* screen's too small */ { endwin(); fprintf(stderr,"\n\nThe screen size too small.\nThe minimum allowable"); fprintf(stderr," screen size is %dx%d\n\n", MIN_COLS, MIN_LINES + 1); exit(-1); } slk_set(6, (printHex) ? "Hex Addr":"Dec Addr", 1); init_fkeys(); /* define menu bar */ while (retval) { free_windows(windows); /* calculate screen */ BASE = (resize > 0 && resize < COLS) ? resize:((COLS-6-MIN_ADDR_LENGTH)/4); MAXY = (LINES) - 3; hex_win_width = BASE * 3; ascii_win_width = BASE; hex_outline_width = (BASE * 3) + 3 + MIN_ADDR_LENGTH; ascii_outline_width = BASE + 2; init_menu(windows); /* init windows */ head = freeList(head); /* free & init head */ /* print origin loc */ mvwprintw(windows->hex_outline, 0, 1, "%0*d", MIN_ADDR_LENGTH, 0); if (fpIN != NULL) /* if no infile... */ { len = maxLoc(fpIN); /* get last file loc */ val = maxLines(len); /* max file lines */ for (x = 0; x <= MAXY && x<=val; x++) /* output lines */ outline(fpIN, x); } wmove(windows->hex, 0, 0); /* cursor to origin */ refreshall(windows); /* refresh all wins */ doupdate(); /* update screen */ mvwaddch(windows->scrollbar, 1, 0, ACS_CKBOARD);/* clear scroller */ /* get user input */ retval = wacceptch(windows, len); } free(fpINfilename); free(fpOUTfilename); freeList(head); screen_exit(0); /* end visualizations */ return retval; /* return */ }
int main(int argc, char **argv) { char *term; int errret; bool cmdline = TRUE; int c; char buf[BUFSIZ]; int result = 0; check_aliases(prg_name = _nc_rootname(argv[0])); term = getenv("TERM"); while ((c = getopt(argc, argv, "ST:V")) != -1) { switch (c) { case 'S': cmdline = FALSE; break; case 'T': use_env(FALSE); term = optarg; break; case 'V': puts(curses_version()); ExitProgram(EXIT_SUCCESS); default: usage(); /* NOTREACHED */ } } /* * Modify the argument list to omit the options we processed. */ if (is_reset || is_init) { if (optind-- < argc) { argc -= optind; argv += optind; } argv[0] = prg_name; } else { argc -= optind; argv += optind; } if (term == 0 || *term == '\0') quit(2, "No value for $TERM and no -T specified"); if (setupterm(term, STDOUT_FILENO, &errret) != OK && errret <= 0) quit(3, "unknown terminal \"%s\"", term); if (cmdline) { if ((argc <= 0) && !is_reset && !is_init) usage(); ExitProgram(tput(argc, argv)); } while (fgets(buf, sizeof(buf), stdin) != 0) { char *argvec[16]; /* command, 9 parms, null, & slop */ int argnum = 0; char *cp; /* crack the argument list into a dope vector */ for (cp = buf; *cp; cp++) { if (isspace(UChar(*cp))) { *cp = '\0'; } else if (cp == buf || cp[-1] == 0) { argvec[argnum++] = cp; if (argnum >= (int) SIZEOF(argvec) - 1) break; } } argvec[argnum] = 0; if (argnum != 0 && tput(argnum, argvec) != 0) { if (result == 0) result = 4; /* will return value >4 */ ++result; } } ExitProgram(result); }
WRAP_API void wrap_use_env(int x) { use_env((bool)x); }