| 1 | /*- |
| 2 | * Copyright (c) 1991, 1993 |
| 3 | * The Regents of the University of California. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. All advertising materials mentioning features or use of this software |
| 14 | * must display the following acknowledgement: |
| 15 | * This product includes software developed by the University of |
| 16 | * California, Berkeley and its contributors. |
| 17 | * 4. Neither the name of the University nor the names of its contributors |
| 18 | * may be used to endorse or promote products derived from this software |
| 19 | * without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 31 | * SUCH DAMAGE. |
| 32 | * |
| 33 | * @(#)vi.h 8.33 (Berkeley) 1/9/94 |
| 34 | */ |
| 35 | |
| 36 | /* System includes. */ |
| 37 | #include <queue.h> /* Required by screen.h. */ |
| 38 | #include <sys/time.h> /* Required by screen.h. */ |
| 39 | |
| 40 | #include <bitstring.h> /* Required by screen.h. */ |
| 41 | #include <limits.h> /* Required by screen.h. */ |
| 42 | #include <signal.h> /* Required by screen.h. */ |
| 43 | #include <stdio.h> /* Required by screen.h. */ |
| 44 | #include <termios.h> /* Required by gs.h. */ |
| 45 | |
| 46 | /* |
| 47 | * Required by screen.h. This is the first include that can pull |
| 48 | * in "compat.h". Should be after every other system include. |
| 49 | */ |
| 50 | #include <regex.h> |
| 51 | |
| 52 | /* |
| 53 | * Forward structure declarations. Not pretty, but the include files |
| 54 | * are far too interrelated for a clean solution. |
| 55 | */ |
| 56 | typedef struct _cb CB; |
| 57 | typedef struct _ch CH; |
| 58 | typedef struct _chname CHNAME; |
| 59 | typedef struct _excmdarg EXCMDARG; |
| 60 | typedef struct _exf EXF; |
| 61 | typedef struct _fref FREF; |
| 62 | typedef struct _gs GS; |
| 63 | typedef struct _ibuf IBUF; |
| 64 | typedef struct _mark MARK; |
| 65 | typedef struct _msg MSG; |
| 66 | typedef struct _option OPTION; |
| 67 | typedef struct _optlist OPTLIST; |
| 68 | typedef struct _scr SCR; |
| 69 | typedef struct _script SCRIPT; |
| 70 | typedef struct _seq SEQ; |
| 71 | typedef struct _tag TAG; |
| 72 | typedef struct _tagf TAGF; |
| 73 | typedef struct _text TEXT; |
| 74 | |
| 75 | /* |
| 76 | * Fundamental character types. |
| 77 | * |
| 78 | * CHAR_T An integral type that can hold any character. |
| 79 | * ARG_CHAR_T The type of a CHAR_T when passed as an argument using |
| 80 | * traditional promotion rules. It should also be able |
| 81 | * to be compared against any CHAR_T for equality without |
| 82 | * problems. |
| 83 | * MAX_CHAR_T The maximum value of any character. |
| 84 | * |
| 85 | * If no integral type can hold a character, don't even try the port. |
| 86 | */ |
| 87 | typedef u_char CHAR_T; |
| 88 | typedef u_int ARG_CHAR_T; |
| 89 | #define MAX_CHAR_T 0xff |
| 90 | |
| 91 | /* The maximum number of columns any character can take up on a screen. */ |
| 92 | #define MAX_CHARACTER_COLUMNS 4 |
| 93 | |
| 94 | /* |
| 95 | * Local includes. |
| 96 | */ |
| 97 | #include <db.h> /* Required by exf.h; includes compat.h. */ |
| 98 | |
| 99 | #include "search.h" /* Required by screen.h. */ |
| 100 | #include "args.h" /* Required by options.h. */ |
| 101 | #include "options.h" /* Required by screen.h. */ |
| 102 | #include "term.h" /* Required by screen.h. */ |
| 103 | |
| 104 | #include "msg.h" /* Required by gs.h. */ |
| 105 | #include "cut.h" /* Required by gs.h. */ |
| 106 | #include "gs.h" /* Required by screen.h. */ |
| 107 | #include "screen.h" /* Required by exf.h. */ |
| 108 | #include "mark.h" /* Required by exf.h. */ |
| 109 | #include "exf.h" |
| 110 | #include "log.h" |
| 111 | #include "mem.h" |
| 112 | |
| 113 | #if FWOPEN_NOT_AVAILABLE /* See PORT/clib/fwopen.c. */ |
| 114 | #define EXCOOKIE sp |
| 115 | int ex_fflush __P((SCR *)); |
| 116 | int ex_printf __P((SCR *, const char *, ...)); |
| 117 | FILE *fwopen __P((SCR *, void *)); |
| 118 | #else |
| 119 | #define EXCOOKIE sp->stdfp |
| 120 | #define ex_fflush fflush |
| 121 | #define ex_printf fprintf |
| 122 | #endif |
| 123 | |
| 124 | /* Macros to set/clear/test flags. */ |
| 125 | #define F_SET(p, f) (p)->flags |= (f) |
| 126 | #define F_CLR(p, f) (p)->flags &= ~(f) |
| 127 | #define F_ISSET(p, f) ((p)->flags & (f)) |
| 128 | |
| 129 | #define LF_INIT(f) flags = (f) |
| 130 | #define LF_SET(f) flags |= (f) |
| 131 | #define LF_CLR(f) flags &= ~(f) |
| 132 | #define LF_ISSET(f) (flags & (f)) |
| 133 | |
| 134 | /* |
| 135 | * XXX |
| 136 | * MIN/MAX have traditionally been in <sys/param.h>. Don't |
| 137 | * try to get them from there, it's just not worth the effort. |
| 138 | */ |
| 139 | #ifndef MAX |
| 140 | #define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) |
| 141 | #endif |
| 142 | #ifndef MIN |
| 143 | #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) |
| 144 | #endif |
| 145 | |
| 146 | /* Function prototypes that don't seem to belong anywhere else. */ |
| 147 | u_long baud_from_bval __P((SCR *)); |
| 148 | char *charname __P((SCR *, ARG_CHAR_T)); |
| 149 | void busy_off __P((SCR *)); |
| 150 | void busy_on __P((SCR *, int, char const *)); |
| 151 | int nonblank __P((SCR *, EXF *, recno_t, size_t *)); |
| 152 | void set_alt_name __P((SCR *, char *)); |
| 153 | int set_window_size __P((SCR *, u_int, int)); |
| 154 | int status __P((SCR *, EXF *, recno_t, int)); |
| 155 | char *tail __P((char *)); |
| 156 | CHAR_T *v_strdup __P((SCR *, CHAR_T *, size_t)); |
| 157 | |
| 158 | #ifdef DEBUG |
| 159 | void TRACE __P((SCR *, const char *, ...)); |
| 160 | #endif |
| 161 | |
| 162 | /* Digraphs (not currently real). */ |
| 163 | int digraph __P((SCR *, int, int)); |
| 164 | int digraph_init __P((SCR *)); |
| 165 | void digraph_save __P((SCR *, int)); |