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 568c92b9fScf46844 * Common Development and Distribution License (the "License"). 668c92b9fScf46844 * 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 */ 2123a1cceaSRoger A. Faulkner 22f6db9f27Scf46844 /* 2323a1cceaSRoger A. Faulkner * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 24f6db9f27Scf46844 */ 25f6db9f27Scf46844 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */ 307c478bd9Sstevel@tonic-gate 31ace1a5f1Sdp #ifndef _EX_H 32ace1a5f1Sdp #define _EX_H 33ace1a5f1Sdp 34ace1a5f1Sdp #ifdef __cplusplus 35ace1a5f1Sdp extern "C" { 36ace1a5f1Sdp #endif 37ace1a5f1Sdp 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * This file contains most of the declarations common to a large number 407c478bd9Sstevel@tonic-gate * of routines. The file ex_vis.h contains declarations 417c478bd9Sstevel@tonic-gate * which are used only inside the screen editor. 427c478bd9Sstevel@tonic-gate * The file ex_tune.h contains parameters which can be diddled per installation. 437c478bd9Sstevel@tonic-gate * 447c478bd9Sstevel@tonic-gate * The declarations relating to the argument list, regular expressions, 457c478bd9Sstevel@tonic-gate * the temporary file data structure used by the editor 467c478bd9Sstevel@tonic-gate * and the data describing terminals are each fairly substantial and 477c478bd9Sstevel@tonic-gate * are kept in the files ex_{argv,re,temp,tty}.h which 487c478bd9Sstevel@tonic-gate * we #include separately. 497c478bd9Sstevel@tonic-gate * 507c478bd9Sstevel@tonic-gate * If you are going to dig into ex, you should look at the outline of the 517c478bd9Sstevel@tonic-gate * distribution of the code into files at the beginning of ex.c and ex_v.c. 527c478bd9Sstevel@tonic-gate * Code which is similar to that of ed is lightly or undocumented in spots 537c478bd9Sstevel@tonic-gate * (e.g. the regular expression code). Newer code (e.g. open and visual) 547c478bd9Sstevel@tonic-gate * is much more carefully documented, and still rough in spots. 557c478bd9Sstevel@tonic-gate * 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate #ifdef UCBV7 587c478bd9Sstevel@tonic-gate #include <whoami.h> 597c478bd9Sstevel@tonic-gate #endif 607c478bd9Sstevel@tonic-gate #include <sys/types.h> 617c478bd9Sstevel@tonic-gate #include <ctype.h> 627c478bd9Sstevel@tonic-gate #include <errno.h> 637c478bd9Sstevel@tonic-gate #include <signal.h> 647c478bd9Sstevel@tonic-gate #include <setjmp.h> 657c478bd9Sstevel@tonic-gate #include <sys/stat.h> 667c478bd9Sstevel@tonic-gate #include <stdlib.h> 677c478bd9Sstevel@tonic-gate #include <limits.h> 6868c92b9fScf46844 #include <libintl.h> 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate #define MULTI_BYTE_MAX MB_LEN_MAX 717c478bd9Sstevel@tonic-gate #define FTYPE(A) (A.st_mode) 727c478bd9Sstevel@tonic-gate #define FMODE(A) (A.st_mode) 737c478bd9Sstevel@tonic-gate #define IDENTICAL(A,B) (A.st_dev==B.st_dev && A.st_ino==B.st_ino) 747c478bd9Sstevel@tonic-gate #define ISBLK(A) ((A.st_mode & S_IFMT) == S_IFBLK) 757c478bd9Sstevel@tonic-gate #define ISCHR(A) ((A.st_mode & S_IFMT) == S_IFCHR) 767c478bd9Sstevel@tonic-gate #define ISDIR(A) ((A.st_mode & S_IFMT) == S_IFDIR) 777c478bd9Sstevel@tonic-gate #define ISFIFO(A) ((A.st_mode & S_IFMT) == S_IFIFO) 787c478bd9Sstevel@tonic-gate #define ISREG(A) ((A.st_mode & S_IFMT) == S_IFREG) 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #ifdef USG 817c478bd9Sstevel@tonic-gate #include <termio.h> 827c478bd9Sstevel@tonic-gate typedef struct termios SGTTY; 837c478bd9Sstevel@tonic-gate #else 847c478bd9Sstevel@tonic-gate #include <sgtty.h> 857c478bd9Sstevel@tonic-gate typedef struct sgttyb SGTTY; 867c478bd9Sstevel@tonic-gate #endif 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #ifdef PAVEL 897c478bd9Sstevel@tonic-gate #define SGTTY struct sgttyb /* trick Pavel curses to not include <curses.h> */ 907c478bd9Sstevel@tonic-gate #endif 917c478bd9Sstevel@tonic-gate typedef char bool; 927c478bd9Sstevel@tonic-gate typedef unsigned long chtype; 937c478bd9Sstevel@tonic-gate #include <term.h> 947c478bd9Sstevel@tonic-gate #define bool vi_bool 957c478bd9Sstevel@tonic-gate #ifdef PAVEL 967c478bd9Sstevel@tonic-gate #undef SGTTY 977c478bd9Sstevel@tonic-gate #endif 987c478bd9Sstevel@tonic-gate #ifndef var 997c478bd9Sstevel@tonic-gate #define var extern 1007c478bd9Sstevel@tonic-gate #endif 1017c478bd9Sstevel@tonic-gate var char *exit_bold; /* string to exit standout mode */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * The following little dance copes with the new USG tty handling. 1057c478bd9Sstevel@tonic-gate * This stuff has the advantage of considerable flexibility, and 1067c478bd9Sstevel@tonic-gate * the disadvantage of being incompatible with anything else. 1077c478bd9Sstevel@tonic-gate * The presence of the symbol USG will indicate the new code: 1087c478bd9Sstevel@tonic-gate * in this case, we define CBREAK (because we can simulate it exactly), 1097c478bd9Sstevel@tonic-gate * but we won't actually use it, so we set it to a value that will 1107c478bd9Sstevel@tonic-gate * probably blow the compilation if we goof up. 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate #ifdef USG 1137c478bd9Sstevel@tonic-gate #define CBREAK xxxxx 1147c478bd9Sstevel@tonic-gate #endif 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate #ifndef VMUNIX 1177c478bd9Sstevel@tonic-gate typedef short line; 1187c478bd9Sstevel@tonic-gate #else 1197c478bd9Sstevel@tonic-gate typedef int line; 1207c478bd9Sstevel@tonic-gate #endif 1217c478bd9Sstevel@tonic-gate typedef short bool; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #include "ex_tune.h" 1247c478bd9Sstevel@tonic-gate #include "ex_vars.h" 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * Options in the editor are referred to usually by "value(vi_name)" where 1277c478bd9Sstevel@tonic-gate * name is all uppercase, i.e. "value(vi_PROMPT)". This is actually a macro 1287c478bd9Sstevel@tonic-gate * which expands to a fixed field in a static structure and so generates 1297c478bd9Sstevel@tonic-gate * very little code. The offsets for the option names in the structure 1307c478bd9Sstevel@tonic-gate * are generated automagically from the structure initializing them in 1317c478bd9Sstevel@tonic-gate * ex_data.c... see the shell script "makeoptions". 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate struct option { 1347c478bd9Sstevel@tonic-gate unsigned char *oname; 1357c478bd9Sstevel@tonic-gate unsigned char *oabbrev; 1367c478bd9Sstevel@tonic-gate short otype; /* Types -- see below */ 1377c478bd9Sstevel@tonic-gate short odefault; /* Default value */ 1387c478bd9Sstevel@tonic-gate short ovalue; /* Current value */ 1397c478bd9Sstevel@tonic-gate unsigned char *osvalue; 1407c478bd9Sstevel@tonic-gate }; 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #define ONOFF 0 1437c478bd9Sstevel@tonic-gate #define NUMERIC 1 1447c478bd9Sstevel@tonic-gate #define STRING 2 /* SHELL or DIRECTORY */ 1457c478bd9Sstevel@tonic-gate #define OTERM 3 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate #define value(a) options[a].ovalue 1487c478bd9Sstevel@tonic-gate #define svalue(a) options[a].osvalue 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate extern struct option options[vi_NOPTS + 1]; 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * The editor does not normally use the standard i/o library. Because 1557c478bd9Sstevel@tonic-gate * we expect the editor to be a heavily used program and because it 1567c478bd9Sstevel@tonic-gate * does a substantial amount of input/output processing it is appropriate 1577c478bd9Sstevel@tonic-gate * for it to call low level read/write primitives directly. In fact, 1587c478bd9Sstevel@tonic-gate * when debugging the editor we use the standard i/o library. In any 1597c478bd9Sstevel@tonic-gate * case the editor needs a printf which prints through "putchar" ala the 1607c478bd9Sstevel@tonic-gate * old version 6 printf. Thus we normally steal a copy of the "printf.c" 1617c478bd9Sstevel@tonic-gate * and "strout" code from the standard i/o library and mung it for our 1627c478bd9Sstevel@tonic-gate * purposes to avoid dragging in the stdio library headers, etc if we 1637c478bd9Sstevel@tonic-gate * are not debugging. Such a modified printf exists in "printf.c" here. 1647c478bd9Sstevel@tonic-gate */ 1657c478bd9Sstevel@tonic-gate #ifdef TRACE 1667c478bd9Sstevel@tonic-gate #include <stdio.h> 1677c478bd9Sstevel@tonic-gate var FILE *trace; 1687c478bd9Sstevel@tonic-gate var bool trubble; 1697c478bd9Sstevel@tonic-gate var bool techoin; 1707c478bd9Sstevel@tonic-gate var unsigned char tracbuf[BUFSIZ]; 1717c478bd9Sstevel@tonic-gate #undef putchar 1727c478bd9Sstevel@tonic-gate #undef getchar 1737c478bd9Sstevel@tonic-gate #else 1747c478bd9Sstevel@tonic-gate /* 1757c478bd9Sstevel@tonic-gate * Warning: do not change BUFSIZ without also changing LBSIZE in ex_tune.h 1767c478bd9Sstevel@tonic-gate * Running with BUFSIZ set to anything besides what is in <stdio.h> is 1777c478bd9Sstevel@tonic-gate * not recommended, if you use stdio. 1787c478bd9Sstevel@tonic-gate */ 1797c478bd9Sstevel@tonic-gate #ifdef u370 1807c478bd9Sstevel@tonic-gate #define BUFSIZE 4096 1817c478bd9Sstevel@tonic-gate #else 1827c478bd9Sstevel@tonic-gate #define BUFSIZE (LINE_MAX*2) 1837c478bd9Sstevel@tonic-gate #endif 1847c478bd9Sstevel@tonic-gate #undef NULL 1857c478bd9Sstevel@tonic-gate #define NULL 0 1867c478bd9Sstevel@tonic-gate #undef EOF 1877c478bd9Sstevel@tonic-gate #define EOF -1 1887c478bd9Sstevel@tonic-gate #endif 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate /* 1917c478bd9Sstevel@tonic-gate * Character constants and bits 1927c478bd9Sstevel@tonic-gate * 1937c478bd9Sstevel@tonic-gate * The editor uses the QUOTE bit as a flag to pass on with characters 1947c478bd9Sstevel@tonic-gate * e.g. to the putchar routine. The editor never uses a simple char variable. 1957c478bd9Sstevel@tonic-gate * Only arrays of and pointers to characters are used and parameters and 1967c478bd9Sstevel@tonic-gate * registers are never declared character. 1977c478bd9Sstevel@tonic-gate */ 1987c478bd9Sstevel@tonic-gate #define QUOTE 020000000000 1997c478bd9Sstevel@tonic-gate #define TRIM 017777777777 2007c478bd9Sstevel@tonic-gate #define NL '\n' 2017c478bd9Sstevel@tonic-gate #define CR '\r' 2027c478bd9Sstevel@tonic-gate #define DELETE 0177 /* See also ATTN, QUIT in ex_tune.h */ 2037c478bd9Sstevel@tonic-gate #define ESCAPE 033 2047c478bd9Sstevel@tonic-gate #undef CTRL 2057c478bd9Sstevel@tonic-gate #define CTRL(c) (c & 037) 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate /* 2087c478bd9Sstevel@tonic-gate * Miscellaneous random variables used in more than one place 2097c478bd9Sstevel@tonic-gate */ 2107c478bd9Sstevel@tonic-gate var bool multibyte; 2117c478bd9Sstevel@tonic-gate var bool aiflag; /* Append/change/insert with autoindent */ 21268c92b9fScf46844 var bool tagflg; /* set for -t option and :tag command */ 2137c478bd9Sstevel@tonic-gate var bool anymarks; /* We have used '[a-z] */ 2147c478bd9Sstevel@tonic-gate var int chng; /* Warn "No write" */ 2157c478bd9Sstevel@tonic-gate var unsigned char *Command; 2167c478bd9Sstevel@tonic-gate var short defwind; /* -w# change default window size */ 2177c478bd9Sstevel@tonic-gate var int dirtcnt; /* When >= MAXDIRT, should sync temporary */ 2187c478bd9Sstevel@tonic-gate #ifdef SIGTSTP 2197c478bd9Sstevel@tonic-gate var bool dosusp; /* Do SIGTSTP in visual when ^Z typed */ 2207c478bd9Sstevel@tonic-gate #endif 2217c478bd9Sstevel@tonic-gate var bool edited; /* Current file is [Edited] */ 2227c478bd9Sstevel@tonic-gate var line *endcore; /* Last available core location */ 2237c478bd9Sstevel@tonic-gate extern bool endline; /* Last cmd mode command ended with \n */ 2247c478bd9Sstevel@tonic-gate var line *fendcore; /* First address in line pointer space */ 2257c478bd9Sstevel@tonic-gate var unsigned char file[FNSIZE]; /* Working file name */ 2267c478bd9Sstevel@tonic-gate var unsigned char genbuf[LBSIZE]; /* Working buffer when manipulating linebuf */ 2277c478bd9Sstevel@tonic-gate var bool hush; /* Command line option - was given, hush up! */ 2287c478bd9Sstevel@tonic-gate var unsigned char *globp; /* (Untyped) input string to command mode */ 2297c478bd9Sstevel@tonic-gate var bool holdcm; /* Don't cursor address */ 2307c478bd9Sstevel@tonic-gate var bool inappend; /* in ex command append mode */ 2317c478bd9Sstevel@tonic-gate var bool inglobal; /* Inside g//... or v//... */ 2327c478bd9Sstevel@tonic-gate var unsigned char *initev; /* Initial : escape for visual */ 2337c478bd9Sstevel@tonic-gate var bool inopen; /* Inside open or visual */ 2347c478bd9Sstevel@tonic-gate var unsigned char *input; /* Current position in cmd line input buffer */ 2357c478bd9Sstevel@tonic-gate var bool intty; /* Input is a tty */ 2367c478bd9Sstevel@tonic-gate var short io; /* General i/o unit (auto-closed on error!) */ 2377c478bd9Sstevel@tonic-gate extern short lastc; /* Last character ret'd from cmd input */ 2387c478bd9Sstevel@tonic-gate var bool laste; /* Last command was an "e" (or "rec") */ 2397c478bd9Sstevel@tonic-gate var unsigned char lastmac; /* Last macro called for ** */ 2407c478bd9Sstevel@tonic-gate var unsigned char lasttag[TAGSIZE]; /* Last argument to a tag command */ 2417c478bd9Sstevel@tonic-gate var unsigned char *linebp; /* Used in substituting in \n */ 2427c478bd9Sstevel@tonic-gate var unsigned char linebuf[LBSIZE]; /* The primary line buffer */ 2437c478bd9Sstevel@tonic-gate var bool listf; /* Command should run in list mode */ 2447c478bd9Sstevel@tonic-gate var line names['z'-'a'+2]; /* Mark registers a-z,' */ 2457c478bd9Sstevel@tonic-gate var int notecnt; /* Count for notify (to visual from cmd) */ 2467c478bd9Sstevel@tonic-gate var bool numberf; /* Command should run in number mode */ 2477c478bd9Sstevel@tonic-gate var unsigned char obuf[BUFSIZE]; /* Buffer for tty output */ 2487c478bd9Sstevel@tonic-gate var short oprompt; /* Saved during source */ 2497c478bd9Sstevel@tonic-gate var short ospeed; /* Output speed (from gtty) */ 2507c478bd9Sstevel@tonic-gate var int otchng; /* Backup tchng to find changes in macros */ 2517c478bd9Sstevel@tonic-gate var int peekc; /* Peek ahead character (cmd mode input) */ 2527c478bd9Sstevel@tonic-gate var unsigned char *pkill[2]; /* Trim for put with ragged (LISP) delete */ 2537c478bd9Sstevel@tonic-gate var bool pfast; /* Have stty -nl'ed to go faster */ 2547c478bd9Sstevel@tonic-gate var pid_t pid; /* Process id of child */ 2557c478bd9Sstevel@tonic-gate var pid_t ppid; /* Process id of parent (e.g. main ex proc) */ 2567c478bd9Sstevel@tonic-gate var jmp_buf resetlab; /* For error throws to top level (cmd mode) */ 2577c478bd9Sstevel@tonic-gate var pid_t rpid; /* Pid returned from wait() */ 2587c478bd9Sstevel@tonic-gate var bool ruptible; /* Interruptible is normal state */ 2597c478bd9Sstevel@tonic-gate var bool seenprompt; /* 1 if have gotten user input */ 2607c478bd9Sstevel@tonic-gate var bool shudclob; /* Have a prompt to clobber (e.g. on ^D) */ 2617c478bd9Sstevel@tonic-gate var int status; /* Status returned from wait() */ 2627c478bd9Sstevel@tonic-gate var int tchng; /* If nonzero, then [Modified] */ 2637c478bd9Sstevel@tonic-gate extern short tfile; /* Temporary file unit */ 2647c478bd9Sstevel@tonic-gate var bool vcatch; /* Want to catch an error (open/visual) */ 2657c478bd9Sstevel@tonic-gate var jmp_buf vreslab; /* For error throws to a visual catch */ 2667c478bd9Sstevel@tonic-gate var bool writing; /* 1 if in middle of a file write */ 2677c478bd9Sstevel@tonic-gate var int xchng; /* Suppresses multiple "No writes" in !cmd */ 2687c478bd9Sstevel@tonic-gate #ifndef PRESUNEUC 2697c478bd9Sstevel@tonic-gate var char mc_filler; /* Right margin filler for multicolumn char */ 2707c478bd9Sstevel@tonic-gate var bool mc_wrap; /* Multicolumn character wrap at right margin */ 2717c478bd9Sstevel@tonic-gate #endif /* PRESUNEUC */ 2727c478bd9Sstevel@tonic-gate var int inexrc; /* boolean: in .exrc initialization */ 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate extern int termiosflag; /* flag for using termios */ 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate /* 2777c478bd9Sstevel@tonic-gate * Macros 2787c478bd9Sstevel@tonic-gate */ 2797c478bd9Sstevel@tonic-gate #define CP(a, b) ((void)strcpy(a, b)) 2807c478bd9Sstevel@tonic-gate /* 2817c478bd9Sstevel@tonic-gate * FIXUNDO: do we want to mung undo vars? 2827c478bd9Sstevel@tonic-gate * Usually yes unless in a macro or global. 2837c478bd9Sstevel@tonic-gate */ 2847c478bd9Sstevel@tonic-gate #define FIXUNDO (inopen >= 0 && (inopen || !inglobal)) 2857c478bd9Sstevel@tonic-gate #define ckaw() {if (chng && value(vi_AUTOWRITE) && !value(vi_READONLY)) \ 2867c478bd9Sstevel@tonic-gate wop(0);\ 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate #define copy(a,b,c) Copy((char *) (a), (char *) (b), (c)) 2897c478bd9Sstevel@tonic-gate #define eq(a, b) ((a) && (b) && strcmp(a, b) == 0) 2907c478bd9Sstevel@tonic-gate #define getexit(a) copy(a, resetlab, sizeof (jmp_buf)) 2917c478bd9Sstevel@tonic-gate #define lastchar() lastc 2927c478bd9Sstevel@tonic-gate #define outchar(c) (*Outchar)(c) 2937c478bd9Sstevel@tonic-gate #define pastwh() ((void)skipwh()) 2947c478bd9Sstevel@tonic-gate #define pline(no) (*Pline)(no) 2957c478bd9Sstevel@tonic-gate #define reset() longjmp(resetlab,1) 2967c478bd9Sstevel@tonic-gate #define resexit(a) copy(resetlab, a, sizeof (jmp_buf)) 2977c478bd9Sstevel@tonic-gate #define setexit() setjmp(resetlab) 2987c478bd9Sstevel@tonic-gate #define setlastchar(c) lastc = c 2997c478bd9Sstevel@tonic-gate #define ungetchar(c) peekc = c 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate #define CATCH vcatch = 1; if (setjmp(vreslab) == 0) { 3027c478bd9Sstevel@tonic-gate #define ONERR } else { vcatch = 0; 3037c478bd9Sstevel@tonic-gate #define ENDCATCH } vcatch = 0; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate /* 3067c478bd9Sstevel@tonic-gate * Environment like memory 3077c478bd9Sstevel@tonic-gate */ 3087c478bd9Sstevel@tonic-gate var unsigned char altfile[FNSIZE]; /* Alternate file name */ 3097c478bd9Sstevel@tonic-gate extern unsigned char direct[ONMSZ]; /* Temp file goes here */ 3107c478bd9Sstevel@tonic-gate extern unsigned char shell[ONMSZ]; /* Copied to be settable */ 3117c478bd9Sstevel@tonic-gate var unsigned char uxb[UXBSIZE + 2]; /* Last !command for !! */ 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* 3147c478bd9Sstevel@tonic-gate * The editor data structure for accessing the current file consists 3157c478bd9Sstevel@tonic-gate * of an incore array of pointers into the temporary file tfile. 3167c478bd9Sstevel@tonic-gate * Each pointer is 15 bits (the low bit is used by global) and is 3177c478bd9Sstevel@tonic-gate * padded with zeroes to make an index into the temp file where the 3187c478bd9Sstevel@tonic-gate * actual text of the line is stored. 3197c478bd9Sstevel@tonic-gate * 3207c478bd9Sstevel@tonic-gate * To effect undo, copies of affected lines are saved after the last 3217c478bd9Sstevel@tonic-gate * line considered to be in the buffer, between dol and unddol. 3227c478bd9Sstevel@tonic-gate * During an open or visual, which uses the command mode undo between 3237c478bd9Sstevel@tonic-gate * dol and unddol, a copy of the entire, pre-command buffer state 3247c478bd9Sstevel@tonic-gate * is saved between unddol and truedol. 3257c478bd9Sstevel@tonic-gate */ 3267c478bd9Sstevel@tonic-gate var line *addr1; /* First addressed line in a command */ 3277c478bd9Sstevel@tonic-gate var line *addr2; /* Second addressed line */ 3287c478bd9Sstevel@tonic-gate var line *dol; /* Last line in buffer */ 3297c478bd9Sstevel@tonic-gate var line *dot; /* Current line */ 3307c478bd9Sstevel@tonic-gate var line *one; /* First line */ 3317c478bd9Sstevel@tonic-gate var line *truedol; /* End of all lines, including saves */ 3327c478bd9Sstevel@tonic-gate var line *unddol; /* End of undo saved lines */ 3337c478bd9Sstevel@tonic-gate var line *zero; /* Points to empty slot before one */ 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate /* 3367c478bd9Sstevel@tonic-gate * Undo information 3377c478bd9Sstevel@tonic-gate * 3387c478bd9Sstevel@tonic-gate * For most commands we save lines changed by salting them away between 3397c478bd9Sstevel@tonic-gate * dol and unddol before they are changed (i.e. we save the descriptors 3407c478bd9Sstevel@tonic-gate * into the temp file tfile which is never garbage collected). The 3417c478bd9Sstevel@tonic-gate * lines put here go back after unddel, and to complete the undo 3427c478bd9Sstevel@tonic-gate * we delete the lines [undap1,undap2). 3437c478bd9Sstevel@tonic-gate * 3447c478bd9Sstevel@tonic-gate * Undoing a move is much easier and we treat this as a special case. 3457c478bd9Sstevel@tonic-gate * Similarly undoing a "put" is a special case for although there 3467c478bd9Sstevel@tonic-gate * are lines saved between dol and unddol we don't stick these back 3477c478bd9Sstevel@tonic-gate * into the buffer. 3487c478bd9Sstevel@tonic-gate */ 3497c478bd9Sstevel@tonic-gate var short undkind; 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate var line *unddel; /* Saved deleted lines go after here */ 3527c478bd9Sstevel@tonic-gate var line *undap1; /* Beginning of new lines */ 3537c478bd9Sstevel@tonic-gate var line *undap2; /* New lines end before undap2 */ 3547c478bd9Sstevel@tonic-gate var line *undadot; /* If we saved all lines, dot reverts here */ 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate #define UNDCHANGE 0 3577c478bd9Sstevel@tonic-gate #define UNDMOVE 1 3587c478bd9Sstevel@tonic-gate #define UNDALL 2 3597c478bd9Sstevel@tonic-gate #define UNDNONE 3 3607c478bd9Sstevel@tonic-gate #define UNDPUT 4 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate /* 3637c478bd9Sstevel@tonic-gate * Various miscellaneous flags and buffers needed by the encryption routines. 3647c478bd9Sstevel@tonic-gate */ 3657c478bd9Sstevel@tonic-gate #define KSIZE 9 /* key size for encryption */ 3667c478bd9Sstevel@tonic-gate var int xflag; /* True if we are in encryption mode */ 3677c478bd9Sstevel@tonic-gate var int xtflag; /* True if the temp file is being encrypted */ 3687c478bd9Sstevel@tonic-gate var int kflag; /* True if the key has been accepted */ 3697c478bd9Sstevel@tonic-gate var int crflag; /* True if the key has been accepted and the file 3707c478bd9Sstevel@tonic-gate being read is ciphertext 3717c478bd9Sstevel@tonic-gate */ 3727c478bd9Sstevel@tonic-gate var int perm[2]; /* pipe connection to crypt for file being edited */ 3737c478bd9Sstevel@tonic-gate var int tperm[2]; /* pipe connection to crypt for temporary file */ 3747c478bd9Sstevel@tonic-gate var int permflag; 3757c478bd9Sstevel@tonic-gate var int tpermflag; 3767c478bd9Sstevel@tonic-gate var unsigned char *key; 3777c478bd9Sstevel@tonic-gate var unsigned char crbuf[CRSIZE]; 3787c478bd9Sstevel@tonic-gate char *getpass(); 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate var bool write_quit; /* True if executing a 'wq' command */ 3817c478bd9Sstevel@tonic-gate var int errcnt; /* number of error/warning messages in */ 3827c478bd9Sstevel@tonic-gate /* editing session (global flag) */ 3837c478bd9Sstevel@tonic-gate /* 3847c478bd9Sstevel@tonic-gate * Function type definitions 3857c478bd9Sstevel@tonic-gate */ 3867c478bd9Sstevel@tonic-gate #define NOSTR (char *) 0 3877c478bd9Sstevel@tonic-gate #define NOLINE (line *) 0 3887c478bd9Sstevel@tonic-gate 389f6db9f27Scf46844 #define setterm visetterm 390f6db9f27Scf46844 #define draino vidraino 391f6db9f27Scf46844 #define gettmode vigettmode 392f6db9f27Scf46844 3937c478bd9Sstevel@tonic-gate extern int (*Outchar)(); 3947c478bd9Sstevel@tonic-gate extern int (*Pline)(); 3957c478bd9Sstevel@tonic-gate extern int (*Putchar)(); 3967c478bd9Sstevel@tonic-gate var void (*oldhup)(); 3977c478bd9Sstevel@tonic-gate int (*setlist())(); 3987c478bd9Sstevel@tonic-gate int (*setnorm())(); 3997c478bd9Sstevel@tonic-gate int (*setnorm())(); 4007c478bd9Sstevel@tonic-gate int (*setnumb())(); 4017c478bd9Sstevel@tonic-gate #ifndef PRESUNEUC 4027c478bd9Sstevel@tonic-gate int (*wdwc)(wchar_t); /* tells kind of word character */ 4037c478bd9Sstevel@tonic-gate int (*wdbdg)(wchar_t, wchar_t, int); /* tells word binding force */ 4047c478bd9Sstevel@tonic-gate wchar_t *(*wddlm)(wchar_t, wchar_t, int); /* tells desired delimiter */ 4057c478bd9Sstevel@tonic-gate wchar_t (*mcfllr)(void); /* tells multicolumn filler character */ 4067c478bd9Sstevel@tonic-gate #endif /* PRESUNEUC */ 4077c478bd9Sstevel@tonic-gate line *address(); 4087c478bd9Sstevel@tonic-gate unsigned char *cgoto(); 4097c478bd9Sstevel@tonic-gate unsigned char *genindent(); 4107c478bd9Sstevel@tonic-gate unsigned char *getblock(); 4117c478bd9Sstevel@tonic-gate char *getenv(); 4127c478bd9Sstevel@tonic-gate line *getmark(); 4137c478bd9Sstevel@tonic-gate unsigned char *mesg(); 4147c478bd9Sstevel@tonic-gate unsigned char *place(); 4157c478bd9Sstevel@tonic-gate unsigned char *plural(); 4167c478bd9Sstevel@tonic-gate line *scanfor(); 417f6db9f27Scf46844 void setin(line *); 4187c478bd9Sstevel@tonic-gate unsigned char *strend(); 4197c478bd9Sstevel@tonic-gate unsigned char *tailpath(); 4207c478bd9Sstevel@tonic-gate char *tgetstr(); 4217c478bd9Sstevel@tonic-gate char *tgoto(); 4227c478bd9Sstevel@tonic-gate char *ttyname(); 4237c478bd9Sstevel@tonic-gate line *vback(); 4247c478bd9Sstevel@tonic-gate unsigned char *vfindcol(); 4257c478bd9Sstevel@tonic-gate unsigned char *vgetline(); 4267c478bd9Sstevel@tonic-gate unsigned char *vinit(); 4277c478bd9Sstevel@tonic-gate unsigned char *vpastwh(); 4287c478bd9Sstevel@tonic-gate unsigned char *vskipwh(); 429f6db9f27Scf46844 int put(void); 430f6db9f27Scf46844 int putreg(unsigned char); 431f6db9f27Scf46844 int YANKreg(int); 432f6db9f27Scf46844 int delete(bool); 4337c478bd9Sstevel@tonic-gate int vi_filter(); 4347c478bd9Sstevel@tonic-gate int getfile(); 4357c478bd9Sstevel@tonic-gate int getsub(); 4367c478bd9Sstevel@tonic-gate int gettty(); 437f6db9f27Scf46844 int join(int); 438f6db9f27Scf46844 int listchar(wchar_t); 439f6db9f27Scf46844 int normchar(wchar_t); 440f6db9f27Scf46844 int normline(void); 441f6db9f27Scf46844 int numbline(int); 4427c478bd9Sstevel@tonic-gate var void (*oldquit)(); 443*0f1f7826SRichard Lowe 4447c478bd9Sstevel@tonic-gate void onhup(int); 4457c478bd9Sstevel@tonic-gate void onintr(int); 4467c478bd9Sstevel@tonic-gate void oncore(int); 4477c478bd9Sstevel@tonic-gate #ifdef CBREAK 4487c478bd9Sstevel@tonic-gate void vintr(int); 4497c478bd9Sstevel@tonic-gate #endif 4507c478bd9Sstevel@tonic-gate void onsusp(int); 4517c478bd9Sstevel@tonic-gate int putch(char); 4527c478bd9Sstevel@tonic-gate int plodput(char); 4537c478bd9Sstevel@tonic-gate int vputch(char); 4547c478bd9Sstevel@tonic-gate 455f6db9f27Scf46844 void shift(int, int); 456f6db9f27Scf46844 int termchar(wchar_t); 4577c478bd9Sstevel@tonic-gate int vfilter(); 4587c478bd9Sstevel@tonic-gate int vshftop(); 459f6db9f27Scf46844 int yank(void); 4607c478bd9Sstevel@tonic-gate unsigned char *lastchr(); 4617c478bd9Sstevel@tonic-gate unsigned char *nextchr(); 4627c478bd9Sstevel@tonic-gate bool putoctal; 463f6db9f27Scf46844 464f6db9f27Scf46844 void error(); 465f6db9f27Scf46844 void error0(void); 466f6db9f27Scf46844 void error1(unsigned char *); 467f6db9f27Scf46844 void fixol(void); 468f6db9f27Scf46844 void resetflav(void); 469f6db9f27Scf46844 void serror(unsigned char *, unsigned char *); 470f6db9f27Scf46844 void setflav(void); 471f6db9f27Scf46844 void tailprim(unsigned char *, int, bool); 472f6db9f27Scf46844 void vcontin(bool); 473f6db9f27Scf46844 void squish(void); 474f6db9f27Scf46844 void move1(int, line *); 475f6db9f27Scf46844 void pragged(bool); 476f6db9f27Scf46844 void zop2(int, int); 477f6db9f27Scf46844 void plines(line *, line *, bool); 478f6db9f27Scf46844 void pofix(void); 479f6db9f27Scf46844 void undo(bool); 480f6db9f27Scf46844 void somechange(void); 481f6db9f27Scf46844 void savetag(char *); 482f6db9f27Scf46844 void unsavetag(void); 483f6db9f27Scf46844 void checkjunk(unsigned char); 484f6db9f27Scf46844 void getone(void); 485f6db9f27Scf46844 void rop3(int); 486f6db9f27Scf46844 void rop2(void); 487f6db9f27Scf46844 void putfile(int); 488f6db9f27Scf46844 void wrerror(void); 489f6db9f27Scf46844 void clrstats(void); 490f6db9f27Scf46844 void slobber(int); 491f6db9f27Scf46844 void flush(void); 492f6db9f27Scf46844 void flush1(void); 493f6db9f27Scf46844 void flush2(void); 494f6db9f27Scf46844 void fgoto(void); 495f6db9f27Scf46844 void flusho(void); 496f6db9f27Scf46844 void comprhs(int); 497f6db9f27Scf46844 int dosubcon(bool, line *); 498f6db9f27Scf46844 void ugo(int, int); 499f6db9f27Scf46844 void dosub(void); 500f6db9f27Scf46844 void snote(int, int); 501f6db9f27Scf46844 void cerror(unsigned char *); 502f6db9f27Scf46844 void unterm(void); 503f6db9f27Scf46844 int setend(void); 504f6db9f27Scf46844 void prall(void); 505f6db9f27Scf46844 void propts(void); 506f6db9f27Scf46844 void propt(struct option *); 507f6db9f27Scf46844 void killcnt(int); 508f6db9f27Scf46844 void markpr(line *); 509f6db9f27Scf46844 void merror1(unsigned char *); 510f6db9f27Scf46844 void notempty(void); 511f6db9f27Scf46844 int qcolumn(unsigned char *, unsigned char *); 512f6db9f27Scf46844 void netchange(int); 513f6db9f27Scf46844 void putmk1(line *, int); 514f6db9f27Scf46844 int nqcolumn(unsigned char *, unsigned char *); 515f6db9f27Scf46844 void syserror(int); 516f6db9f27Scf46844 void cleanup(bool); 517f6db9f27Scf46844 void blkio(short, unsigned char *, int (*)()); 518f6db9f27Scf46844 void tflush(void); 519f6db9f27Scf46844 short partreg(unsigned char); 520f6db9f27Scf46844 void kshift(void); 521f6db9f27Scf46844 void YANKline(void); 522f6db9f27Scf46844 void rbflush(void); 523f6db9f27Scf46844 void waitfor(void); 524f6db9f27Scf46844 void ovbeg(void); 525f6db9f27Scf46844 void fixzero(void); 526f6db9f27Scf46844 void savevis(void); 527f6db9f27Scf46844 void undvis(void); 528f6db9f27Scf46844 void setwind(void); 529f6db9f27Scf46844 void vok(wchar_t *, int); 530f6db9f27Scf46844 void vsetsiz(int); 531f6db9f27Scf46844 void vinslin(int, int, int); 532f6db9f27Scf46844 void vopenup(int, bool, int); 533f6db9f27Scf46844 void vadjAL(int, int); 534f6db9f27Scf46844 void vup1(void); 535f6db9f27Scf46844 void vmoveitup(int, bool); 536f6db9f27Scf46844 void vscroll(int); 537f6db9f27Scf46844 void vscrap(void); 538f6db9f27Scf46844 void vredraw(int); 539f6db9f27Scf46844 void vdellin(int, int, int); 540f6db9f27Scf46844 void vadjDL(int, int); 541f6db9f27Scf46844 void vsyncCL(void); 542f6db9f27Scf46844 void vsync(int); 543f6db9f27Scf46844 void vsync1(int); 544f6db9f27Scf46844 void vcloseup(int, int); 545f6db9f27Scf46844 void sethard(void); 546f6db9f27Scf46844 void vdirty(int, int); 547f6db9f27Scf46844 void setBUF(unsigned char *); 548f6db9f27Scf46844 void addto(unsigned char *, unsigned char *); 549f6db9f27Scf46844 void macpush(); 550f6db9f27Scf46844 void setalarm(void); 551f6db9f27Scf46844 void cancelalarm(void); 552f6db9f27Scf46844 void grabtag(void); 553f6db9f27Scf46844 void prepapp(void); 554f6db9f27Scf46844 void vremote(); 555f6db9f27Scf46844 void vsave(void); 556f6db9f27Scf46844 void vzop(bool, int, int); 557f6db9f27Scf46844 void warnf(); 558f6db9f27Scf46844 int wordof(unsigned char, unsigned char *); 559f6db9f27Scf46844 void setpk(void); 560f6db9f27Scf46844 void back1(void); 561f6db9f27Scf46844 void vdoappend(unsigned char *); 562f6db9f27Scf46844 void vclrbyte(wchar_t *, int); 563f6db9f27Scf46844 void vclreol(void); 564f6db9f27Scf46844 void vsetcurs(unsigned char *); 565f6db9f27Scf46844 void vigoto(int, int); 566f6db9f27Scf46844 void vcsync(void); 567f6db9f27Scf46844 void vgotoCL(int); 568f6db9f27Scf46844 void vgoto(int, int); 569f6db9f27Scf46844 void vmaktop(int, wchar_t *); 570f6db9f27Scf46844 void vrigid(void); 571f6db9f27Scf46844 void vneedpos(int); 572f6db9f27Scf46844 void vnpins(int); 573f6db9f27Scf46844 void vishft(void); 574f6db9f27Scf46844 void viin(wchar_t); 575f6db9f27Scf46844 void godm(void); 576f6db9f27Scf46844 void enddm(void); 577f6db9f27Scf46844 void goim(void); 578f6db9f27Scf46844 void endim(void); 579f6db9f27Scf46844 void vjumpto(line *, unsigned char *, unsigned char); 580f6db9f27Scf46844 void vup(int, int, bool); 581f6db9f27Scf46844 void vdown(int, int, bool); 582f6db9f27Scf46844 void vcontext(line *, unsigned char); 583f6db9f27Scf46844 void vclean(void); 584f6db9f27Scf46844 void vshow(line *, line*); 585f6db9f27Scf46844 void vreset(bool); 586f6db9f27Scf46844 void vroll(int); 587f6db9f27Scf46844 void vrollR(int); 588f6db9f27Scf46844 void vnline(unsigned char *); 589f6db9f27Scf46844 void noerror(); 59023a1cceaSRoger A. Faulkner void getaline(line); 591f6db9f27Scf46844 void viprintf(); 592f6db9f27Scf46844 void gettmode(void); 593f6db9f27Scf46844 void setterm(unsigned char *); 594f6db9f27Scf46844 void draino(void); 595f6db9f27Scf46844 int lfind(); 596f6db9f27Scf46844 void source(); 597f6db9f27Scf46844 void commands(); 598f6db9f27Scf46844 void addmac(); 5993a5240e9Scf46844 void vmoveto(); 6003a5240e9Scf46844 void vrepaint(); 6013a5240e9Scf46844 void getDOT(void); 6023a5240e9Scf46844 void vclear(void); 603f6db9f27Scf46844 6047c478bd9Sstevel@tonic-gate unsigned char *lastchr(); 6057c478bd9Sstevel@tonic-gate unsigned char *nextchr(); 6067c478bd9Sstevel@tonic-gate bool putoctal; 607ace1a5f1Sdp 608f6db9f27Scf46844 void setdot1(void); 609f6db9f27Scf46844 610ace1a5f1Sdp #ifdef __cplusplus 611ace1a5f1Sdp } 612ace1a5f1Sdp #endif 613ace1a5f1Sdp 614ace1a5f1Sdp #endif /* _EX_H */ 615