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