160786Sps/* 2240121Sdelphij * Copyright (C) 1984-2012 Mark Nudelman 360786Sps * 460786Sps * You may distribute under the terms of either the GNU General Public 560786Sps * License or the Less License, as specified in the README file. 660786Sps * 7240121Sdelphij * For more information, see the README file. 860786Sps */ 960786Sps 1060786Sps 1160786Sps/* 1260786Sps * Handling functions for command line options. 1360786Sps * 1460786Sps * Most options are handled by the generic code in option.c. 1560786Sps * But all string options, and a few non-string options, require 1660786Sps * special handling specific to the particular option. 1760786Sps * This special processing is done by the "handling functions" in this file. 1860786Sps * 1960786Sps * Each handling function is passed a "type" and, if it is a string 2060786Sps * option, the string which should be "assigned" to the option. 2160786Sps * The type may be one of: 2260786Sps * INIT The option is being initialized from the command line. 2360786Sps * TOGGLE The option is being changed from within the program. 2460786Sps * QUERY The setting of the option is merely being queried. 2560786Sps */ 2660786Sps 2760786Sps#include "less.h" 2860786Sps#include "option.h" 2960786Sps 3060786Spsextern int nbufs; 31128345Stjrextern int bufspace; 3260786Spsextern int pr_type; 3360786Spsextern int plusoption; 3460786Spsextern int swindow; 35195941Sdelphijextern int sc_width; 3660786Spsextern int sc_height; 3760786Spsextern int secure; 3860786Spsextern int dohelp; 3960786Spsextern int any_display; 4060786Spsextern char openquote; 4160786Spsextern char closequote; 4260786Spsextern char *prproto[]; 4360786Spsextern char *eqproto; 4460786Spsextern char *hproto; 4589019Spsextern char *wproto; 4660786Spsextern IFILE curr_ifile; 4760786Spsextern char version[]; 48170964Sdelphijextern int jump_sline; 49170964Sdelphijextern int jump_sline_fraction; 50195941Sdelphijextern int shift_count; 51195941Sdelphijextern int shift_count_fraction; 52170964Sdelphijextern int less_is_more; 5360786Sps#if LOGFILE 5460786Spsextern char *namelogfile; 5560786Spsextern int force_logfile; 5660786Spsextern int logfile; 5760786Sps#endif 5860786Sps#if TAGS 5960786Spspublic char *tagoption = NULL; 6060786Spsextern char *tags; 6160786Sps#endif 6260786Sps#if MSDOS_COMPILER 6360786Spsextern int nm_fg_color, nm_bg_color; 6460786Spsextern int bo_fg_color, bo_bg_color; 6560786Spsextern int ul_fg_color, ul_bg_color; 6660786Spsextern int so_fg_color, so_bg_color; 6760786Spsextern int bl_fg_color, bl_bg_color; 6860786Sps#endif 6960786Sps 7060786Sps 7160786Sps#if LOGFILE 7260786Sps/* 7360786Sps * Handler for -o option. 7460786Sps */ 7560786Sps public void 7660786Spsopt_o(type, s) 7760786Sps int type; 7860786Sps char *s; 7960786Sps{ 8060786Sps PARG parg; 8160786Sps 8260786Sps if (secure) 8360786Sps { 8460786Sps error("log file support is not available", NULL_PARG); 8560786Sps return; 8660786Sps } 8760786Sps switch (type) 8860786Sps { 8960786Sps case INIT: 9060786Sps namelogfile = s; 9160786Sps break; 9260786Sps case TOGGLE: 9360786Sps if (ch_getflags() & CH_CANSEEK) 9460786Sps { 9560786Sps error("Input is not a pipe", NULL_PARG); 9660786Sps return; 9760786Sps } 9860786Sps if (logfile >= 0) 9960786Sps { 10060786Sps error("Log file is already in use", NULL_PARG); 10160786Sps return; 10260786Sps } 10360786Sps s = skipsp(s); 10460786Sps namelogfile = lglob(s); 10560786Sps use_logfile(namelogfile); 10660786Sps sync_logfile(); 10760786Sps break; 10860786Sps case QUERY: 10960786Sps if (logfile < 0) 11060786Sps error("No log file", NULL_PARG); 11160786Sps else 11260786Sps { 113128345Stjr parg.p_string = namelogfile; 11460786Sps error("Log file \"%s\"", &parg); 11560786Sps } 11660786Sps break; 11760786Sps } 11860786Sps} 11960786Sps 12060786Sps/* 12160786Sps * Handler for -O option. 12260786Sps */ 12360786Sps public void 12460786Spsopt__O(type, s) 12560786Sps int type; 12660786Sps char *s; 12760786Sps{ 12860786Sps force_logfile = TRUE; 12960786Sps opt_o(type, s); 13060786Sps} 13160786Sps#endif 13260786Sps 13360786Sps/* 134170256Sdelphij * Handlers for -j option. 135170256Sdelphij */ 136170256Sdelphij public void 137170256Sdelphijopt_j(type, s) 138170256Sdelphij int type; 139170256Sdelphij char *s; 140170256Sdelphij{ 141170256Sdelphij PARG parg; 142170256Sdelphij char buf[16]; 143170256Sdelphij int len; 144170256Sdelphij int err; 145170256Sdelphij 146170256Sdelphij switch (type) 147170256Sdelphij { 148170256Sdelphij case INIT: 149170256Sdelphij case TOGGLE: 150170256Sdelphij if (*s == '.') 151170256Sdelphij { 152170256Sdelphij s++; 153170256Sdelphij jump_sline_fraction = getfraction(&s, "j", &err); 154170256Sdelphij if (err) 155170256Sdelphij error("Invalid line fraction", NULL_PARG); 156170256Sdelphij else 157170256Sdelphij calc_jump_sline(); 158170256Sdelphij } else 159170256Sdelphij { 160170256Sdelphij int sline = getnum(&s, "j", &err); 161170256Sdelphij if (err) 162170256Sdelphij error("Invalid line number", NULL_PARG); 163170256Sdelphij else 164170256Sdelphij { 165170256Sdelphij jump_sline = sline; 166170256Sdelphij jump_sline_fraction = -1; 167170256Sdelphij } 168170256Sdelphij } 169170256Sdelphij break; 170170256Sdelphij case QUERY: 171170256Sdelphij if (jump_sline_fraction < 0) 172170256Sdelphij { 173170256Sdelphij parg.p_int = jump_sline; 174170256Sdelphij error("Position target at screen line %d", &parg); 175170256Sdelphij } else 176170256Sdelphij { 177170256Sdelphij 178170256Sdelphij sprintf(buf, ".%06d", jump_sline_fraction); 179170256Sdelphij len = strlen(buf); 180170256Sdelphij while (len > 2 && buf[len-1] == '0') 181170256Sdelphij len--; 182170256Sdelphij buf[len] = '\0'; 183170256Sdelphij parg.p_string = buf; 184170256Sdelphij error("Position target at screen position %s", &parg); 185170256Sdelphij } 186170256Sdelphij break; 187170256Sdelphij } 188170256Sdelphij} 189170256Sdelphij 190170256Sdelphij public void 191170256Sdelphijcalc_jump_sline() 192170256Sdelphij{ 193170256Sdelphij if (jump_sline_fraction < 0) 194170256Sdelphij return; 195170256Sdelphij jump_sline = sc_height * jump_sline_fraction / NUM_FRAC_DENOM; 196170256Sdelphij} 197170256Sdelphij 198195941Sdelphij/* 199195941Sdelphij * Handlers for -# option. 200195941Sdelphij */ 201195941Sdelphij public void 202195941Sdelphijopt_shift(type, s) 203195941Sdelphij int type; 204195941Sdelphij char *s; 205195941Sdelphij{ 206195941Sdelphij PARG parg; 207195941Sdelphij char buf[16]; 208195941Sdelphij int len; 209195941Sdelphij int err; 210195941Sdelphij 211195941Sdelphij switch (type) 212195941Sdelphij { 213195941Sdelphij case INIT: 214195941Sdelphij case TOGGLE: 215195941Sdelphij if (*s == '.') 216195941Sdelphij { 217195941Sdelphij s++; 218195941Sdelphij shift_count_fraction = getfraction(&s, "#", &err); 219195941Sdelphij if (err) 220195941Sdelphij error("Invalid column fraction", NULL_PARG); 221195941Sdelphij else 222195941Sdelphij calc_shift_count(); 223195941Sdelphij } else 224195941Sdelphij { 225195941Sdelphij int hs = getnum(&s, "#", &err); 226195941Sdelphij if (err) 227195941Sdelphij error("Invalid column number", NULL_PARG); 228195941Sdelphij else 229195941Sdelphij { 230195941Sdelphij shift_count = hs; 231195941Sdelphij shift_count_fraction = -1; 232195941Sdelphij } 233195941Sdelphij } 234195941Sdelphij break; 235195941Sdelphij case QUERY: 236195941Sdelphij if (shift_count_fraction < 0) 237195941Sdelphij { 238195941Sdelphij parg.p_int = shift_count; 239195941Sdelphij error("Horizontal shift %d columns", &parg); 240195941Sdelphij } else 241195941Sdelphij { 242195941Sdelphij 243195941Sdelphij sprintf(buf, ".%06d", shift_count_fraction); 244195941Sdelphij len = strlen(buf); 245195941Sdelphij while (len > 2 && buf[len-1] == '0') 246195941Sdelphij len--; 247195941Sdelphij buf[len] = '\0'; 248195941Sdelphij parg.p_string = buf; 249195941Sdelphij error("Horizontal shift %s of screen width", &parg); 250195941Sdelphij } 251195941Sdelphij break; 252195941Sdelphij } 253195941Sdelphij} 254195941Sdelphij public void 255195941Sdelphijcalc_shift_count() 256195941Sdelphij{ 257195941Sdelphij if (shift_count_fraction < 0) 258195941Sdelphij return; 259195941Sdelphij shift_count = sc_width * shift_count_fraction / NUM_FRAC_DENOM; 260195941Sdelphij} 261195941Sdelphij 26260786Sps#if USERFILE 26360786Sps public void 26460786Spsopt_k(type, s) 26560786Sps int type; 26660786Sps char *s; 26760786Sps{ 26860786Sps PARG parg; 26960786Sps 27060786Sps switch (type) 27160786Sps { 27260786Sps case INIT: 27360786Sps if (lesskey(s, 0)) 27460786Sps { 275128345Stjr parg.p_string = s; 27660786Sps error("Cannot use lesskey file \"%s\"", &parg); 27760786Sps } 27860786Sps break; 27960786Sps } 28060786Sps} 28160786Sps#endif 28260786Sps 28360786Sps#if TAGS 28460786Sps/* 28560786Sps * Handler for -t option. 28660786Sps */ 28760786Sps public void 28860786Spsopt_t(type, s) 28960786Sps int type; 29060786Sps char *s; 29160786Sps{ 29260786Sps IFILE save_ifile; 29360786Sps POSITION pos; 29460786Sps 29560786Sps switch (type) 29660786Sps { 29760786Sps case INIT: 29860786Sps tagoption = s; 29960786Sps /* Do the rest in main() */ 30060786Sps break; 30160786Sps case TOGGLE: 30260786Sps if (secure) 30360786Sps { 30460786Sps error("tags support is not available", NULL_PARG); 30560786Sps break; 30660786Sps } 30760786Sps findtag(skipsp(s)); 30860786Sps save_ifile = save_curr_ifile(); 309161475Sdelphij /* 310161475Sdelphij * Try to open the file containing the tag 311161475Sdelphij * and search for the tag in that file. 312161475Sdelphij */ 313161475Sdelphij if (edit_tagfile() || (pos = tagsearch()) == NULL_POSITION) 31460786Sps { 315161475Sdelphij /* Failed: reopen the old file. */ 31660786Sps reedit_ifile(save_ifile); 31760786Sps break; 31860786Sps } 31960786Sps unsave_ifile(save_ifile); 32060786Sps jump_loc(pos, jump_sline); 32160786Sps break; 32260786Sps } 32360786Sps} 32460786Sps 32560786Sps/* 32660786Sps * Handler for -T option. 32760786Sps */ 32860786Sps public void 32960786Spsopt__T(type, s) 33060786Sps int type; 33160786Sps char *s; 33260786Sps{ 33360786Sps PARG parg; 33460786Sps 33560786Sps switch (type) 33660786Sps { 33760786Sps case INIT: 33860786Sps tags = s; 33960786Sps break; 34060786Sps case TOGGLE: 34160786Sps s = skipsp(s); 34260786Sps tags = lglob(s); 34360786Sps break; 34460786Sps case QUERY: 345128345Stjr parg.p_string = tags; 34660786Sps error("Tags file \"%s\"", &parg); 34760786Sps break; 34860786Sps } 34960786Sps} 35060786Sps#endif 35160786Sps 35260786Sps/* 35360786Sps * Handler for -p option. 35460786Sps */ 35560786Sps public void 35660786Spsopt_p(type, s) 35760786Sps int type; 35860786Sps register char *s; 35960786Sps{ 36060786Sps switch (type) 36160786Sps { 36260786Sps case INIT: 36360786Sps /* 36460786Sps * Unget a search command for the specified string. 36560786Sps * {{ This won't work if the "/" command is 36660786Sps * changed or invalidated by a .lesskey file. }} 36760786Sps */ 36860786Sps plusoption = TRUE; 36960786Sps ungetsc(s); 370161475Sdelphij /* 371161475Sdelphij * In "more" mode, the -p argument is a command, 372161475Sdelphij * not a search string, so we don't need a slash. 373161475Sdelphij */ 374170256Sdelphij if (!less_is_more) 375161475Sdelphij ungetsc("/"); 37660786Sps break; 37760786Sps } 37860786Sps} 37960786Sps 38060786Sps/* 38160786Sps * Handler for -P option. 38260786Sps */ 38360786Sps public void 38460786Spsopt__P(type, s) 38560786Sps int type; 38660786Sps register char *s; 38760786Sps{ 38860786Sps register char **proto; 38960786Sps PARG parg; 39060786Sps 39160786Sps switch (type) 39260786Sps { 39360786Sps case INIT: 39460786Sps case TOGGLE: 39560786Sps /* 39660786Sps * Figure out which prototype string should be changed. 39760786Sps */ 39860786Sps switch (*s) 39960786Sps { 40060786Sps case 's': proto = &prproto[PR_SHORT]; s++; break; 40160786Sps case 'm': proto = &prproto[PR_MEDIUM]; s++; break; 40260786Sps case 'M': proto = &prproto[PR_LONG]; s++; break; 40360786Sps case '=': proto = &eqproto; s++; break; 40460786Sps case 'h': proto = &hproto; s++; break; 40589019Sps case 'w': proto = &wproto; s++; break; 40660786Sps default: proto = &prproto[PR_SHORT]; break; 40760786Sps } 40860786Sps free(*proto); 40960786Sps *proto = save(s); 41060786Sps break; 41160786Sps case QUERY: 41260786Sps parg.p_string = prproto[pr_type]; 41360786Sps error("%s", &parg); 41460786Sps break; 41560786Sps } 41660786Sps} 41760786Sps 41860786Sps/* 41960786Sps * Handler for the -b option. 42060786Sps */ 42160786Sps /*ARGSUSED*/ 42260786Sps public void 42360786Spsopt_b(type, s) 42460786Sps int type; 42560786Sps char *s; 42660786Sps{ 42760786Sps switch (type) 42860786Sps { 429128345Stjr case INIT: 43060786Sps case TOGGLE: 43160786Sps /* 432128345Stjr * Set the new number of buffers. 43360786Sps */ 434128345Stjr ch_setbufspace(bufspace); 43560786Sps break; 436128345Stjr case QUERY: 43760786Sps break; 43860786Sps } 43960786Sps} 44060786Sps 44160786Sps/* 44260786Sps * Handler for the -i option. 44360786Sps */ 44460786Sps /*ARGSUSED*/ 44560786Sps public void 44660786Spsopt_i(type, s) 44760786Sps int type; 44860786Sps char *s; 44960786Sps{ 45060786Sps switch (type) 45160786Sps { 45260786Sps case TOGGLE: 45360786Sps chg_caseless(); 45460786Sps break; 45560786Sps case QUERY: 45660786Sps case INIT: 45760786Sps break; 45860786Sps } 45960786Sps} 46060786Sps 46160786Sps/* 46260786Sps * Handler for the -V option. 46360786Sps */ 46460786Sps /*ARGSUSED*/ 46560786Sps public void 46660786Spsopt__V(type, s) 46760786Sps int type; 46860786Sps char *s; 46960786Sps{ 47060786Sps switch (type) 47160786Sps { 47260786Sps case TOGGLE: 47360786Sps case QUERY: 47460786Sps dispversion(); 47560786Sps break; 47660786Sps case INIT: 47760786Sps /* 47860786Sps * Force output to stdout per GNU standard for --version output. 47960786Sps */ 48060786Sps any_display = 1; 48160786Sps putstr("less "); 48260786Sps putstr(version); 483240121Sdelphij putstr(" ("); 484240121Sdelphij#if HAVE_GNU_REGEX 485240121Sdelphij putstr("GNU "); 486240121Sdelphij#endif 487240121Sdelphij#if HAVE_POSIX_REGCOMP 488240121Sdelphij putstr("POSIX "); 489240121Sdelphij#endif 490240121Sdelphij#if HAVE_PCRE 491240121Sdelphij putstr("PCRE "); 492240121Sdelphij#endif 493240121Sdelphij#if HAVE_RE_COMP 494240121Sdelphij putstr("BSD "); 495240121Sdelphij#endif 496240121Sdelphij#if HAVE_REGCMP 497240121Sdelphij putstr("V8 "); 498240121Sdelphij#endif 499240121Sdelphij#if HAVE_V8_REGCOMP 500240121Sdelphij putstr("Spencer V8 "); 501240121Sdelphij#endif 502240121Sdelphij#if !HAVE_GNU_REGEX && !HAVE_POSIX_REGCOMP && !HAVE_PCRE && !HAVE_RE_COMP && !HAVE_REGCMP && !HAVE_V8_REGCOMP 503240121Sdelphij putstr("no "); 504240121Sdelphij#endif 505240121Sdelphij putstr("regular expressions)\n"); 506240121Sdelphij putstr("Copyright (C) 1984-2012 Mark Nudelman\n\n"); 50760786Sps putstr("less comes with NO WARRANTY, to the extent permitted by law.\n"); 50860786Sps putstr("For information about the terms of redistribution,\n"); 50960786Sps putstr("see the file named README in the less distribution.\n"); 51089019Sps putstr("Homepage: http://www.greenwoodsoftware.com/less\n"); 51160786Sps quit(QUIT_OK); 51260786Sps break; 51360786Sps } 51460786Sps} 51560786Sps 51660786Sps#if MSDOS_COMPILER 51760786Sps/* 51860786Sps * Parse an MSDOS color descriptor. 51960786Sps */ 52060786Sps static void 52160786Spscolordesc(s, fg_color, bg_color) 52260786Sps char *s; 52360786Sps int *fg_color; 52460786Sps int *bg_color; 52560786Sps{ 52660786Sps int fg, bg; 52760786Sps int err; 52860786Sps 529128345Stjr fg = getnum(&s, "D", &err); 53060786Sps if (err) 53160786Sps { 53260786Sps error("Missing fg color in -D", NULL_PARG); 53360786Sps return; 53460786Sps } 53560786Sps if (*s != '.') 536191930Sdelphij bg = nm_bg_color; 53760786Sps else 53860786Sps { 53960786Sps s++; 540128345Stjr bg = getnum(&s, "D", &err); 54160786Sps if (err) 54260786Sps { 543191930Sdelphij error("Missing bg color in -D", NULL_PARG); 54460786Sps return; 54560786Sps } 54660786Sps } 54760786Sps if (*s != '\0') 54860786Sps error("Extra characters at end of -D option", NULL_PARG); 54960786Sps *fg_color = fg; 55060786Sps *bg_color = bg; 55160786Sps} 55260786Sps 55360786Sps/* 55460786Sps * Handler for the -D option. 55560786Sps */ 55660786Sps /*ARGSUSED*/ 55760786Sps public void 55860786Spsopt_D(type, s) 55960786Sps int type; 56060786Sps char *s; 56160786Sps{ 56260786Sps switch (type) 56360786Sps { 56460786Sps case INIT: 56560786Sps case TOGGLE: 56660786Sps switch (*s++) 56760786Sps { 56860786Sps case 'n': 56960786Sps colordesc(s, &nm_fg_color, &nm_bg_color); 57060786Sps break; 57160786Sps case 'd': 57260786Sps colordesc(s, &bo_fg_color, &bo_bg_color); 57360786Sps break; 57460786Sps case 'u': 57560786Sps colordesc(s, &ul_fg_color, &ul_bg_color); 57660786Sps break; 57760786Sps case 'k': 57860786Sps colordesc(s, &bl_fg_color, &bl_bg_color); 57960786Sps break; 58060786Sps case 's': 58160786Sps colordesc(s, &so_fg_color, &so_bg_color); 58260786Sps break; 58360786Sps default: 58460786Sps error("-D must be followed by n, d, u, k or s", NULL_PARG); 58560786Sps break; 58660786Sps } 58760786Sps if (type == TOGGLE) 58860786Sps { 589161475Sdelphij at_enter(AT_STANDOUT); 590161475Sdelphij at_exit(); 59160786Sps } 59260786Sps break; 59360786Sps case QUERY: 59460786Sps break; 59560786Sps } 59660786Sps} 59760786Sps#endif 59860786Sps 59960786Sps/* 60089019Sps * Handler for the -x option. 60189019Sps */ 60289019Sps public void 60389019Spsopt_x(type, s) 60489019Sps int type; 60589019Sps register char *s; 60689019Sps{ 60789019Sps extern int tabstops[]; 60889019Sps extern int ntabstops; 60989019Sps extern int tabdefault; 61089019Sps char msg[60+(4*TABSTOP_MAX)]; 61189019Sps int i; 61289019Sps PARG p; 61389019Sps 61489019Sps switch (type) 61589019Sps { 61689019Sps case INIT: 61789019Sps case TOGGLE: 61889019Sps /* Start at 1 because tabstops[0] is always zero. */ 61989019Sps for (i = 1; i < TABSTOP_MAX; ) 62089019Sps { 62189019Sps int n = 0; 622128345Stjr s = skipsp(s); 62389019Sps while (*s >= '0' && *s <= '9') 62489019Sps n = (10 * n) + (*s++ - '0'); 62589019Sps if (n > tabstops[i-1]) 62689019Sps tabstops[i++] = n; 627128345Stjr s = skipsp(s); 62889019Sps if (*s++ != ',') 62989019Sps break; 63089019Sps } 63189019Sps if (i < 2) 63289019Sps return; 63389019Sps ntabstops = i; 63489019Sps tabdefault = tabstops[ntabstops-1] - tabstops[ntabstops-2]; 63589019Sps break; 63689019Sps case QUERY: 63789019Sps strcpy(msg, "Tab stops "); 63889019Sps if (ntabstops > 2) 63989019Sps { 64089019Sps for (i = 1; i < ntabstops; i++) 64189019Sps { 64289019Sps if (i > 1) 64389019Sps strcat(msg, ","); 64489019Sps sprintf(msg+strlen(msg), "%d", tabstops[i]); 64589019Sps } 64689019Sps sprintf(msg+strlen(msg), " and then "); 64789019Sps } 64889019Sps sprintf(msg+strlen(msg), "every %d spaces", 64989019Sps tabdefault); 65089019Sps p.p_string = msg; 65189019Sps error("%s", &p); 65289019Sps break; 65389019Sps } 65489019Sps} 65589019Sps 65689019Sps 65789019Sps/* 65860786Sps * Handler for the -" option. 65960786Sps */ 66060786Sps public void 66160786Spsopt_quote(type, s) 66260786Sps int type; 66360786Sps register char *s; 66460786Sps{ 66560786Sps char buf[3]; 66660786Sps PARG parg; 66760786Sps 66860786Sps switch (type) 66960786Sps { 67060786Sps case INIT: 67160786Sps case TOGGLE: 672128345Stjr if (s[0] == '\0') 673128345Stjr { 674128345Stjr openquote = closequote = '\0'; 675128345Stjr break; 676128345Stjr } 67760786Sps if (s[1] != '\0' && s[2] != '\0') 67860786Sps { 67960786Sps error("-\" must be followed by 1 or 2 chars", NULL_PARG); 68060786Sps return; 68160786Sps } 68260786Sps openquote = s[0]; 68360786Sps if (s[1] == '\0') 68460786Sps closequote = openquote; 68560786Sps else 68660786Sps closequote = s[1]; 68760786Sps break; 68860786Sps case QUERY: 68960786Sps buf[0] = openquote; 69060786Sps buf[1] = closequote; 69160786Sps buf[2] = '\0'; 69260786Sps parg.p_string = buf; 69360786Sps error("quotes %s", &parg); 69460786Sps break; 69560786Sps } 69660786Sps} 69760786Sps 69860786Sps/* 69960786Sps * "-?" means display a help message. 70060786Sps * If from the command line, exit immediately. 70160786Sps */ 70260786Sps /*ARGSUSED*/ 70360786Sps public void 70460786Spsopt_query(type, s) 70560786Sps int type; 70660786Sps char *s; 70760786Sps{ 70860786Sps switch (type) 70960786Sps { 71060786Sps case QUERY: 71160786Sps case TOGGLE: 71260786Sps error("Use \"h\" for help", NULL_PARG); 71360786Sps break; 71460786Sps case INIT: 71560786Sps dohelp = 1; 71660786Sps } 71760786Sps} 71860786Sps 71960786Sps/* 72060786Sps * Get the "screen window" size. 72160786Sps */ 72260786Sps public int 72360786Spsget_swindow() 72460786Sps{ 72560786Sps if (swindow > 0) 72660786Sps return (swindow); 72760786Sps return (sc_height + swindow); 72860786Sps} 72960786Sps 730