Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / common / gs.h
blob4289af603f89b19a0d5a5d63617813476800ae66
1 /* $NetBSD: gs.h,v 1.3 2013/11/25 22:43:46 christos Exp $ */
2 /*-
3 * Copyright (c) 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
10 * Id: gs.h,v 10.55 2001/11/01 10:28:25 skimo Exp (Berkeley) Date: 2001/11/01 10:28:25
13 #define TEMPORARY_FILE_STRING "/tmp" /* Default temporary file name. */
16 * File reference structure (FREF). The structure contains the name of the
17 * file, along with the information that follows the name.
19 * !!!
20 * The read-only bit follows the file name, not the file itself.
22 struct _fref {
23 TAILQ_ENTRY(_fref) q; /* Linked list of file references. */
24 char *name; /* File name. */
25 char *tname; /* Backing temporary file name. */
27 db_recno_t lno; /* 1-N: file cursor line. */
28 size_t cno; /* 0-N: file cursor column. */
30 #define FR_CURSORSET 0x0001 /* If lno/cno values valid. */
31 #define FR_DONTDELETE 0x0002 /* Don't delete the temporary file. */
32 #define FR_EXNAMED 0x0004 /* Read/write renamed the file. */
33 #define FR_NAMECHANGE 0x0008 /* If the name changed. */
34 #define FR_NEWFILE 0x0010 /* File doesn't really exist yet. */
35 #define FR_RECOVER 0x0020 /* File is being recovered. */
36 #define FR_TMPEXIT 0x0040 /* Modified temporary file, no exit. */
37 #define FR_TMPFILE 0x0080 /* If file has no name. */
38 #define FR_UNLOCKED 0x0100 /* File couldn't be locked. */
39 u_int16_t flags;
42 /* Action arguments to scr_exadjust(). */
43 typedef enum { EX_TERM_CE, EX_TERM_SCROLL } exadj_t;
45 /* Screen attribute arguments to scr_attr(). */
46 typedef enum { SA_ALTERNATE, SA_INVERSE } scr_attr_t;
48 /* Key type arguments to scr_keyval(). */
49 typedef enum { KEY_VEOF, KEY_VERASE, KEY_VKILL, KEY_VWERASE } scr_keyval_t;
52 * GS:
54 * Structure that describes global state of the running program.
56 struct _gs {
57 char *progname; /* Programe name. */
59 int id; /* Last allocated screen id. */
60 TAILQ_HEAD(_dqh, _win) dq; /* Displayed windows. */
61 TAILQ_HEAD(_hqh, _scr) hq; /* Hidden screens. */
63 void *perl_interp; /* Perl interpreter. */
64 void *tcl_interp; /* Tcl_Interp *: Tcl interpreter. */
66 void *cl_private; /* Curses support private area. */
67 void *tk_private; /* Tk/Tcl support private area. */
69 /* File references. */
70 TAILQ_HEAD(_frefh, _fref) frefq;
71 /* File structures. */
72 TAILQ_HEAD(_exfh, _exf) exfq;
74 #define GO_COLUMNS 0 /* Global options: columns. */
75 #define GO_LINES 1 /* Global options: lines. */
76 #define GO_SECURE 2 /* Global options: secure. */
77 #define GO_TERM 3 /* Global options: terminal type. */
78 OPTION opts[GO_TERM + 1];
80 DB *msg; /* Message catalog DB. */
81 MSGH msgq; /* User message list. */
82 #define DEFAULT_NOPRINT '\1' /* Emergency non-printable character. */
83 int noprint; /* Cached, unprintable character. */
85 char *c_option; /* Ex initial, command-line command. */
87 #ifdef DEBUG
88 FILE *tracefp; /* Trace file pointer. */
89 #endif
91 #define MAX_BIT_SEQ 0x7f /* Max + 1 fast check character. */
92 LIST_HEAD(_seqh, _seq) seqq; /* Linked list of maps, abbrevs. */
93 bitstr_t bit_decl(seqb, MAX_BIT_SEQ + 1);
95 #define MAX_FAST_KEY 0xff /* Max fast check character.*/
96 #define KEY_LEN(sp, ch) \
97 (((ch) & ~MAX_FAST_KEY) == 0 ? \
98 sp->gp->cname[(unsigned char)ch].len : v_key_len(sp, ch))
99 #define KEY_NAME(sp, ch) \
100 (((ch) & ~MAX_FAST_KEY) == 0 ? \
101 sp->gp->cname[(unsigned char)ch].name : v_key_name(sp, ch))
102 struct {
103 u_char name[MAX_CHARACTER_COLUMNS + 1];
104 u_int8_t len;
105 } cname[MAX_FAST_KEY + 1]; /* Fast lookup table. */
107 #define KEY_VAL(sp, ch) \
108 (((ch) & ~MAX_FAST_KEY) == 0 ? \
109 sp->gp->special_key[(unsigned char)ch] : v_key_val(sp,ch))
110 e_key_t /* Fast lookup table. */
111 special_key[MAX_FAST_KEY + 1];
113 /* Flags. */
114 #define G_ABBREV 0x0001 /* If have abbreviations. */
115 #define G_BELLSCHED 0x0002 /* Bell scheduled. */
116 #define G_INTERRUPTED 0x0004 /* Interrupted. */
117 #define G_RECOVER_SET 0x0008 /* Recover system initialized. */
118 #define G_SCRIPTED 0x0010 /* Ex script session. */
119 #define G_SCRWIN 0x0020 /* Scripting windows running. */
120 #define G_SNAPSHOT 0x0040 /* Always snapshot files. */
121 #define G_SRESTART 0x0080 /* Screen restarted. */
122 u_int32_t flags;
124 /* Screen interface functions. */
125 /* Add a string to the screen. */
126 int (*scr_addstr) __P((SCR *, const char *, size_t));
127 /* Add a string to the screen. */
128 int (*scr_waddstr) __P((SCR *, const CHAR_T *, size_t));
129 /* Toggle a screen attribute. */
130 int (*scr_attr) __P((SCR *, scr_attr_t, int));
131 /* Terminal baud rate. */
132 int (*scr_baud) __P((SCR *, u_long *));
133 /* Beep/bell/flash the terminal. */
134 int (*scr_bell) __P((SCR *));
135 /* Display a busy message. */
136 void (*scr_busy) __P((SCR *, const char *, busy_t));
137 /* Prepare child. */
138 int (*scr_child) __P((SCR *));
139 /* Clear to the end of the line. */
140 int (*scr_clrtoeol) __P((SCR *));
141 /* Return the cursor location. */
142 int (*scr_cursor) __P((SCR *, size_t *, size_t *));
143 /* Delete a line. */
144 int (*scr_deleteln) __P((SCR *));
145 /* Discard a screen. */
146 int (*scr_discard) __P((SCR *, SCR **));
147 /* Get a keyboard event. */
148 int (*scr_event) __P((SCR *, EVENT *, u_int32_t, int));
149 /* Ex: screen adjustment routine. */
150 int (*scr_ex_adjust) __P((SCR *, exadj_t));
151 int (*scr_fmap) /* Set a function key. */
152 __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
153 /* Get terminal key value. */
154 int (*scr_keyval) __P((SCR *, scr_keyval_t, CHAR_T *, int *));
155 /* Insert a line. */
156 int (*scr_insertln) __P((SCR *));
157 /* Handle an option change. */
158 int (*scr_optchange) __P((SCR *, int, const char *, u_long *));
159 /* Move the cursor. */
160 int (*scr_move) __P((SCR *, size_t, size_t));
161 /* Refresh the screen. */
162 int (*scr_refresh) __P((SCR *, int));
163 /* Rename the file. */
164 int (*scr_rename) __P((SCR *, char *, int));
165 /* Reply to an event. */
166 int (*scr_reply) __P((SCR *, int, char *));
167 /* Set the screen type. */
168 int (*scr_screen) __P((SCR *, u_int32_t));
169 /* Split the screen. */
170 int (*scr_split) __P((SCR *, SCR *));
171 /* Suspend the editor. */
172 int (*scr_suspend) __P((SCR *, int *));
173 /* Print usage message. */
174 void (*scr_usage) __P((void));
176 /* Threading stuff */
177 void *th_private;
179 int (*run) __P((WIN *, void *(*)(void*), void *));
181 int (*lock_init) __P((WIN *, void **));
182 #define LOCK_INIT(wp,s) \
183 wp->gp->lock_init(wp, &s->lock)
184 int (*lock_try) __P((WIN *, void **));
185 #define LOCK_TRY(wp,s) \
186 wp->gp->lock_try(wp, &s->lock)
187 int (*lock_unlock) __P((WIN *, void **));
188 #define LOCK_UNLOCK(wp,s) \
189 wp->gp->lock_unlock(wp, &s->lock)
190 int (*lock_end) __P((WIN *, void **));
191 #define LOCK_END(wp,s) \
192 wp->gp->lock_end(wp, &s->lock)
196 * XXX
197 * Block signals if there are asynchronous events. Used to keep DB system calls
198 * from being interrupted and not restarted, as that will result in consistency
199 * problems. This should be handled by DB.
201 #ifdef BLOCK_SIGNALS
202 #include <signal.h>
203 extern sigset_t __sigblockset;
204 #define SIGBLOCK \
205 (void)sigprocmask(SIG_BLOCK, &__sigblockset, NULL)
206 #define SIGUNBLOCK \
207 (void)sigprocmask(SIG_UNBLOCK, &__sigblockset, NULL);
208 #else
209 #define SIGBLOCK
210 #define SIGUNBLOCK
211 #endif