1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 32*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 33*7c478bd9Sstevel@tonic-gate * All Rights Reserved 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 36*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 37*7c478bd9Sstevel@tonic-gate * contributors. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/ 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #include <stdio.h> 45*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 46*7c478bd9Sstevel@tonic-gate #include <string.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 48*7c478bd9Sstevel@tonic-gate #include "curses_inc.h" 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #ifdef _VR2_COMPAT_CODE 51*7c478bd9Sstevel@tonic-gate extern char _endwin; 52*7c478bd9Sstevel@tonic-gate #endif /* _VR2_COMPAT_CODE */ 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 1200 is put at the 0th location since 0 is probably a mistake. */ 55*7c478bd9Sstevel@tonic-gate static long baud_convert[] = { 56*7c478bd9Sstevel@tonic-gate 1200, 50, 75, 110, 135, 150, 200, 300, 600, 1200, 57*7c478bd9Sstevel@tonic-gate 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 58*7c478bd9Sstevel@tonic-gate 115200, 153600, 230400, 307200, 460800 59*7c478bd9Sstevel@tonic-gate }; 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate static char isfilter = 0; 62*7c478bd9Sstevel@tonic-gate static int _chk_trm(void); 63*7c478bd9Sstevel@tonic-gate static void _forget(void); 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* 66*7c478bd9Sstevel@tonic-gate * newscreen sets up a terminal and returns a pointer to the terminal 67*7c478bd9Sstevel@tonic-gate * structure or NULL in case of an error. The parameters are: 68*7c478bd9Sstevel@tonic-gate * type: terminal type 69*7c478bd9Sstevel@tonic-gate * lsize, csize, tabsize: physical sizes 70*7c478bd9Sstevel@tonic-gate * infptr, outfptr: input and output stdio stream file pointers 71*7c478bd9Sstevel@tonic-gate */ 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate SCREEN * 74*7c478bd9Sstevel@tonic-gate newscreen(char *type, int lsize, int csize, int tabsize, 75*7c478bd9Sstevel@tonic-gate FILE *outfptr, FILE *infptr) 76*7c478bd9Sstevel@tonic-gate { 77*7c478bd9Sstevel@tonic-gate int old_lines = LINES, old_cols = COLS, retcode; 78*7c478bd9Sstevel@tonic-gate #ifndef _IOFBF 79*7c478bd9Sstevel@tonic-gate char *sobuf; 80*7c478bd9Sstevel@tonic-gate #endif /* _IOBUF */ 81*7c478bd9Sstevel@tonic-gate WINDOW *old_curscr = curscr; 82*7c478bd9Sstevel@tonic-gate SCREEN *old = SP; 83*7c478bd9Sstevel@tonic-gate TERMINAL *old_term = cur_term; 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 86*7c478bd9Sstevel@tonic-gate if (outf == NULL) { 87*7c478bd9Sstevel@tonic-gate outf = fopen("trace", "w"); 88*7c478bd9Sstevel@tonic-gate if (outf == NULL) { 89*7c478bd9Sstevel@tonic-gate perror("trace"); 90*7c478bd9Sstevel@tonic-gate exit(-1); 91*7c478bd9Sstevel@tonic-gate } 92*7c478bd9Sstevel@tonic-gate setbuf(outf, (char *)NULL); 93*7c478bd9Sstevel@tonic-gate } 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate if (outf) 96*7c478bd9Sstevel@tonic-gate fprintf(outf, "NEWTERM(type=%s, outfptr=%x %d, infptr=%x %d) " 97*7c478bd9Sstevel@tonic-gate "isatty(2) %d, getenv %s\n", type, outfptr, 98*7c478bd9Sstevel@tonic-gate fileno(outfptr), infptr, fileno(infptr), isatty(2), 99*7c478bd9Sstevel@tonic-gate getenv("TERM")); 100*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* read in terminfo file */ 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate if (setupterm(type, fileno(outfptr), &retcode) != 0) 106*7c478bd9Sstevel@tonic-gate goto err2; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* the max length of a multi-byte character */ 109*7c478bd9Sstevel@tonic-gate _csmax = (cswidth[0] > cswidth[1]+1 ? 110*7c478bd9Sstevel@tonic-gate (cswidth[0] > cswidth[2]+1 ? cswidth[0] : cswidth[2]+1) : 111*7c478bd9Sstevel@tonic-gate (cswidth[1] > cswidth[2] ? cswidth[1]+1 : cswidth[2]+1)); 112*7c478bd9Sstevel@tonic-gate if (_csmax > CSMAX) 113*7c478bd9Sstevel@tonic-gate goto err2; 114*7c478bd9Sstevel@tonic-gate /* the max length of a multi-column character */ 115*7c478bd9Sstevel@tonic-gate _scrmax = _curs_scrwidth[0] > _curs_scrwidth[1] ? 116*7c478bd9Sstevel@tonic-gate (_curs_scrwidth[0] > _curs_scrwidth[2] ? _curs_scrwidth[0] : 117*7c478bd9Sstevel@tonic-gate _curs_scrwidth[2]) : (_curs_scrwidth[1] > _curs_scrwidth[2] ? 118*7c478bd9Sstevel@tonic-gate _curs_scrwidth[1] : _curs_scrwidth[2]); 119*7c478bd9Sstevel@tonic-gate /* true multi-byte/multi-column case */ 120*7c478bd9Sstevel@tonic-gate _mbtrue = (_csmax > 1 || _scrmax > 1); 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate if ((curs_errno = _chk_trm()) != -1) { 123*7c478bd9Sstevel@tonic-gate (void) strcpy(curs_parm_err, cur_term->_termname); 124*7c478bd9Sstevel@tonic-gate goto err2; 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate /* use calloc because almost everything needs to be zero */ 128*7c478bd9Sstevel@tonic-gate if ((SP = (SCREEN *) calloc(1, sizeof (SCREEN))) == NULL) 129*7c478bd9Sstevel@tonic-gate goto err1; 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate SP->term_file = outfptr; 132*7c478bd9Sstevel@tonic-gate SP->input_file = infptr; 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate /* 135*7c478bd9Sstevel@tonic-gate * The default is echo, for upward compatibility, but we do 136*7c478bd9Sstevel@tonic-gate * all echoing in curses to avoid problems with the tty driver 137*7c478bd9Sstevel@tonic-gate * echoing things during critical sections. 138*7c478bd9Sstevel@tonic-gate */ 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate SP->fl_echoit = 1; 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate /* set some fields for cur_term structure */ 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate (void) typeahead(fileno(infptr)); 145*7c478bd9Sstevel@tonic-gate (void) tinputfd(fileno(infptr)); 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate /* 148*7c478bd9Sstevel@tonic-gate * We use LINES instead of the SP variable and a local variable because 149*7c478bd9Sstevel@tonic-gate * slk_init and rip_init update the LINES value and application code 150*7c478bd9Sstevel@tonic-gate * may look at the value of LINES in the function called by rip_init. 151*7c478bd9Sstevel@tonic-gate */ 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate /* LINTED */ 154*7c478bd9Sstevel@tonic-gate LINES = SP->lsize = lsize > 0 ? lsize : lines; 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* force the output to be buffered */ 157*7c478bd9Sstevel@tonic-gate #ifdef _IOFBF 158*7c478bd9Sstevel@tonic-gate (void) setvbuf(outfptr, (char *)NULL, _IOFBF, 0); 159*7c478bd9Sstevel@tonic-gate #else /* _IOFBF */ 160*7c478bd9Sstevel@tonic-gate if ((sobuf = malloc(BUFSIZ)) == NULL) { 161*7c478bd9Sstevel@tonic-gate curs_errno = CURS_BAD_MALLOC; 162*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 163*7c478bd9Sstevel@tonic-gate strcpy(curs_parm_err, "newscreen"); 164*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 165*7c478bd9Sstevel@tonic-gate } 166*7c478bd9Sstevel@tonic-gate setbuf(outfptr, sobuf); 167*7c478bd9Sstevel@tonic-gate #endif /* _IOFBF */ 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate #ifdef SYSV 170*7c478bd9Sstevel@tonic-gate SP->baud = baud_convert[_BRS(PROGTTYS)]; 171*7c478bd9Sstevel@tonic-gate #else /* SYSV */ 172*7c478bd9Sstevel@tonic-gate SP->baud = baud_convert[_BR(PROGTTY)]; 173*7c478bd9Sstevel@tonic-gate #endif /* SYSV */ 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate /* figure out how much each terminal capability costs */ 176*7c478bd9Sstevel@tonic-gate _init_costs(); 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate /* initialize the array of alternate characters */ 179*7c478bd9Sstevel@tonic-gate (void) init_acs(); 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate SP->tcap = cur_term; 182*7c478bd9Sstevel@tonic-gate 183*7c478bd9Sstevel@tonic-gate /* set tty settings to something reasonable for us */ 184*7c478bd9Sstevel@tonic-gate #ifdef SYSV 185*7c478bd9Sstevel@tonic-gate PROGTTYS.c_lflag &= ~ECHO; 186*7c478bd9Sstevel@tonic-gate PROGTTYS.c_lflag |= ISIG; 187*7c478bd9Sstevel@tonic-gate PROGTTYS.c_oflag &= ~(OCRNL|ONLCR); /* why would anyone set OCRNL? */ 188*7c478bd9Sstevel@tonic-gate #else /* SYSV */ 189*7c478bd9Sstevel@tonic-gate PROGTTY.sg_flags &= ~(RAW|ECHO|CRMOD); 190*7c478bd9Sstevel@tonic-gate #endif /* SYSV */ 191*7c478bd9Sstevel@tonic-gate 192*7c478bd9Sstevel@tonic-gate (void) cbreak(); 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate /* LINTED */ 195*7c478bd9Sstevel@tonic-gate COLS = SP->csize = csize > 0 ? csize : columns; 196*7c478bd9Sstevel@tonic-gate if (tabsize == 0) 197*7c478bd9Sstevel@tonic-gate tabsize = (init_tabs == -1) ? 8 : init_tabs; 198*7c478bd9Sstevel@tonic-gate /* LINTED */ 199*7c478bd9Sstevel@tonic-gate SP->tsize = (short)tabsize; 200*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 201*7c478bd9Sstevel@tonic-gate if (outf) 202*7c478bd9Sstevel@tonic-gate fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); 203*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate if ((curscr = SP->cur_scr = newwin(LINES, COLS, 0, 0)) == NULL) 206*7c478bd9Sstevel@tonic-gate goto err; 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate SP->fl_endwin = 2; 209*7c478bd9Sstevel@tonic-gate #ifdef _VR2_COMPAT_CODE 210*7c478bd9Sstevel@tonic-gate _endwin = FALSE; 211*7c478bd9Sstevel@tonic-gate #endif /* _VR2_COMPAT_CODE */ 212*7c478bd9Sstevel@tonic-gate curscr->_sync = TRUE; 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate /* 215*7c478bd9Sstevel@tonic-gate * This will tell _quick_echo(if it's ever called), whether 216*7c478bd9Sstevel@tonic-gate * _quick_echo should let wrefresh handle everything. 217*7c478bd9Sstevel@tonic-gate */ 218*7c478bd9Sstevel@tonic-gate 219*7c478bd9Sstevel@tonic-gate if (ceol_standout_glitch || (magic_cookie_glitch >= 0) || 220*7c478bd9Sstevel@tonic-gate tilde_glitch || (transparent_underline && erase_overstrike)) { 221*7c478bd9Sstevel@tonic-gate curscr->_flags |= _CANT_BE_IMMED; 222*7c478bd9Sstevel@tonic-gate } 223*7c478bd9Sstevel@tonic-gate if (!(SP->virt_scr = newwin(LINES, COLS, 0, 0))) 224*7c478bd9Sstevel@tonic-gate goto err; 225*7c478bd9Sstevel@tonic-gate _virtscr = SP->virt_scr; 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate SP->virt_scr->_clear = FALSE; 228*7c478bd9Sstevel@tonic-gate 229*7c478bd9Sstevel@tonic-gate /* video mark map for cookie terminals */ 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate if (ceol_standout_glitch || (magic_cookie_glitch >= 0)) { 232*7c478bd9Sstevel@tonic-gate int i, nc; 233*7c478bd9Sstevel@tonic-gate char **marks; 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate if ((marks = (char **)calloc((unsigned)LINES, 236*7c478bd9Sstevel@tonic-gate sizeof (char *))) == NULL) 237*7c478bd9Sstevel@tonic-gate goto err; 238*7c478bd9Sstevel@tonic-gate SP->_mks = marks; 239*7c478bd9Sstevel@tonic-gate nc = (COLS / BITSPERBYTE) + (COLS % BITSPERBYTE ? 1 : 0); 240*7c478bd9Sstevel@tonic-gate if ((*marks = (char *)calloc((unsigned)nc * LINES, 241*7c478bd9Sstevel@tonic-gate sizeof (char))) == NULL) 242*7c478bd9Sstevel@tonic-gate goto err; 243*7c478bd9Sstevel@tonic-gate for (i = LINES - 1; i-- > 0; ++marks) 244*7c478bd9Sstevel@tonic-gate *(marks + 1) = *marks + nc; 245*7c478bd9Sstevel@tonic-gate } 246*7c478bd9Sstevel@tonic-gate 247*7c478bd9Sstevel@tonic-gate /* hash tables for lines */ 248*7c478bd9Sstevel@tonic-gate if ((SP->cur_hash = (int *)calloc((unsigned)2 * LINES, 249*7c478bd9Sstevel@tonic-gate sizeof (int))) == NULL) 250*7c478bd9Sstevel@tonic-gate goto err; 251*7c478bd9Sstevel@tonic-gate SP->virt_hash = SP->cur_hash + LINES; 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate /* adjust the screen size if soft labels and/or ripoffline are used */ 254*7c478bd9Sstevel@tonic-gate if (_slk_init) 255*7c478bd9Sstevel@tonic-gate (*_slk_init)(); 256*7c478bd9Sstevel@tonic-gate if (_rip_init) 257*7c478bd9Sstevel@tonic-gate (*_rip_init)(); 258*7c478bd9Sstevel@tonic-gate 259*7c478bd9Sstevel@tonic-gate if ((SP->std_scr = newwin(LINES, COLS, 0, 0)) == NULL) { 260*7c478bd9Sstevel@tonic-gate /* free all the storage allocated above and return NULL */ 261*7c478bd9Sstevel@tonic-gate err: 262*7c478bd9Sstevel@tonic-gate delscreen(SP); 263*7c478bd9Sstevel@tonic-gate COLS = old_cols; 264*7c478bd9Sstevel@tonic-gate curscr = old_curscr; 265*7c478bd9Sstevel@tonic-gate LINES = old_lines; 266*7c478bd9Sstevel@tonic-gate err1: 267*7c478bd9Sstevel@tonic-gate SP = old; 268*7c478bd9Sstevel@tonic-gate 269*7c478bd9Sstevel@tonic-gate curs_errno = CURS_BAD_MALLOC; 270*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 271*7c478bd9Sstevel@tonic-gate strcpy(curs_parm_err, "newscreen"); 272*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate err2: 275*7c478bd9Sstevel@tonic-gate cur_term = old_term; 276*7c478bd9Sstevel@tonic-gate return (NULL); 277*7c478bd9Sstevel@tonic-gate } 278*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 279*7c478bd9Sstevel@tonic-gate if (outf) 280*7c478bd9Sstevel@tonic-gate fprintf(outf, "SP %x, stdscr %x, curscr %x\n", 281*7c478bd9Sstevel@tonic-gate SP, SP->std_scr, curscr); 282*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 283*7c478bd9Sstevel@tonic-gate 284*7c478bd9Sstevel@tonic-gate if (((SP->imode = (enter_insert_mode && exit_insert_mode)) != 0) && 285*7c478bd9Sstevel@tonic-gate ((SP->dmode = (enter_delete_mode && exit_delete_mode)) != 0)) { 286*7c478bd9Sstevel@tonic-gate if (strcmp(enter_insert_mode, enter_delete_mode) == 0) 287*7c478bd9Sstevel@tonic-gate SP->sid_equal = TRUE; 288*7c478bd9Sstevel@tonic-gate if (strcmp(exit_insert_mode, exit_delete_mode) == 0) 289*7c478bd9Sstevel@tonic-gate SP->eid_equal = TRUE; 290*7c478bd9Sstevel@tonic-gate } 291*7c478bd9Sstevel@tonic-gate SP->ichok = (SP->imode || insert_character || parm_ich); 292*7c478bd9Sstevel@tonic-gate SP->dchok = (delete_character || parm_dch); 293*7c478bd9Sstevel@tonic-gate 294*7c478bd9Sstevel@tonic-gate stdscr = SP->std_scr; 295*7c478bd9Sstevel@tonic-gate TABSIZE = SP->tsize; 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate return (SP); 298*7c478bd9Sstevel@tonic-gate } 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate /* 301*7c478bd9Sstevel@tonic-gate * check if terminal have capabilities to do basic cursor movements and 302*7c478bd9Sstevel@tonic-gate * screen clearing 303*7c478bd9Sstevel@tonic-gate */ 304*7c478bd9Sstevel@tonic-gate static int 305*7c478bd9Sstevel@tonic-gate _chk_trm(void) 306*7c478bd9Sstevel@tonic-gate { 307*7c478bd9Sstevel@tonic-gate short error_num = -1; 308*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 309*7c478bd9Sstevel@tonic-gate if (outf) 310*7c478bd9Sstevel@tonic-gate fprintf(outf, "chk_trm().\n"); 311*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate if (generic_type) 314*7c478bd9Sstevel@tonic-gate error_num = CURS_UNKNOWN; 315*7c478bd9Sstevel@tonic-gate else { 316*7c478bd9Sstevel@tonic-gate if (isfilter) { 317*7c478bd9Sstevel@tonic-gate _forget(); 318*7c478bd9Sstevel@tonic-gate /* Only need to move left or right on current line */ 319*7c478bd9Sstevel@tonic-gate if (!(cursor_left || carriage_return || 320*7c478bd9Sstevel@tonic-gate column_address || parm_left_cursor)) { 321*7c478bd9Sstevel@tonic-gate goto out_stupid; 322*7c478bd9Sstevel@tonic-gate } 323*7c478bd9Sstevel@tonic-gate } else { 324*7c478bd9Sstevel@tonic-gate if ((hard_copy || over_strike) || 325*7c478bd9Sstevel@tonic-gate /* some way to move up, down, left */ 326*7c478bd9Sstevel@tonic-gate (!(cursor_address) && 327*7c478bd9Sstevel@tonic-gate (!((cursor_up || cursor_home) && cursor_down && 328*7c478bd9Sstevel@tonic-gate (cursor_left || carriage_return)))) || 329*7c478bd9Sstevel@tonic-gate (!clear_screen)) { 330*7c478bd9Sstevel@tonic-gate out_stupid: 331*7c478bd9Sstevel@tonic-gate error_num = CURS_STUPID; 332*7c478bd9Sstevel@tonic-gate } 333*7c478bd9Sstevel@tonic-gate } 334*7c478bd9Sstevel@tonic-gate } 335*7c478bd9Sstevel@tonic-gate return (error_num); 336*7c478bd9Sstevel@tonic-gate } 337*7c478bd9Sstevel@tonic-gate 338*7c478bd9Sstevel@tonic-gate int 339*7c478bd9Sstevel@tonic-gate filter(void) 340*7c478bd9Sstevel@tonic-gate { 341*7c478bd9Sstevel@tonic-gate isfilter = 1; 342*7c478bd9Sstevel@tonic-gate return (OK); 343*7c478bd9Sstevel@tonic-gate } 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate /* 346*7c478bd9Sstevel@tonic-gate * if (for some reason) user assumes that terminal has only one line, 347*7c478bd9Sstevel@tonic-gate * disable all capabilities that deal with non-horizontal cursor movement 348*7c478bd9Sstevel@tonic-gate */ 349*7c478bd9Sstevel@tonic-gate static void 350*7c478bd9Sstevel@tonic-gate _forget(void) 351*7c478bd9Sstevel@tonic-gate { 352*7c478bd9Sstevel@tonic-gate row_address = cursor_address = clear_screen = parm_down_cursor = 353*7c478bd9Sstevel@tonic-gate cursor_up = cursor_down = NULL; 354*7c478bd9Sstevel@tonic-gate cursor_home = carriage_return; 355*7c478bd9Sstevel@tonic-gate lines = 1; 356*7c478bd9Sstevel@tonic-gate } 357