17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*de81e71eSTim Marsland * Common Development and Distribution License (the "License"). 6*de81e71eSTim Marsland * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*de81e71eSTim Marsland 227c478bd9Sstevel@tonic-gate /* 23*de81e71eSTim Marsland * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 327c478bd9Sstevel@tonic-gate * The Regents of the University of California 337c478bd9Sstevel@tonic-gate * All Rights Reserved 347c478bd9Sstevel@tonic-gate * 357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 377c478bd9Sstevel@tonic-gate * contributors. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #include <stdio.h> 437c478bd9Sstevel@tonic-gate #include <stdlib.h> 447c478bd9Sstevel@tonic-gate #include <string.h> 457c478bd9Sstevel@tonic-gate #include <sys/types.h> 467c478bd9Sstevel@tonic-gate #include "curses_inc.h" 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #ifdef _VR2_COMPAT_CODE 497c478bd9Sstevel@tonic-gate extern char _endwin; 507c478bd9Sstevel@tonic-gate #endif /* _VR2_COMPAT_CODE */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* 1200 is put at the 0th location since 0 is probably a mistake. */ 537c478bd9Sstevel@tonic-gate static long baud_convert[] = { 547c478bd9Sstevel@tonic-gate 1200, 50, 75, 110, 135, 150, 200, 300, 600, 1200, 557c478bd9Sstevel@tonic-gate 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 56*de81e71eSTim Marsland 115200, 153600, 230400, 307200, 460800, 921600 577c478bd9Sstevel@tonic-gate }; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate static char isfilter = 0; 607c478bd9Sstevel@tonic-gate static int _chk_trm(void); 617c478bd9Sstevel@tonic-gate static void _forget(void); 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * newscreen sets up a terminal and returns a pointer to the terminal 657c478bd9Sstevel@tonic-gate * structure or NULL in case of an error. The parameters are: 667c478bd9Sstevel@tonic-gate * type: terminal type 677c478bd9Sstevel@tonic-gate * lsize, csize, tabsize: physical sizes 687c478bd9Sstevel@tonic-gate * infptr, outfptr: input and output stdio stream file pointers 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate SCREEN * 727c478bd9Sstevel@tonic-gate newscreen(char *type, int lsize, int csize, int tabsize, 737c478bd9Sstevel@tonic-gate FILE *outfptr, FILE *infptr) 747c478bd9Sstevel@tonic-gate { 757c478bd9Sstevel@tonic-gate int old_lines = LINES, old_cols = COLS, retcode; 767c478bd9Sstevel@tonic-gate #ifndef _IOFBF 777c478bd9Sstevel@tonic-gate char *sobuf; 787c478bd9Sstevel@tonic-gate #endif /* _IOBUF */ 797c478bd9Sstevel@tonic-gate WINDOW *old_curscr = curscr; 807c478bd9Sstevel@tonic-gate SCREEN *old = SP; 817c478bd9Sstevel@tonic-gate TERMINAL *old_term = cur_term; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate #ifdef DEBUG 847c478bd9Sstevel@tonic-gate if (outf == NULL) { 857c478bd9Sstevel@tonic-gate outf = fopen("trace", "w"); 867c478bd9Sstevel@tonic-gate if (outf == NULL) { 877c478bd9Sstevel@tonic-gate perror("trace"); 887c478bd9Sstevel@tonic-gate exit(-1); 897c478bd9Sstevel@tonic-gate } 907c478bd9Sstevel@tonic-gate setbuf(outf, (char *)NULL); 917c478bd9Sstevel@tonic-gate } 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate if (outf) 947c478bd9Sstevel@tonic-gate fprintf(outf, "NEWTERM(type=%s, outfptr=%x %d, infptr=%x %d) " 957c478bd9Sstevel@tonic-gate "isatty(2) %d, getenv %s\n", type, outfptr, 967c478bd9Sstevel@tonic-gate fileno(outfptr), infptr, fileno(infptr), isatty(2), 977c478bd9Sstevel@tonic-gate getenv("TERM")); 987c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* read in terminfo file */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate if (setupterm(type, fileno(outfptr), &retcode) != 0) 1047c478bd9Sstevel@tonic-gate goto err2; 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* the max length of a multi-byte character */ 1077c478bd9Sstevel@tonic-gate _csmax = (cswidth[0] > cswidth[1]+1 ? 1087c478bd9Sstevel@tonic-gate (cswidth[0] > cswidth[2]+1 ? cswidth[0] : cswidth[2]+1) : 1097c478bd9Sstevel@tonic-gate (cswidth[1] > cswidth[2] ? cswidth[1]+1 : cswidth[2]+1)); 1107c478bd9Sstevel@tonic-gate if (_csmax > CSMAX) 1117c478bd9Sstevel@tonic-gate goto err2; 1127c478bd9Sstevel@tonic-gate /* the max length of a multi-column character */ 1137c478bd9Sstevel@tonic-gate _scrmax = _curs_scrwidth[0] > _curs_scrwidth[1] ? 1147c478bd9Sstevel@tonic-gate (_curs_scrwidth[0] > _curs_scrwidth[2] ? _curs_scrwidth[0] : 1157c478bd9Sstevel@tonic-gate _curs_scrwidth[2]) : (_curs_scrwidth[1] > _curs_scrwidth[2] ? 1167c478bd9Sstevel@tonic-gate _curs_scrwidth[1] : _curs_scrwidth[2]); 1177c478bd9Sstevel@tonic-gate /* true multi-byte/multi-column case */ 1187c478bd9Sstevel@tonic-gate _mbtrue = (_csmax > 1 || _scrmax > 1); 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate if ((curs_errno = _chk_trm()) != -1) { 1217c478bd9Sstevel@tonic-gate (void) strcpy(curs_parm_err, cur_term->_termname); 1227c478bd9Sstevel@tonic-gate goto err2; 1237c478bd9Sstevel@tonic-gate } 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* use calloc because almost everything needs to be zero */ 1267c478bd9Sstevel@tonic-gate if ((SP = (SCREEN *) calloc(1, sizeof (SCREEN))) == NULL) 1277c478bd9Sstevel@tonic-gate goto err1; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate SP->term_file = outfptr; 1307c478bd9Sstevel@tonic-gate SP->input_file = infptr; 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate /* 1337c478bd9Sstevel@tonic-gate * The default is echo, for upward compatibility, but we do 1347c478bd9Sstevel@tonic-gate * all echoing in curses to avoid problems with the tty driver 1357c478bd9Sstevel@tonic-gate * echoing things during critical sections. 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate SP->fl_echoit = 1; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* set some fields for cur_term structure */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate (void) typeahead(fileno(infptr)); 1437c478bd9Sstevel@tonic-gate (void) tinputfd(fileno(infptr)); 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * We use LINES instead of the SP variable and a local variable because 1477c478bd9Sstevel@tonic-gate * slk_init and rip_init update the LINES value and application code 1487c478bd9Sstevel@tonic-gate * may look at the value of LINES in the function called by rip_init. 1497c478bd9Sstevel@tonic-gate */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* LINTED */ 1527c478bd9Sstevel@tonic-gate LINES = SP->lsize = lsize > 0 ? lsize : lines; 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* force the output to be buffered */ 1557c478bd9Sstevel@tonic-gate #ifdef _IOFBF 1567c478bd9Sstevel@tonic-gate (void) setvbuf(outfptr, (char *)NULL, _IOFBF, 0); 1577c478bd9Sstevel@tonic-gate #else /* _IOFBF */ 1587c478bd9Sstevel@tonic-gate if ((sobuf = malloc(BUFSIZ)) == NULL) { 1597c478bd9Sstevel@tonic-gate curs_errno = CURS_BAD_MALLOC; 1607c478bd9Sstevel@tonic-gate #ifdef DEBUG 1617c478bd9Sstevel@tonic-gate strcpy(curs_parm_err, "newscreen"); 1627c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 1637c478bd9Sstevel@tonic-gate } 1647c478bd9Sstevel@tonic-gate setbuf(outfptr, sobuf); 1657c478bd9Sstevel@tonic-gate #endif /* _IOFBF */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #ifdef SYSV 1687c478bd9Sstevel@tonic-gate SP->baud = baud_convert[_BRS(PROGTTYS)]; 1697c478bd9Sstevel@tonic-gate #else /* SYSV */ 1707c478bd9Sstevel@tonic-gate SP->baud = baud_convert[_BR(PROGTTY)]; 1717c478bd9Sstevel@tonic-gate #endif /* SYSV */ 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate /* figure out how much each terminal capability costs */ 1747c478bd9Sstevel@tonic-gate _init_costs(); 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate /* initialize the array of alternate characters */ 1777c478bd9Sstevel@tonic-gate (void) init_acs(); 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate SP->tcap = cur_term; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate /* set tty settings to something reasonable for us */ 1827c478bd9Sstevel@tonic-gate #ifdef SYSV 1837c478bd9Sstevel@tonic-gate PROGTTYS.c_lflag &= ~ECHO; 1847c478bd9Sstevel@tonic-gate PROGTTYS.c_lflag |= ISIG; 1857c478bd9Sstevel@tonic-gate PROGTTYS.c_oflag &= ~(OCRNL|ONLCR); /* why would anyone set OCRNL? */ 1867c478bd9Sstevel@tonic-gate #else /* SYSV */ 1877c478bd9Sstevel@tonic-gate PROGTTY.sg_flags &= ~(RAW|ECHO|CRMOD); 1887c478bd9Sstevel@tonic-gate #endif /* SYSV */ 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate (void) cbreak(); 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate /* LINTED */ 1937c478bd9Sstevel@tonic-gate COLS = SP->csize = csize > 0 ? csize : columns; 1947c478bd9Sstevel@tonic-gate if (tabsize == 0) 1957c478bd9Sstevel@tonic-gate tabsize = (init_tabs == -1) ? 8 : init_tabs; 1967c478bd9Sstevel@tonic-gate /* LINTED */ 1977c478bd9Sstevel@tonic-gate SP->tsize = (short)tabsize; 1987c478bd9Sstevel@tonic-gate #ifdef DEBUG 1997c478bd9Sstevel@tonic-gate if (outf) 2007c478bd9Sstevel@tonic-gate fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); 2017c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate if ((curscr = SP->cur_scr = newwin(LINES, COLS, 0, 0)) == NULL) 2047c478bd9Sstevel@tonic-gate goto err; 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate SP->fl_endwin = 2; 2077c478bd9Sstevel@tonic-gate #ifdef _VR2_COMPAT_CODE 2087c478bd9Sstevel@tonic-gate _endwin = FALSE; 2097c478bd9Sstevel@tonic-gate #endif /* _VR2_COMPAT_CODE */ 2107c478bd9Sstevel@tonic-gate curscr->_sync = TRUE; 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /* 2137c478bd9Sstevel@tonic-gate * This will tell _quick_echo(if it's ever called), whether 2147c478bd9Sstevel@tonic-gate * _quick_echo should let wrefresh handle everything. 2157c478bd9Sstevel@tonic-gate */ 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate if (ceol_standout_glitch || (magic_cookie_glitch >= 0) || 2187c478bd9Sstevel@tonic-gate tilde_glitch || (transparent_underline && erase_overstrike)) { 2197c478bd9Sstevel@tonic-gate curscr->_flags |= _CANT_BE_IMMED; 2207c478bd9Sstevel@tonic-gate } 2217c478bd9Sstevel@tonic-gate if (!(SP->virt_scr = newwin(LINES, COLS, 0, 0))) 2227c478bd9Sstevel@tonic-gate goto err; 2237c478bd9Sstevel@tonic-gate _virtscr = SP->virt_scr; 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate SP->virt_scr->_clear = FALSE; 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate /* video mark map for cookie terminals */ 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate if (ceol_standout_glitch || (magic_cookie_glitch >= 0)) { 2307c478bd9Sstevel@tonic-gate int i, nc; 2317c478bd9Sstevel@tonic-gate char **marks; 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate if ((marks = (char **)calloc((unsigned)LINES, 2347c478bd9Sstevel@tonic-gate sizeof (char *))) == NULL) 2357c478bd9Sstevel@tonic-gate goto err; 2367c478bd9Sstevel@tonic-gate SP->_mks = marks; 2377c478bd9Sstevel@tonic-gate nc = (COLS / BITSPERBYTE) + (COLS % BITSPERBYTE ? 1 : 0); 2387c478bd9Sstevel@tonic-gate if ((*marks = (char *)calloc((unsigned)nc * LINES, 2397c478bd9Sstevel@tonic-gate sizeof (char))) == NULL) 2407c478bd9Sstevel@tonic-gate goto err; 2417c478bd9Sstevel@tonic-gate for (i = LINES - 1; i-- > 0; ++marks) 2427c478bd9Sstevel@tonic-gate *(marks + 1) = *marks + nc; 2437c478bd9Sstevel@tonic-gate } 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate /* hash tables for lines */ 2467c478bd9Sstevel@tonic-gate if ((SP->cur_hash = (int *)calloc((unsigned)2 * LINES, 2477c478bd9Sstevel@tonic-gate sizeof (int))) == NULL) 2487c478bd9Sstevel@tonic-gate goto err; 2497c478bd9Sstevel@tonic-gate SP->virt_hash = SP->cur_hash + LINES; 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate /* adjust the screen size if soft labels and/or ripoffline are used */ 2527c478bd9Sstevel@tonic-gate if (_slk_init) 2537c478bd9Sstevel@tonic-gate (*_slk_init)(); 2547c478bd9Sstevel@tonic-gate if (_rip_init) 2557c478bd9Sstevel@tonic-gate (*_rip_init)(); 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate if ((SP->std_scr = newwin(LINES, COLS, 0, 0)) == NULL) { 2587c478bd9Sstevel@tonic-gate /* free all the storage allocated above and return NULL */ 2597c478bd9Sstevel@tonic-gate err: 2607c478bd9Sstevel@tonic-gate delscreen(SP); 2617c478bd9Sstevel@tonic-gate COLS = old_cols; 2627c478bd9Sstevel@tonic-gate curscr = old_curscr; 2637c478bd9Sstevel@tonic-gate LINES = old_lines; 2647c478bd9Sstevel@tonic-gate err1: 2657c478bd9Sstevel@tonic-gate SP = old; 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate curs_errno = CURS_BAD_MALLOC; 2687c478bd9Sstevel@tonic-gate #ifdef DEBUG 2697c478bd9Sstevel@tonic-gate strcpy(curs_parm_err, "newscreen"); 2707c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate err2: 2737c478bd9Sstevel@tonic-gate cur_term = old_term; 2747c478bd9Sstevel@tonic-gate return (NULL); 2757c478bd9Sstevel@tonic-gate } 2767c478bd9Sstevel@tonic-gate #ifdef DEBUG 2777c478bd9Sstevel@tonic-gate if (outf) 2787c478bd9Sstevel@tonic-gate fprintf(outf, "SP %x, stdscr %x, curscr %x\n", 2797c478bd9Sstevel@tonic-gate SP, SP->std_scr, curscr); 2807c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate if (((SP->imode = (enter_insert_mode && exit_insert_mode)) != 0) && 2837c478bd9Sstevel@tonic-gate ((SP->dmode = (enter_delete_mode && exit_delete_mode)) != 0)) { 2847c478bd9Sstevel@tonic-gate if (strcmp(enter_insert_mode, enter_delete_mode) == 0) 2857c478bd9Sstevel@tonic-gate SP->sid_equal = TRUE; 2867c478bd9Sstevel@tonic-gate if (strcmp(exit_insert_mode, exit_delete_mode) == 0) 2877c478bd9Sstevel@tonic-gate SP->eid_equal = TRUE; 2887c478bd9Sstevel@tonic-gate } 2897c478bd9Sstevel@tonic-gate SP->ichok = (SP->imode || insert_character || parm_ich); 2907c478bd9Sstevel@tonic-gate SP->dchok = (delete_character || parm_dch); 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate stdscr = SP->std_scr; 2937c478bd9Sstevel@tonic-gate TABSIZE = SP->tsize; 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate return (SP); 2967c478bd9Sstevel@tonic-gate } 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate /* 2997c478bd9Sstevel@tonic-gate * check if terminal have capabilities to do basic cursor movements and 3007c478bd9Sstevel@tonic-gate * screen clearing 3017c478bd9Sstevel@tonic-gate */ 3027c478bd9Sstevel@tonic-gate static int 3037c478bd9Sstevel@tonic-gate _chk_trm(void) 3047c478bd9Sstevel@tonic-gate { 3057c478bd9Sstevel@tonic-gate short error_num = -1; 3067c478bd9Sstevel@tonic-gate #ifdef DEBUG 3077c478bd9Sstevel@tonic-gate if (outf) 3087c478bd9Sstevel@tonic-gate fprintf(outf, "chk_trm().\n"); 3097c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate if (generic_type) 3127c478bd9Sstevel@tonic-gate error_num = CURS_UNKNOWN; 3137c478bd9Sstevel@tonic-gate else { 3147c478bd9Sstevel@tonic-gate if (isfilter) { 3157c478bd9Sstevel@tonic-gate _forget(); 3167c478bd9Sstevel@tonic-gate /* Only need to move left or right on current line */ 3177c478bd9Sstevel@tonic-gate if (!(cursor_left || carriage_return || 3187c478bd9Sstevel@tonic-gate column_address || parm_left_cursor)) { 3197c478bd9Sstevel@tonic-gate goto out_stupid; 3207c478bd9Sstevel@tonic-gate } 3217c478bd9Sstevel@tonic-gate } else { 3227c478bd9Sstevel@tonic-gate if ((hard_copy || over_strike) || 3237c478bd9Sstevel@tonic-gate /* some way to move up, down, left */ 3247c478bd9Sstevel@tonic-gate (!(cursor_address) && 3257c478bd9Sstevel@tonic-gate (!((cursor_up || cursor_home) && cursor_down && 3267c478bd9Sstevel@tonic-gate (cursor_left || carriage_return)))) || 3277c478bd9Sstevel@tonic-gate (!clear_screen)) { 3287c478bd9Sstevel@tonic-gate out_stupid: 3297c478bd9Sstevel@tonic-gate error_num = CURS_STUPID; 3307c478bd9Sstevel@tonic-gate } 3317c478bd9Sstevel@tonic-gate } 3327c478bd9Sstevel@tonic-gate } 3337c478bd9Sstevel@tonic-gate return (error_num); 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate int 3377c478bd9Sstevel@tonic-gate filter(void) 3387c478bd9Sstevel@tonic-gate { 3397c478bd9Sstevel@tonic-gate isfilter = 1; 3407c478bd9Sstevel@tonic-gate return (OK); 3417c478bd9Sstevel@tonic-gate } 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate /* 3447c478bd9Sstevel@tonic-gate * if (for some reason) user assumes that terminal has only one line, 3457c478bd9Sstevel@tonic-gate * disable all capabilities that deal with non-horizontal cursor movement 3467c478bd9Sstevel@tonic-gate */ 3477c478bd9Sstevel@tonic-gate static void 3487c478bd9Sstevel@tonic-gate _forget(void) 3497c478bd9Sstevel@tonic-gate { 3507c478bd9Sstevel@tonic-gate row_address = cursor_address = clear_screen = parm_down_cursor = 3517c478bd9Sstevel@tonic-gate cursor_up = cursor_down = NULL; 3527c478bd9Sstevel@tonic-gate cursor_home = carriage_return; 3537c478bd9Sstevel@tonic-gate lines = 1; 3547c478bd9Sstevel@tonic-gate } 355