int main(void) { int nrows, ncols; setupterm(NULL, fileno(stdout), (int *)0); nrows = tigetnum("lines"); ncols = tigetnum("cols"); printf("This terminal has %d columns and %d rows\n", ncols, nrows); exit(0); }
static int get_number_of_columns (void) { int number_of_columns; number_of_columns = tigetnum ((char *) "cols"); return number_of_columns; }
static int _tigetint(char const *cap_name, int default_value) { int j = tigetnum(cap_name); if (j >= 0) return j; else if (j == -2) cu_warnf("tigetnum did not accept the capability \"%s\"", cap_name); return default_value; }
/* * TermInfo#tigetnum(capname) => int * * TermInfo#tigetnum returns a numeric capability specified by capname. */ static VALUE rt_tigetnum(VALUE self, VALUE v_capname) { int ret; setup(self); ret = tigetnum(StringValueCStr(v_capname)); if (ret == -2) { rb_raise(eTermInfoError, "not a numeric capability"); } if (ret == -1) { rb_raise(eTermInfoError, "canceled or absent numeric capability"); } return INT2NUM(ret); }
/*** Fetch terminfo numeric capability. @function tigetnum @string capname @treturn int content of terminal numeric capability @see tigetnum(3x) @see terminfo(5) */ static int Ptigetnum (lua_State *L) { int res; strlcpy (ti_capname, luaL_checkstring (L, 1), sizeof (ti_capname)); res = tigetnum (ti_capname); if (-2 == res) return luaL_error (L, "`%s' is not a numeric capability", ti_capname); else if (-1 == res) lua_pushnil (L); else lua_pushinteger(L, res); return 1; }
static void show_tabs(void) { int i, co = tigetnum("cols"); if (co > 0) { printf("\r "); for (i = 10; i < co - 2; i += 10) printf("%-10d", i); putchar('\n'); for (i = 1; i <= co; i++) putchar(i % 10 + '0'); putchar('\n'); for (i = 1; i < co; i++) printf("\tT\b"); putchar('\n'); } }
static void sial_getwinsize(void) { struct winsize w; if (ioctl (fileno(ofile), TIOCGWINSZ, &w) == 0) { cols=w.ws_col; } else /* use ENV */ { char *ewidth; if ((ewidth = getenv ("COLUMNS"))) cols = atoi (ewidth); /* use what's in terminfo */ if (cols <= 0) cols = tigetnum ("co"); } if(cols <= 10) cols=10; if(cols > 80) cols=80; }
static HashNode getterminfo(UNUSED(HashTable ht), const char *name) { int len, num; char *tistr, *nameu; Param pm = NULL; /* This depends on the termcap stuff in init.c */ if (termflags & TERM_BAD) return NULL; if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term())) return NULL; nameu = dupstring(name); unmetafy(nameu, &len); pm = (Param) hcalloc(sizeof(struct param)); pm->node.nam = nameu; pm->node.flags = PM_READONLY; if (((num = tigetnum(nameu)) != -1) && (num != -2)) { pm->u.val = num; pm->node.flags |= PM_INTEGER; pm->gsu.i = &nullsetinteger_gsu; } else if ((num = tigetflag(nameu)) != -1) { pm->u.str = num ? dupstring("yes") : dupstring("no"); pm->node.flags |= PM_SCALAR; pm->gsu.s = &nullsetscalar_gsu; } else if ((tistr = (char *)tigetstr(nameu)) != NULL && tistr != (char *)-1) { pm->u.str = dupstring(tistr); pm->node.flags |= PM_SCALAR; pm->gsu.s = &nullsetscalar_gsu; } else { /* zwarn("no such capability: %s", name); */ pm->u.str = dupstring(""); pm->node.flags |= PM_UNSET; pm->gsu.s = &nullsetscalar_gsu; } return &pm->node; }
static int outputcap(char *cap, int argc, char **argv) { int parmset = 0; char *thisstr; int i; if ((i = tigetflag(cap)) >= 0) return (1 - i); if ((i = tigetnum(cap)) >= -1) { (void) printf("%d\n", i); return (0); } if ((thisstr = tigetstr(cap)) != (char *)-1) { if (!thisstr) { return (1); } for (parmset = 0; optind < argc; optind++, parmset++) if (allnumeric(argv[optind])) parm[parmset] = atoi(argv[optind]); else parm[parmset] = (int)argv[optind]; if (parmset) putp(tparm(thisstr, parm[0], parm[1], parm[2], parm[3], parm[4], parm[5], parm[6], parm[7], parm[8])); else putp(thisstr); return (0); } (void) fprintf(stderr, gettext("%s: unknown terminfo capability '%s'\n"), progname, cap); exit(4); /* NOTREACHED */ }
static int lua_setupterm(lua_State *L) { char *term = 0; int i; char *name; if (!lua_isnoneornil(L, 1)) term = (char *)luaL_checkstring(L, 1); setupterm((char *)term, 1, (int *)0); /* * Now populate the table with strings, bools and nums */ lua_rawgeti(L, LUA_REGISTRYINDEX, table_ref); // Strings for (i=0; (name = strnames[i]); i++) { char *strval = tigetstr(name); if (strval) { lua_pushstring(L, strval); lua_setfield(L, -2, strfnames[i]); } } // Bools for (i=0; (name = boolnames[i]); i++) { if (tigetflag(name)==1) { lua_pushboolean(L, true); lua_setfield(L, -2, boolfnames[i]); } } // Nums for (i=0; (name = numnames[i]); i++) { int val = tigetnum(name); if (val >= 0) { lua_pushnumber(L, val); lua_setfield(L, -2, numfnames[i]); } } return 1; }
static void _init_color_logging(void) { if (use_escapes < 0) { if (!isatty(STDOUT_FILENO)) { use_escapes = 0; __loggerlogwrap(YOBOT_LOG_WARN, "no tty detected"); return; } int erret; if (setupterm(NULL, STDOUT_FILENO, &erret) != OK) { use_escapes = 0; __loggerlogwrap(YOBOT_LOG_ERROR, "setupterm returned ERR"); return; } erret = tigetnum("colors"); if (erret <= 0) { use_escapes = 0; __loggerlogwrap(YOBOT_LOG_WARN, "couldn't find color caps for terminal"); return; } else { if (erret >= 16) { title_fmt = "\033[" _INTENSE_FG _MAGENTA "m"; use_escapes = 1; } else if (erret >= 8) { title_fmt = "\033[" _BRIGHT_FG ";" _FG _MAGENTA "m"; use_escapes = 1; } else /*less than eight colors*/ { use_escapes = 0; __loggerlogwrap(YOBOT_LOG_WARN, "too few colors supported by terminal. not doing logging"); } } if(use_escapes) { reset_fmt = "\033[0m"; __loggerlogwrap(YOBOT_LOG_INFO, "using color escapes for logging"); } } }
void Getborder(int *x,int *y) { setupterm(NULL,fileno(stdout),NULL); *x=tigetnum("cols"); *y=tigetnum("lines"); }
/* setup terminal characteristics and allocate initial stuff */ void * rl_init(int cliIdx) { char *term; int ret; rl_t *rl=calloc(1, sizeof(*rl)); /* initialize soem of the values */ rl->maxh=DEF_HIST; /* number of buffered commands */ rl->maxl=DEF_LENGTH; /* maximum command length */ rl->prompt=">"; rl->notty=0; rl->width=80; rl->maxpos=0; rl->histoff=0; /* callbacks */ rl->cliIdx=cliIdx; /* sequence matching */ rl->seqidx=0; if(!(rl->hist=hist_init(rl->maxh, rl->maxl, cliIdx))) return 0; /* allocate a new buffer */ if(!(rl->buf=malloc(rl->maxl))) return 0; /* setup the terminal parameter for 'term '. Do this only once */ if(!termInit) { termInit++; term="xterm"; if(setupterm(term, 0, &ret)!=ERR) { bip="\007"; kwb="\033\177"; kwf="\033d"; fw="\033f"; bw="\033b"; /* if any of these basics go back to fgets() */ if(!(upN=tigetstr("cuu")) || !(downN=tigetstr("cud")) || !(leftN=tigetstr("cub")) || !(bol=tigetstr("cr")) || !(rightN=tigetstr("cuf")) || !(cod=tigetstr("ed"))) { rl->notty=1; return rl; } xenl=tigetflag("xenl"); home=tigetstr("clear"); kup=tigetstr("kcuu1"); kdown=tigetstr("kcud1"); kleft=tigetstr("kcub1"); kright=tigetstr("kcuf1"); kdel=tigetstr("kdch1"); kbksp=tigetstr("kbs"); } else { trxdbg(0,0,1,"Unable to initialize 'term'\n"); } } #ifdef OVER_TTY /* get window size */ { struct winsize w; if (ioctl (in, TIOCGWINSZ, &w) == 0) { width=w.ws_col; } else /* use ENV */ { char *ewidth; if ((ewidth = getenv ("COLUMNS"))) width = atoi (ewidth); /* use what's in terminfo */ if (width <= 0) width = tigetnum ("co"); } if (width <= 1) width = 80; } /* set ourselves in the proper mode */ { if(ioctl(in, TCGETA, &tio)) { notty=1; return 1;} stio=tio; tio.c_lflag &= ~(ICANON | ECHO); tio.c_iflag &= ~(ICRNL | INLCR); tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 0; } #endif rlShowPrompt(rl, 1); return rl; }
static void scanterminfo(UNUSED(HashTable ht), ScanFunc func, int flags) { Param pm = NULL; int num; char **capname, *tistr; #ifndef HAVE_BOOLNAMES static char *boolnames[] = { "bw", "am", "bce", "ccc", "xhp", "xhpa", "cpix", "crxm", "xt", "xenl", "eo", "gn", "hc", "chts", "km", "daisy", "hs", "hls", "in", "lpix", "da", "db", "mir", "msgr", "nxon", "xsb", "npc", "ndscr", "nrrmc", "os", "mc5i", "xvpa", "sam", "eslok", "hz", "ul", "xon", NULL}; #endif #ifndef HAVE_NUMNAMES static char *numnames[] = { "cols", "it", "lh", "lw", "lines", "lm", "xmc", "ma", "colors", "pairs", "wnum", "ncv", "nlab", "pb", "vt", "wsl", "bitwin", "bitype", "bufsz", "btns", "spinh", "spinv", "maddr", "mjump", "mcs", "mls", "npins", "orc", "orhi", "orl", "orvi", "cps", "widcs", NULL}; #endif #ifndef HAVE_STRNAMES static char *strnames[] = { "acsc", "cbt", "bel", "cr", "cpi", "lpi", "chr", "cvr", "csr", "rmp", "tbc", "mgc", "clear", "el1", "el", "ed", "hpa", "cmdch", "cwin", "cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1", "ll", "cuu1", "cvvis", "defc", "dch1", "dl1", "dial", "dsl", "dclk", "hd", "enacs", "smacs", "smam", "blink", "bold", "smcup", "smdc", "dim", "swidm", "sdrfq", "smir", "sitm", "slm", "smicm", "snlq", "snrmq", "prot", "rev", "invis", "sshm", "smso", "ssubm", "ssupm", "smul", "sum", "smxon", "ech", "rmacs", "rmam", "sgr0", "rmcup", "rmdc", "rwidm", "rmir", "ritm", "rlm", "rmicm", "rshm", "rmso", "rsubm", "rsupm", "rmul", "rum", "rmxon", "pause", "hook", "flash", "ff", "fsl", "wingo", "hup", "is1", "is2", "is3", "if", "iprog", "initc", "initp", "ich1", "il1", "ip", "ka1", "ka3", "kb2", "kbs", "kbeg", "kcbt", "kc1", "kc3", "kcan", "ktbc", "kclr", "kclo", "kcmd", "kcpy", "kcrt", "kctab", "kdch1", "kdl1", "kcud1", "krmir", "kend", "kent", "kel", "ked", "kext", "kf0", "kf1", "kf10", "kf11", "kf12", "kf13", "kf14", "kf15", "kf16", "kf17", "kf18", "kf19", "kf2", "kf20", "kf21", "kf22", "kf23", "kf24", "kf25", "kf26", "kf27", "kf28", "kf29", "kf3", "kf30", "kf31", "kf32", "kf33", "kf34", "kf35", "kf36", "kf37", "kf38", "kf39", "kf4", "kf40", "kf41", "kf42", "kf43", "kf44", "kf45", "kf46", "kf47", "kf48", "kf49", "kf5", "kf50", "kf51", "kf52", "kf53", "kf54", "kf55", "kf56", "kf57", "kf58", "kf59", "kf6", "kf60", "kf61", "kf62", "kf63", "kf7", "kf8", "kf9", "kfnd", "khlp", "khome", "kich1", "kil1", "kcub1", "kll", "kmrk", "kmsg", "kmov", "knxt", "knp", "kopn", "kopt", "kpp", "kprv", "kprt", "krdo", "kref", "krfr", "krpl", "krst", "kres", "kcuf1", "ksav", "kBEG", "kCAN", "kCMD", "kCPY", "kCRT", "kDC", "kDL", "kslt", "kEND", "kEOL", "kEXT", "kind", "kFND", "kHLP", "kHOM", "kIC", "kLFT", "kMSG", "kMOV", "kNXT", "kOPT", "kPRV", "kPRT", "kri", "kRDO", "kRPL", "kRIT", "kRES", "kSAV", "kSPD", "khts", "kUND", "kspd", "kund", "kcuu1", "rmkx", "smkx", "lf0", "lf1", "lf10", "lf2", "lf3", "lf4", "lf5", "lf6", "lf7", "lf8", "lf9", "fln", "rmln", "smln", "rmm", "smm", "mhpa", "mcud1", "mcub1", "mcuf1", "mvpa", "mcuu1", "nel", "porder", "oc", "op", "pad", "dch", "dl", "cud", "mcud", "ich", "indn", "il", "cub", "mcub", "cuf", "mcuf", "rin", "cuu", "mcuu", "pfkey", "pfloc", "pfx", "pln", "mc0", "mc5p", "mc4", "mc5", "pulse", "qdial", "rmclk", "rep", "rfi", "rs1", "rs2", "rs3", "rf", "rc", "vpa", "sc", "ind", "ri", "scs", "sgr", "setb", "smgb", "smgbp", "sclk", "scp", "setf", "smgl", "smglp", "smgr", "smgrp", "hts", "smgt", "smgtp", "wind", "sbim", "scsd", "rbim", "rcsd", "subcs", "supcs", "ht", "docr", "tsl", "tone", "uc", "hu", "u0", "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "wait", "xoffc", "xonc", "zerom", "scesa", "bicr", "binel", "birep", "csnm", "csin", "colornm", "defbi", "devt", "dispc", "endbi", "smpch", "smsc", "rmpch", "rmsc", "getm", "kmous", "minfo", "pctrm", "pfxl", "reqmp", "scesc", "s0ds", "s1ds", "s2ds", "s3ds", "setab", "setaf", "setcolor", "smglr", "slines", "smgtb", "ehhlm", "elhlm", "elohlm", "erhlm", "ethlm", "evhlm", "sgr1", "slength", NULL}; #endif pm = (Param) hcalloc(sizeof(struct param)); pm->node.flags = PM_READONLY | PM_SCALAR; pm->gsu.s = &nullsetscalar_gsu; for (capname = (char **)boolnames; *capname; capname++) { if ((num = tigetflag(*capname)) != -1) { pm->u.str = num ? dupstring("yes") : dupstring("no"); pm->node.nam = dupstring(*capname); func(&pm->node, flags); } } pm->node.flags = PM_READONLY | PM_INTEGER; pm->gsu.i = &nullsetinteger_gsu; for (capname = (char **)numnames; *capname; capname++) { if (((num = tigetnum(*capname)) != -1) && (num != -2)) { pm->u.val = num; pm->node.nam = dupstring(*capname); func(&pm->node, flags); } } pm->node.flags = PM_READONLY | PM_SCALAR; pm->gsu.s = &nullsetscalar_gsu; for (capname = (char **)strnames; *capname; capname++) { if ((tistr = (char *)tigetstr(*capname)) != NULL && tistr != (char *)-1) { pm->u.str = dupstring(tistr); pm->node.nam = dupstring(*capname); func(&pm->node, flags); } } }
static int bin_echoti(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) { char *s, *t, **u; int arg, num, strarg = 0; long pars[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; char *strcap[] = { "pfkey", "pfloc", "pfx", "pln", "pfxl", NULL }; s = *argv++; /* This depends on the termcap stuff in init.c */ if (termflags & TERM_BAD) return 1; if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term())) return 1; /* if the specified capability has a numeric value, display it */ if (((num = tigetnum(s)) != -1) && (num != -2)) { printf("%d\n", num); return 0; } switch (tigetflag(s)) { case -1: break; case 0: puts("no"); return 0; default: puts("yes"); return 0; } /* get a string-type capability */ t = (char *)tigetstr(s); if (!t || t == (char *)-1 || !*t) { /* capability doesn't exist, or (if boolean) is off */ zwarnnam(name, "no such terminfo capability: %s", s); return 1; } /* check that the number of arguments provided is not too high */ if (arrlen_gt(argv, 9)) { zwarnnam(name, "too many arguments"); return 1; } /* check if we have a capability taking non-integers for parameters */ for (u = strcap; *u && !strarg; u++) strarg = !strcmp(s, *u); /* get the arguments */ for (arg=0; argv[arg]; arg++) { if (strarg && arg > 0) pars[arg] = (long) argv[arg]; else pars[arg] = atoi(argv[arg]); } /* output string, through the proper termcap functions */ if (!arg) putp(t); else { putp(tparm(t, pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], pars[6], pars[7], pars[8])); } return 0; }
Terminal::Terminal() : m_valid(false) , m_256colors(false) , m_truecolor(false) { // Override using environment variable char* overrideMode = getenv("ROSMON_COLOR_MODE"); const char* termOverride = 0; if(overrideMode) { if(strcasecmp(overrideMode, "truecolor") == 0) { termOverride = "xterm-256color"; m_256colors = true; m_truecolor = true; } else if(strcasecmp(overrideMode, "256colors") == 0) { termOverride = "xterm-256color"; m_256colors = true; m_truecolor = false; } else if(strcasecmp(overrideMode, "ansi") == 0) { m_256colors = false; m_truecolor = false; } else { fprintf(stderr, "Warning: Unknown ROSMON_COLOR_MODE value: '%s'\n", overrideMode); } } else { // Detect truecolor-capable terminals if(getenv("KONSOLE_DBUS_SESSION")) { // Sadly, there is no way to determine the Konsole version. Since // any reasonably recent version supports true colors, just assume // true color support m_truecolor = true; m_256colors = true; } char* vte_version = getenv("VTE_VERSION"); if(vte_version && atoi(vte_version) >= 3600) { m_256colors = true; m_truecolor = true; } } int ret; if(setupterm(termOverride, STDOUT_FILENO, &ret) != OK) { printf("Could not setup the terminal. Disabling all colors...\n"); return; } m_valid = true; if(!m_256colors && !overrideMode) { // Detect 256 color terminals int num_colors = tigetnum("colors"); m_256colors = num_colors >= 256; } { const char* bgColor = tigetstr("setab"); if(bgColor && bgColor != (char*)-1) m_bgColorStr = bgColor; else printf("Your terminal does not support ANSI background!\n"); } { const char* fgColor = tigetstr("setaf"); if(fgColor && fgColor != (char*)-1) m_fgColorStr = fgColor; else printf("Your terminal does not support ANSI foreground!\n"); } m_opStr = tigetstr("op"); m_elStr = tigetstr("el"); m_upStr = tigetstr("cuu"); }
/* * Initialize the termcap-based console driver. * Returns zero if stdin/stdout are not tty's. */ static int InitTermcapDriver(void) { char *term; char *str; int posn; #if defined(IL_USE_TERMINFO) int errret = ERR; #endif if(termcapInitialized) { return consoleIsTty; } term = getenv("TERM"); if(!isatty(0) || !isatty(1) || !term || *term == '\0') { /* Either stdin or stdout is not a tty, so cannot use console mode */ consoleIsTty = 0; } #ifdef IL_USE_TERMCAP else if((termcapBuffer = (char *)ILMalloc(8192)) == 0 || (termcapBuffer2 = (char *)ILMalloc(8192)) == 0) { /* Insufficient memory to do termcap processing */ consoleIsTty = 0; } else if(tgetent(termcapBuffer, term) <= 0) { /* Could not load the termcap entry for the terminal */ consoleIsTty = 0; } #else if(setupterm(term, 1, &errret) != OK) { /* Could not load the terminfo entry for the terminal */ consoleIsTty = 0; } #endif else { /* Prime the screen size information from the termcap details */ #ifdef IL_USE_TERMCAP screenWidth = tgetnum("co"); if(screenWidth <= 0) { screenWidth = 80; } screenHeight = tgetnum("li"); if(screenHeight <= 0) { screenHeight = 24; } #else screenWidth = tigetnum("cols"); if(screenWidth <= 0) { screenWidth = 80; } screenHeight = tigetnum("lines"); if(screenHeight <= 0) { screenHeight = 24; } #endif /* Query the terminal itself as to what the size is */ #ifdef TIOCGWINSZ { struct winsize size; size.ws_row = 0; size.ws_col = 0; if(ioctl(0, TIOCGWINSZ, &size) >= 0) { if(size.ws_row > 0) { screenHeight = size.ws_row; } if(size.ws_col > 0) { screenWidth = size.ws_col; } } } #endif /* There's no way to get the current cursor position, so we just assume that the position is the start of the bottom-most line */ screenX = 0; screenY = screenHeight - 1; /* Determine if the terminal supports the xterm title sequence */ if(!strcmp(term, "xterm") || !strncmp(term, "xterm-", 6) || !strcmp(term, "color-xterm") || !strcmp(term, "color_xterm") || !strcmp(term, "rxvt")) { terminalHasTitle = 1; } /* Determine if the terminal has ANSI color sequences */ if(GetStringCap("AB", "setab")) { terminalHasColor = 1; } else if(terminalHasTitle) { /* All of the xterm variants support color */ terminalHasColor = 1; } else if(!strcmp(term, "linux")) { terminalHasColor = 1; } /* Populate the list of special keys */ for(posn = 0; posn < NumSpecialKeys; ++posn) { if(SpecialKeys[posn].name[0] == '\033') { /* This is an explicit key code for things that are usually keycodes but not the ones listed in termcap */ SpecialKeyStrings[posn] = ILDupString(SpecialKeys[posn].name); } else { str = GetStringCap(SpecialKeys[posn].name, SpecialKeys[posn].terminfoName); if(str && *str != '\0') { SpecialKeyStrings[posn] = ILDupString(str); } else { SpecialKeyStrings[posn] = 0; } } } /* Get the strings to enter or leave "alternative" mode */ enterAltMode = 0; leaveAltMode = 0; if(consoleMode == IL_CONSOLE_CBREAK_ALT || consoleMode == IL_CONSOLE_RAW_ALT) { str = GetStringCap("ti", "smcup"); if(str && *str != '\0') { enterAltMode = ILDupString(str); } str = GetStringCap("te", "rmcup"); if(str && *str != '\0') { leaveAltMode = ILDupString(str); } if(enterAltMode) { /* Write out the "enter alternative mode" string */ tputs(enterAltMode, 1, ConsolePutchar); fflush(stdout); } } /* Get the string to use to make the cursor normal on exit */ str = GetStringCap("ve", "cnorm"); if(str && *str != '\0') { makeCursorVisible = ILDupString(str); } /* Assume that the attributes are currently set to the default */ consoleAttrs = 0x07; /* Make the cursor initially visible and normal */ cursorVisible = 1; cursorSize = 25; if(makeCursorVisible) { tputs(makeCursorVisible, 1, ConsolePutchar); } /* The console is a known tty */ consoleIsTty = 1; } termcapInitialized = 1; return consoleIsTty; }
int main( int argc, char **argv ) { int eax; double fp7; int i; char *cp = &ebx; double numerator, denominator; double new_size; int coption, boption, wide_flag; init_gvars( ); default_out = stdout; gfp = stdout; wide_flag = 0; coption = 0; if ( i >= 0 ) { if ( i + -98 + -98 <= 22 ) { ; } usage( ); exit( 2 ); } else { if ( n_tokens <= 99 ) { __fprintf_chk( stderr, 1, "%s: Expression array size too small.\n", prog_name ); exit( 2 ); } if ( init_mem( ) == 0 ) { __fprintf_chk( stderr, 1, "%s: Not enough memory.\n", prog_name ); exit( 2 ); } if ( readline_enabled ) { if ( numerator && prog_name ) { __snprintf_chk( history_filename_storage, 4096, 1, 4096, "%s/.%s_history", cp, prog_name ); history_filename = history_filename_storage; } rl_initialize( ); using_history( ); stifle_history( 500 ); rl_inhibit_completion = 1; if ( html_flag == 0 ) { color_flag = tigetnum( "colors" ) > 7; } read_history( history_filename ); } get_screen_size( ); if ( html_flag ) __printf_chk( 1, "<pre>\n" ); if ( test_mode == 0 ) { if ( quiet_mode == 0 ) { if ( security_level > 1 ) __printf_chk( 1, "Secure " ); __printf_chk( 1, "Mathomatic version %s (www.mathomatic.org)\n", "15.1.1" ); __printf_chk( 1, "Copyright (C) 1987-2010 George Gesslein II.\n" ); __printf_chk( 1, "%d equation spaces available, %ld kilobytes per equation space.\n", 100, (/*HI*/int)( ( n_tokens << 5 ) * 0x10624dd3 ) >> 6 ); if ( test_mode == 0 ) goto B32; } B32:; if ( load_rc( ) == 0 ) __fprintf_chk( stderr, 1, "%s: Error loading set options from \"%s\".\n", prog_name, rc_file ); } if ( wide_flag ) { screen_columns = 0; screen_rows = 0; } if ( coption & 1 ) color_flag = color_flag == 0; if ( 0 ) { color_flag = 1; bold_colors = 1; } if ( test_mode ) color_flag = 0; if ( quiet_mode == 0 && color_flag ) { __printf_chk( 1, "%s%s color mode enabled", html_flag != 0 ? "ANSI" : "HTML", bold_colors == 0 ? " bold" : "" ); if ( 0 ) __printf_chk( 1, ".\n" ); else __printf_chk( 1, "; disable with the -c option or \"set no color\".\n" ); } i = _setjmp( &jmp_save[0].__jmpbuf[0] ); if ( _setjmp( &jmp_save[0].__jmpbuf[0] ) ) { clean_up( ); if ( i == 14 ) error( "Expression too large." ); __printf_chk( 1, "Operation aborted.\n" ); } else { if ( set_signals( ) == 0 ) __fprintf_chk( stderr, 1, "signal(2) setting failed.\n" ); if ( !f_to_fraction( 0.500000000000, &denominator, ebp_36 ) || denominator != 1.000000000000 || ebp_36 != 2.000000000000 || 0 || !f_to_fraction( 0.333333333333, &denominator, ebp_36 ) || denominator != 1.000000000000 || 0 || ebp_36 != 3.000000000000 || ebp_36 != 3.000000000000 ) { __fprintf_chk( stderr, 1, "%s: Cannot convert any floating point values to fractions.\n", prog_name ); __fprintf_chk( stderr, 1, "Roots will not work properly.\n" ); } i = optind; if ( argc <= optind || argv[ i ] == 0 ) { main_io_loop( ); exit_program( 0 ); return 0; } { /* phantom */ size_t __s1_len; /* phantom */ size_t __s2_len; unsigned char *__s1; /* phantom */ int __result; do { if ( '-' == argv[ i ][0] && argv[ i ][1] == 0 ) main_io_loop( ); else { if ( read_file( argv[ i ] ) == 0 ) { __fprintf_chk( stderr, 1, "Read of file \"%s\" failed.\n", argv[ i ] ); exit_program( 1 ); } } i++; } while ( i + 1 < argc && argv[ i + 1 + 1 ] ); } } } }
static void dumpit(NCURSES_CONST char *cap) { /* * One of the limitations of the termcap interface is that the library * cannot determine the size of the buffer passed via tgetstr(), nor the * amount of space remaining. This demo simply reuses the whole buffer * for each call; a normal termcap application would try to use the buffer * to hold all of the strings extracted from the terminal entry. */ const char *str; int num; if ((str = tigetstr(cap)) != 0 && (str != (char *) -1)) { /* * Note that the strings returned are mostly terminfo format, since * ncurses does not convert except for a handful of special cases. */ printf(FNAME(str), cap); while (*str != 0) { int ch = UChar(*str++); switch (ch) { case '\177': fputs("^?", stdout); break; case '\033': fputs("\\E", stdout); break; case '\b': fputs("\\b", stdout); break; case '\f': fputs("\\f", stdout); break; case '\n': fputs("\\n", stdout); break; case '\r': fputs("\\r", stdout); break; case ' ': fputs("\\s", stdout); break; case '\t': fputs("\\t", stdout); break; case '^': fputs("\\^", stdout); break; case ':': fputs("\\072", stdout); break; case '\\': fputs("\\\\", stdout); break; default: if (isgraph(ch)) fputc(ch, stdout); else if (ch < 32) printf("^%c", ch + '@'); else printf("\\%03o", ch); break; } } printf("\n"); } else if ((num = tigetnum(cap)) >= 0) { printf(FNAME(num), cap); printf(" %d\n", num); } else if ((num = tigetflag(cap)) >= 0) { printf(FNAME(flg), cap); printf("%s\n", num ? "true" : "false"); } fflush(stdout); }
static int tput(int argc, char *argv[]) { NCURSES_CONST char *name; char *s; int i, j, c; int status; FILE *f; #if !PURE_TERMINFO bool termcap = FALSE; #endif if ((name = argv[0]) == 0) name = ""; check_aliases(name); if (is_reset || is_init) { if (init_prog != 0) { system(init_prog); } FLUSH; if (is_reset && reset_1string != 0) { PUTS(reset_1string); } else if (init_1string != 0) { PUTS(init_1string); } FLUSH; if (is_reset && reset_2string != 0) { PUTS(reset_2string); } else if (init_2string != 0) { PUTS(init_2string); } FLUSH; #ifdef set_lr_margin if (set_lr_margin != 0) { PUTS(TPARM_2(set_lr_margin, 0, columns - 1)); } else #endif #ifdef set_left_margin_parm if (set_left_margin_parm != 0 && set_right_margin_parm != 0) { PUTS(TPARM_1(set_left_margin_parm, 0)); PUTS(TPARM_1(set_right_margin_parm, columns - 1)); } else #endif if (clear_margins != 0 && set_left_margin != 0 && set_right_margin != 0) { PUTS(clear_margins); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } PUTS(set_left_margin); if (parm_right_cursor) { PUTS(TPARM_1(parm_right_cursor, columns - 1)); } else { for (i = 0; i < columns - 1; i++) { PUTCHAR(' '); } } PUTS(set_right_margin); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } } FLUSH; if (init_tabs != 8) { if (clear_all_tabs != 0 && set_tab != 0) { for (i = 0; i < columns - 1; i += 8) { if (parm_right_cursor) { PUTS(TPARM_1(parm_right_cursor, 8)); } else { for (j = 0; j < 8; j++) PUTCHAR(' '); } PUTS(set_tab); } FLUSH; } } if (is_reset && reset_file != 0) { f = fopen(reset_file, "r"); if (f == 0) { quit(4 + errno, "Can't open reset_file: '%s'", reset_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } else if (init_file != 0) { f = fopen(init_file, "r"); if (f == 0) { quit(4 + errno, "Can't open init_file: '%s'", init_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } FLUSH; if (is_reset && reset_3string != 0) { PUTS(reset_3string); } else if (init_3string != 0) { PUTS(init_3string); } FLUSH; return 0; } if (strcmp(name, "longname") == 0) { PUTS(longname()); return 0; } #if !PURE_TERMINFO retry: #endif if ((status = tigetflag(name)) != -1) { return exit_code(BOOLEAN, status); } else if ((status = tigetnum(name)) != CANCELLED_NUMERIC) { (void) printf("%d\n", status); return exit_code(NUMBER, 0); } else if ((s = tigetstr(name)) == CANCELLED_STRING) { #if !PURE_TERMINFO if (!termcap) { const struct name_table_entry *np; termcap = TRUE; if ((np = _nc_find_entry(name, _nc_get_hash_table(termcap))) != 0) { switch (np->nte_type) { case BOOLEAN: if (bool_from_termcap[np->nte_index]) name = boolnames[np->nte_index]; break; case NUMBER: if (num_from_termcap[np->nte_index]) name = numnames[np->nte_index]; break; case STRING: if (str_from_termcap[np->nte_index]) name = strnames[np->nte_index]; break; } goto retry; } } #endif quit(4, "unknown terminfo capability '%s'", name); } else if (s != ABSENT_STRING) { if (argc > 1) { int k; int popcount; long numbers[1 + NUM_PARM]; char *strings[1 + NUM_PARM]; char *p_is_s[NUM_PARM]; /* Nasty hack time. The tparm function needs to see numeric * parameters as numbers, not as pointers to their string * representations */ for (k = 1; k < argc; k++) { char *tmp = 0; strings[k] = argv[k]; numbers[k] = strtol(argv[k], &tmp, 0); if (tmp == 0 || *tmp != 0) numbers[k] = 0; } for (k = argc; k <= NUM_PARM; k++) { numbers[k] = 0; strings[k] = 0; } switch (tparm_type(name)) { case Num_Str: s = TPARM_2(s, numbers[1], strings[2]); break; case Num_Str_Str: s = TPARM_3(s, numbers[1], strings[2], strings[3]); break; case Numbers: default: (void) _nc_tparm_analyze(s, p_is_s, &popcount); #define myParam(n) (p_is_s[n - 1] != 0 ? ((TPARM_ARG) strings[n]) : numbers[n]) s = TPARM_9(s, myParam(1), myParam(2), myParam(3), myParam(4), myParam(5), myParam(6), myParam(7), myParam(8), myParam(9)); break; } } /* use putp() in order to perform padding */ putp(s); return exit_code(STRING, 0); } return exit_code(STRING, 1); }
int getcaps(int fildes) { char *cap; #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ char cap_ebcdic[128]; /* more than enough for terminal name */ int ebc_len, gtm_cap_index = 0; #endif int status; cap = GETENV("TERM"); if (!cap) cap = "unknown"; #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ ebc_len = strlen(cap); if (SIZEOF(cap_ebcdic) < ebc_len) ebc_len = SIZEOF(cap_ebcdic) - 1; asc_to_ebc((unsigned char *)cap_ebcdic, (unsigned char *)cap, ebc_len); cap_ebcdic[ebc_len] = '\0'; cap = cap_ebcdic; #endif SETUPTERM(cap, fildes, &status); if (1 == status) { #ifdef KEEP_zOS_EBCDIC #pragma convlit(suspend) #endif #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ /* assumes source is EBCDIC and curses/terminfo entries expect EBCDIC */ #pragma convert(source) #endif AUTO_RIGHT_MARGIN = tigetflag("am"); CLR_EOS = tigetstr("ed"); CLR_EOL = tigetstr("el"); COLUMNS = tigetnum("cols"); CURSOR_ADDRESS = tigetstr("cup"); CURSOR_DOWN = tigetstr("cud1"); CURSOR_LEFT = tigetstr("cub1"); CURSOR_RIGHT = tigetstr("cuf1"); CURSOR_UP = tigetstr("cuu1"); EAT_NEWLINE_GLITCH = tigetflag("xenl"); KEY_BACKSPACE = tigetstr("kbs"); KEY_DC = tigetstr("kdch1"); KEY_DOWN = tigetstr("kcud1"); KEY_LEFT = tigetstr("kcub1"); KEY_RIGHT = tigetstr("kcuf1"); KEY_UP = tigetstr("kcuu1"); KEY_INSERT = tigetstr("kich1"); KEYPAD_LOCAL = tigetstr("rmkx"); KEYPAD_XMIT = tigetstr("smkx"); GTM_LINES = tigetnum("lines"); #if defined(__MVS__) && __CHARSET_LIB==1 /* -qascii */ #pragma convert(pop) #endif #ifdef KEEP_zOS_EBCDIC #pragma convlit(resume) #endif assert(-1 != AUTO_RIGHT_MARGIN); assert((char *)-1 != CLR_EOS); CAP2ASCII(CLR_EOS); assert((char *)-1 != CLR_EOL); CAP2ASCII(CLR_EOL); assert(-2 != COLUMNS); assert((char *)-1 != CURSOR_ADDRESS); CAP2ASCII(CURSOR_ADDRESS); assert((char *)-1 != CURSOR_DOWN); CAP2ASCII(CURSOR_DOWN); assert((char *)-1 != CURSOR_LEFT); CAP2ASCII(CURSOR_LEFT); assert((char *)-1 != CURSOR_RIGHT); CAP2ASCII(CURSOR_RIGHT); assert((char *)-1 != CURSOR_UP); CAP2ASCII(CURSOR_UP); assert((char *)-1 != KEY_BACKSPACE); CAP2ASCII(KEY_BACKSPACE); assert((char *)-1 != KEY_DC); CAP2ASCII(KEY_DC); assert((char *)-1 != KEY_DOWN); CAP2ASCII(KEY_DOWN); assert((char *)-1 != KEY_LEFT); CAP2ASCII(KEY_LEFT); assert((char *)-1 != KEY_RIGHT); CAP2ASCII(KEY_RIGHT); assert((char *)-1 != KEY_UP); CAP2ASCII(KEY_UP); assert((char *)-1 != KEY_INSERT); CAP2ASCII(KEY_INSERT); assert((char *)-1 != KEYPAD_LOCAL); CAP2ASCII(KEYPAD_LOCAL); assert((char *)-1 != KEYPAD_XMIT); CAP2ASCII(KEYPAD_XMIT); assert(-2 != GTM_LINES); } else { AUTO_RIGHT_MARGIN = gtm_auto_right_margin; CLR_EOS = gtm_clr_eos; CLR_EOL = gtm_clr_eol; COLUMNS = gtm_columns; CURSOR_ADDRESS = gtm_cursor_address; CURSOR_DOWN = gtm_cursor_down; CURSOR_LEFT = gtm_cursor_left; CURSOR_RIGHT = gtm_cursor_right; CURSOR_UP = gtm_cursor_up; EAT_NEWLINE_GLITCH = gtm_eat_newline_glitch; KEY_BACKSPACE = gtm_key_backspace; KEY_DC = gtm_key_dc; KEY_DOWN = gtm_key_down; KEY_LEFT = gtm_key_left; KEY_RIGHT = gtm_key_right; KEY_UP = gtm_key_up; KEY_INSERT = gtm_key_insert; KEYPAD_LOCAL = gtm_keypad_local; KEYPAD_XMIT = gtm_keypad_xmit; GTM_LINES = gtm_lines; } return status; }
static int tput(int argc, char *argv[]) { NCURSES_CONST char *name; char *s; int i, j, c; int status; FILE *f; check_aliases(name = argv[0]); if (is_reset || is_init) { if (init_prog != 0) { system(init_prog); } FLUSH; if (is_reset && reset_1string != 0) { PUTS(reset_1string); } else if (init_1string != 0) { PUTS(init_1string); } FLUSH; if (is_reset && reset_2string != 0) { PUTS(reset_2string); } else if (init_2string != 0) { PUTS(init_2string); } FLUSH; if (set_lr_margin != 0) { PUTS(tparm(set_lr_margin, 0, columns - 1)); } else if (set_left_margin_parm != 0 && set_right_margin_parm != 0) { PUTS(tparm(set_left_margin_parm, 0)); PUTS(tparm(set_right_margin_parm, columns - 1)); } else if (clear_margins != 0 && set_left_margin != 0 && set_right_margin != 0) { PUTS(clear_margins); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } PUTS(set_left_margin); if (parm_right_cursor) { PUTS(tparm(parm_right_cursor, columns - 1)); } else { for (i = 0; i < columns - 1; i++) { PUTCHAR(' '); } } PUTS(set_right_margin); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } } FLUSH; if (init_tabs != 8) { if (clear_all_tabs != 0 && set_tab != 0) { for (i = 0; i < columns - 1; i += 8) { if (parm_right_cursor) { PUTS(tparm(parm_right_cursor, 8)); } else { for (j = 0; j < 8; j++) PUTCHAR(' '); } PUTS(set_tab); } FLUSH; } } if (is_reset && reset_file != 0) { f = fopen(reset_file, "r"); if (f == 0) { quit(errno, "Can't open reset_file: '%s'", reset_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } else if (init_file != 0) { f = fopen(init_file, "r"); if (f == 0) { quit(errno, "Can't open init_file: '%s'", init_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } FLUSH; if (is_reset && reset_3string != 0) { PUTS(reset_3string); } else if (init_2string != 0) { PUTS(init_2string); } FLUSH; return 0; } if (strcmp(name, "longname") == 0) { PUTS(longname()); return 0; } #if !PURE_TERMINFO { const struct name_table_entry *np; if ((np = _nc_find_entry(name, _nc_get_hash_table(1))) != 0) switch (np->nte_type) { case BOOLEAN: if (bool_from_termcap[np->nte_index]) name = boolnames[np->nte_index]; break; case NUMBER: if (num_from_termcap[np->nte_index]) name = numnames[np->nte_index]; break; case STRING: if (str_from_termcap[np->nte_index]) name = strnames[np->nte_index]; break; } } #endif if ((status = tigetflag(name)) != -1) { return (status != 0); } else if ((status = tigetnum(name)) != CANCELLED_NUMERIC) { (void) printf("%d\n", status); return (0); } else if ((s = tigetstr(name)) == CANCELLED_STRING) { quit(4, "%s: unknown terminfo capability '%s'", prg_name, name); } else if (s != ABSENT_STRING) { if (argc > 1) { int k; int numbers[10]; char *strings[10]; /* Nasty hack time. The tparm function needs to see numeric * parameters as numbers, not as pointers to their string * representations */ for (k = 1; k < argc; k++) { char *tmp = 0; strings[k] = argv[k]; numbers[k] = strtol(argv[k], &tmp, 0); if (tmp == 0 || *tmp != 0) numbers[k] = 0; } for (k = argc; k <= 9; k++) { numbers[k] = 0; strings[k] = 0; } switch (tparm_type(name)) { case Num_Str: s = tparm(s, numbers[1], strings[2]); break; case Num_Str_Str: s = tparm(s, numbers[1], strings[2], strings[3]); break; default: s = tparm(s, numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6], numbers[7], numbers[8], numbers[9]); break; } } /* use putp() in order to perform padding */ putp(s); return (0); } return (0); }
int _t3_tigetnum(const char *name) { /* Copy the name into a new buffer, because tigetnum expects a char * not a const char *. */ COPY_BUFFER(name); return tigetnum(name_buffer); }
static int tinfoterminalinfo(int termcap_wins) { char *_ku, *_kd, *_kl, *_kr, *_kppu, *_kppd, *_kphome, *_kpend, *_kpdel, *_kf1, *_kf2, *_kf3, *_kf4, *_kf5, *_kf6, *_kf7, *_kf8, *_kf9, *_kf10, *_kf11, *_kf12; char *ttnm; if (Pmaster) { /* * setupterm() automatically retrieves the value * of the TERM variable. */ int err; ttnm = getenv("TERM"); if(!ttnm) return(-1); strncpy(term_name, ttnm, sizeof(term_name)); term_name[sizeof(term_name)-1] = '\0'; setupterm ((char *) 0, 1, &err); if (err != 1) return(err-2); } else { /* * setupterm() issues a message and exits, if the * terminfo data base is gone or the term type is * unknown, if arg2 is 0. */ setupterm ((char *) 0, 1, (int *) 0); } _clearscreen = tigetstr("clear"); _moveto = tigetstr("cup"); _up = tigetstr("cuu1"); _down = tigetstr("cud1"); _right = tigetstr("cuf1"); _left = tigetstr("cub1"); _setinverse = tigetstr("smso"); _clearinverse = tigetstr("rmso"); _setunderline = tigetstr("smul"); _clearunderline = tigetstr("rmul"); _setbold = tigetstr("bold"); _clearallattr = tigetstr("sgr0"); _cleartoeoln = tigetstr("el"); _cleartoeos = tigetstr("ed"); _deletechar = tigetstr("dch1"); _insertchar = tigetstr("ich1"); _startinsert = tigetstr("smir"); _endinsert = tigetstr("rmir"); _deleteline = tigetstr("dl1"); _insertline = tigetstr("il1"); _scrollregion = tigetstr("csr"); _scrolldown = tigetstr("ind"); _scrollup = tigetstr("ri"); _termcap_init = tigetstr("smcup"); _termcap_end = tigetstr("rmcup"); _startdelete = tigetstr("smdc"); _enddelete = tigetstr("rmdc"); _ku = tigetstr("kcuu1"); _kd = tigetstr("kcud1"); _kl = tigetstr("kcub1"); _kr = tigetstr("kcuf1"); _kppu = tigetstr("kpp"); _kppd = tigetstr("knp"); _kphome = tigetstr("khome"); _kpend = tigetstr("kend"); _kpdel = tigetstr("kdch1"); _kf1 = tigetstr("kf1"); _kf2 = tigetstr("kf2"); _kf3 = tigetstr("kf3"); _kf4 = tigetstr("kf4"); _kf5 = tigetstr("kf5"); _kf6 = tigetstr("kf6"); _kf7 = tigetstr("kf7"); _kf8 = tigetstr("kf8"); _kf9 = tigetstr("kf9"); _kf10 = tigetstr("kf10"); _kf11 = tigetstr("kf11"); _kf12 = tigetstr("kf12"); _colors = tigetnum("colors"); _pairs = tigetnum("pairs"); _setaf = tigetstr("setaf"); _setab = tigetstr("setab"); _setf = tigetstr("setf"); _setb = tigetstr("setb"); _scp = tigetstr("scp"); _op = tigetstr("op"); _oc = tigetstr("oc"); _bce = tigetflag("bce"); _tlines = tigetnum("lines"); if(_tlines == -1){ char *er; int rr; /* tigetnum failed, try $LINES */ er = getenv("LINES"); if(er && (rr = atoi(er)) > 0) _tlines = rr; } _tcolumns = tigetnum("cols"); if(_tcolumns == -1){ char *ec; int cc; /* tigetnum failed, try $COLUMNS */ ec = getenv("COLUMNS"); if(ec && (cc = atoi(ec)) > 0) _tcolumns = cc; } /* * Add default keypad sequences to the trie. * Since these come first, they will override any conflicting termcap * or terminfo escape sequences defined below. An escape sequence is * considered conflicting if one is a prefix of the other. * So, without TERMCAP_WINS, there will likely be some termcap/terminfo * escape sequences that don't work, because they conflict with default * sequences defined here. */ if(!termcap_wins) setup_dflt_esc_seq(); /* * add termcap/info escape sequences to the trie... */ if(_ku != NULL && _kd != NULL && _kl != NULL && _kr != NULL){ kpinsert(_ku, KEY_UP, termcap_wins); kpinsert(_kd, KEY_DOWN, termcap_wins); kpinsert(_kl, KEY_LEFT, termcap_wins); kpinsert(_kr, KEY_RIGHT, termcap_wins); } if(_kppu != NULL && _kppd != NULL){ kpinsert(_kppu, KEY_PGUP, termcap_wins); kpinsert(_kppd, KEY_PGDN, termcap_wins); } kpinsert(_kphome, KEY_HOME, termcap_wins); kpinsert(_kpend, KEY_END, termcap_wins); kpinsert(_kpdel, KEY_DEL, termcap_wins); kpinsert(_kf1, F1, termcap_wins); kpinsert(_kf2, F2, termcap_wins); kpinsert(_kf3, F3, termcap_wins); kpinsert(_kf4, F4, termcap_wins); kpinsert(_kf5, F5, termcap_wins); kpinsert(_kf6, F6, termcap_wins); kpinsert(_kf7, F7, termcap_wins); kpinsert(_kf8, F8, termcap_wins); kpinsert(_kf9, F9, termcap_wins); kpinsert(_kf10, F10, termcap_wins); kpinsert(_kf11, F11, termcap_wins); kpinsert(_kf12, F12, termcap_wins); /* * Add default keypad sequences to the trie. * Since these come after the termcap/terminfo escape sequences above, * the termcap/info sequences will override any conflicting default * escape sequences defined here. * So, with TERMCAP_WINS, some of the default sequences will be missing. * This means that you'd better get all of your termcap/terminfo entries * correct if you define TERMCAP_WINS. */ if(termcap_wins) setup_dflt_esc_seq(); if(Pmaster) return(0); else return(TRUE); }
static int my_tgetnum(char *s) { return tigetnum(s); }
void getboarder(int *y,int *x) { setupterm(NULL,1,NULL); *y=tigetnum("lines"); *x=tigetnum("cols"); }
int getcaps(int fildes) { char *cap; int status; cap = GETENV("TERM"); if (!cap) cap = "unknown"; SETUPTERM(cap, fildes, &status); if (1 == status) { #ifdef __MVS__ #pragma convlit(suspend) #endif AUTO_RIGHT_MARGIN = tigetflag("am"); CLR_EOS = tigetstr("ed"); CLR_EOL = tigetstr("el"); COLUMNS = tigetnum("cols"); CURSOR_ADDRESS = tigetstr("cup"); CURSOR_DOWN = tigetstr("cud1"); CURSOR_LEFT = tigetstr("cub1"); CURSOR_RIGHT = tigetstr("cuf1"); CURSOR_UP = tigetstr("cuu1"); EAT_NEWLINE_GLITCH = tigetflag("xenl"); KEY_BACKSPACE = tigetstr("kbs"); KEY_DC = tigetstr("kdch1"); KEY_DOWN = tigetstr("kcud1"); KEY_LEFT = tigetstr("kcub1"); KEY_RIGHT = tigetstr("kcuf1"); KEY_UP = tigetstr("kcuu1"); KEY_INSERT = tigetstr("kich1"); KEYPAD_LOCAL = tigetstr("rmkx"); KEYPAD_XMIT = tigetstr("smkx"); GTM_LINES = tigetnum("lines"); #ifdef __MVS__ #pragma convlit(resume) #endif assert(-1 != AUTO_RIGHT_MARGIN); if (0 == AUTO_RIGHT_MARGIN) AUTO_RIGHT_MARGIN = gtm_auto_right_margin; assert((char *)-1L != CLR_EOS); if (NULL == CLR_EOS) CLR_EOS = gtm_clr_eos; assert((char *)-1L != CLR_EOL); if (NULL == CLR_EOL) CLR_EOL = gtm_clr_eol; assert(-2 != COLUMNS); if (-1 == COLUMNS) COLUMNS = gtm_columns; assert((char *)-1L != CURSOR_ADDRESS); if (NULL == CURSOR_ADDRESS) CURSOR_ADDRESS = gtm_cursor_address; assert((char *)-1L != CURSOR_DOWN); if (NULL == CURSOR_DOWN) CURSOR_DOWN = gtm_cursor_down; assert((char *)-1L != CURSOR_LEFT); if (NULL == CURSOR_LEFT) CURSOR_LEFT = gtm_cursor_left; assert((char *)-1L != CURSOR_RIGHT); if (NULL == CURSOR_RIGHT) CURSOR_RIGHT = gtm_cursor_right; assert((char *)-1L != CURSOR_UP); if (NULL == CURSOR_UP) CURSOR_UP = gtm_cursor_up; assert((char *)-1L != KEY_BACKSPACE); if (NULL == KEY_BACKSPACE) KEY_BACKSPACE = gtm_key_backspace; assert((char *)-1L != KEY_DC); if (NULL == KEY_DC) KEY_DC = gtm_key_dc; assert((char *)-1L != KEY_DOWN); if (NULL == KEY_DOWN) KEY_DOWN = gtm_key_down; assert((char *)-1L != KEY_LEFT); if (NULL == KEY_LEFT) KEY_LEFT = gtm_key_left; assert((char *)-1L != KEY_RIGHT); if (NULL == KEY_RIGHT) KEY_RIGHT = gtm_key_right; assert((char *)-1L != KEY_UP); if (NULL == KEY_UP) KEY_UP = gtm_key_up; assert((char *)-1L != KEY_INSERT); if (NULL == KEY_INSERT) KEY_INSERT = gtm_key_insert; assert((char *)-1L != KEYPAD_LOCAL); if (NULL == KEYPAD_LOCAL) KEYPAD_LOCAL = gtm_keypad_local; assert((char *)-1L != KEYPAD_XMIT); if (NULL == KEYPAD_XMIT) KEYPAD_XMIT = gtm_keypad_xmit; assert(-2 != GTM_LINES); if (-1 == GTM_LINES) GTM_LINES = gtm_lines; } else { AUTO_RIGHT_MARGIN = gtm_auto_right_margin; CLR_EOS = gtm_clr_eos; CLR_EOL = gtm_clr_eol; COLUMNS = gtm_columns; CURSOR_ADDRESS = gtm_cursor_address; CURSOR_DOWN = gtm_cursor_down; CURSOR_LEFT = gtm_cursor_left; CURSOR_RIGHT = gtm_cursor_right; CURSOR_UP = gtm_cursor_up; EAT_NEWLINE_GLITCH = gtm_eat_newline_glitch; KEY_BACKSPACE = gtm_key_backspace; KEY_DC = gtm_key_dc; KEY_DOWN = gtm_key_down; KEY_LEFT = gtm_key_left; KEY_RIGHT = gtm_key_right; KEY_UP = gtm_key_up; KEY_INSERT = gtm_key_insert; KEYPAD_LOCAL = gtm_keypad_local; KEYPAD_XMIT = gtm_keypad_xmit; GTM_LINES = gtm_lines; } return status; }