2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
7 * $Id: screen.h,v 8.81 1993/12/29 09:51:24 bostic Exp $ (Berkeley) $Date: 1993/12/29 09:51:24 $
11 * There are minimum values that vi has to have to display a screen. The
12 * row minimum is fixed at 1 line for the text, and 1 line for any error
13 * messages. The column calculation is a lot trickier. For example, you
14 * have to have enough columns to display the line number, not to mention
15 * guaranteeing that tabstop and shiftwidth values are smaller than the
16 * current column value. It's a lot simpler to have a fixed value and not
20 * MINIMUM_SCREEN_COLS is probably wrong.
22 #define MINIMUM_SCREEN_ROWS 2
23 #define MINIMUM_SCREEN_COLS 20
24 /* Line operations. */
25 enum operation
{ LINE_APPEND
, LINE_DELETE
, LINE_INSERT
, LINE_RESET
};
26 /* Position values. */
27 enum position
{ P_BOTTOM
, P_FILL
, P_MIDDLE
, P_TOP
};
30 * Structure for holding file references. Each SCR structure contains a
31 * linked list of these (the user's argument list) as well as pointers to
32 * the current and previous files. The structure contains the name of the
33 * file, along with the information that follows the name. A file has up
34 * to three "names". The tname field is the path of the temporary backing
35 * file, if any. The name field is the name the user originally used to
36 * specify the file to be edited. The cname field is the changed name if
37 * the user changed the name.
39 * Note that the read-only bit follows the file name, not the file itself.
42 * The mtime field should be a struct timespec, but time_t is more portable.
45 CIRCLEQ_ENTRY(_fref
) q
; /* Linked list of file references. */
46 char *cname
; /* Changed file name. */
47 char *name
; /* File name. */
48 char *tname
; /* Temporary file name. */
50 recno_t lno
; /* 1-N: file cursor line. */
51 size_t cno
; /* 0-N: file cursor column. */
52 time_t mtime
; /* Last modification time. */
54 #define FR_CHANGEWRITE 0x001 /* Name changed and then written. */
55 #define FR_CURSORSET 0x002 /* If lno/cno valid. */
56 #define FR_EDITED 0x004 /* If the file was ever edited. */
57 #define FR_IGNORE 0x008 /* File isn't part of argument list. */
58 #define FR_NEWFILE 0x010 /* File doesn't really exist yet. */
59 #define FR_RDONLY 0x020 /* File is read-only. */
64 * There's a file name hierarchy -- if the user has changed the name, we
65 * use it, otherwise, we use the original name, if there was one, othewise
66 * use the temporary name.
68 #define FILENAME(frp) \
69 ((frp)->cname != NULL) ? (frp)->cname : \
70 ((frp)->name != NULL) ? (frp)->name : (frp)->tname
74 * The screen structure. To the extent possible, all screen information
75 * is stored in the various private areas. The only information here
76 * is used by global routines or is shared by too many screens.
79 /* INITIALIZED AT SCREEN CREATE. */
80 CIRCLEQ_ENTRY(_scr
) q
; /* Screens. */
82 GS
*gp
; /* Pointer to global area. */
84 SCR
*nextdisp
; /* Next display screen. */
86 EXF
*ep
; /* Screen's current EXF structure. */
88 MSGH msgq
; /* Message list. */
90 CIRCLEQ_HEAD(_frefh
, _fref
) frefq
;
91 FREF
*frp
; /* FREF being edited. */
92 FREF
*a_frp
; /* Last argument list FREF edited. */
93 FREF
*p_frp
; /* Last FREF edited. */
95 u_long ccnt
; /* Command count. */
96 u_long q_ccnt
; /* Quit or ZZ command count. */
99 size_t rows
; /* 1-N: number of rows. */
100 size_t cols
; /* 1-N: number of columns. */
101 size_t woff
; /* 0-N: row offset in screen. */
102 size_t t_rows
; /* 1-N: cur number of text rows. */
103 size_t t_maxrows
; /* 1-N: max number of text rows. */
104 size_t t_minrows
; /* 1-N: min number of text rows. */
107 recno_t lno
; /* 1-N: file line. */
108 size_t cno
; /* 0-N: file character in line. */
110 size_t rcm
; /* Vi: 0-N: Column suck. */
111 #define RCM_FNB 0x01 /* Column suck: first non-blank. */
112 #define RCM_LAST 0x02 /* Column suck: last. */
115 #define L_ADDED 0 /* Added lines. */
116 #define L_CHANGED 1 /* Changed lines. */
117 #define L_COPIED 2 /* Copied lines. */
118 #define L_DELETED 3 /* Deleted lines. */
119 #define L_JOINED 4 /* Joined lines. */
120 #define L_MOVED 5 /* Moved lines. */
121 #define L_PUT 6 /* Put lines. */
122 #define L_LSHIFT 7 /* Left shift lines. */
123 #define L_RSHIFT 8 /* Right shift lines. */
124 #define L_YANKED 9 /* Yanked lines. */
125 recno_t rptlines
[L_YANKED
+ 1];/* Ex/vi: lines changed by last op. */
127 FILE *stdfp
; /* Ex output file pointer. */
129 char *if_name
; /* Ex input file name, for messages. */
130 recno_t if_lno
; /* Ex input file line, for messages. */
132 fd_set rdfd
; /* Ex/vi: read fd select mask. */
134 TEXTH tiq
; /* Ex/vi: text input queue. */
136 SCRIPT
*script
; /* Vi: script mode information .*/
138 char const *time_msg
; /* ITIMER_REAL message. */
139 struct itimerval time_value
; /* ITIMER_REAL saved value. */
140 struct sigaction time_handler
; /* ITIMER_REAL saved handler. */
142 void *vi_private
; /* Vi private area. */
143 void *ex_private
; /* Ex private area. */
144 void *svi_private
; /* Vi curses screen private area. */
145 void *xaw_private
; /* Vi XAW screen private area. */
147 /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
148 char *alt_name
; /* Ex/vi: alternate file name. */
150 /* Ex/vi: search/substitute info. */
151 regex_t sre
; /* Last search RE. */
152 regex_t subre
; /* Last substitute RE. */
153 enum direction searchdir
; /* File search direction. */
154 enum cdirection csearchdir
; /* Character search direction. */
155 CHAR_T lastckey
; /* Last search character. */
156 regmatch_t
*match
; /* Substitute match array. */
157 size_t matchsize
; /* Substitute match array size. */
158 char *repl
; /* Substitute replacement. */
159 size_t repl_len
; /* Substitute replacement length.*/
160 size_t *newl
; /* Newline offset array. */
161 size_t newl_len
; /* Newline array size. */
162 size_t newl_cnt
; /* Newlines in replacement. */
164 u_int saved_vi_mode
; /* Saved vi display type. */
166 OPTION opts
[O_OPTIONCOUNT
]; /* Options. */
169 * SCREEN SUPPORT ROUTINES.
171 * A SCR * MUST be the first argument to these routines.
173 /* Ring the screen bell. */
174 void (*s_bell
) __P((SCR
*));
175 /* Background the screen. */
176 int (*s_bg
) __P((SCR
*));
177 /* Put up a busy message. */
178 int (*s_busy
) __P((SCR
*, char const *));
179 /* Change a screen line. */
180 int (*s_change
) __P((SCR
*, EXF
*, recno_t
, enum operation
));
181 /* Return column close to specified. */
182 size_t (*s_chposition
) __P((SCR
*, EXF
*, recno_t
, size_t));
183 /* Clear the screen. */
184 int (*s_clear
) __P((SCR
*));
185 /* Return the logical cursor column. */
186 int (*s_column
) __P((SCR
*, EXF
*, size_t *));
187 enum confirm
/* Confirm an action with the user. */
188 (*s_confirm
) __P((SCR
*, EXF
*, MARK
*, MARK
*));
189 /* Move down the screen. */
190 int (*s_down
) __P((SCR
*, EXF
*, MARK
*, recno_t
, int));
192 int (*s_edit
) __P((SCR
*, EXF
*));
194 int (*s_end
) __P((SCR
*));
195 /* Run a single ex command. */
196 int (*s_ex_cmd
) __P((SCR
*, EXF
*, EXCMDARG
*, MARK
*));
197 /* Run user's ex commands. */
198 int (*s_ex_run
) __P((SCR
*, EXF
*, MARK
*));
199 /* Screen's ex write function. */
200 int (*s_ex_write
) __P((void *, const char *, int));
201 /* Foreground the screen. */
202 int (*s_fg
) __P((SCR
*, CHAR_T
*));
203 /* Fill the screen's map. */
204 int (*s_fill
) __P((SCR
*, EXF
*, recno_t
, enum position
));
205 enum input
/* Get a line from the user. */
206 (*s_get
) __P((SCR
*, EXF
*, TEXTH
*, int, u_int
));
207 enum input
/* Get a key from the user. */
208 (*s_key_read
) __P((SCR
*, int *, struct timeval
*));
209 /* Tell the screen an option changed. */
210 int (*s_optchange
) __P((SCR
*, int));
211 /* Return column at screen position. */
212 int (*s_position
) __P((SCR
*, EXF
*,
213 MARK
*, u_long
, enum position
));
214 /* Change the absolute screen size. */
215 int (*s_rabs
) __P((SCR
*, long));
216 /* Refresh the screen. */
217 int (*s_refresh
) __P((SCR
*, EXF
*));
218 /* Return column close to last char. */
219 size_t (*s_relative
) __P((SCR
*, EXF
*, recno_t
));
220 /* Change the relative screen size. */
221 int (*s_rrel
) __P((SCR
*, long));
222 /* Split the screen. */
223 int (*s_split
) __P((SCR
*, ARGS
*[]));
224 /* Suspend the screen. */
225 int (*s_suspend
) __P((SCR
*));
226 /* Move up the screen. */
227 int (*s_up
) __P((SCR
*, EXF
*, MARK
*, recno_t
, int));
229 /* Editor screens. */
230 #define S_EX 0x0000001 /* Ex screen. */
231 #define S_VI_CURSES 0x0000002 /* Vi: curses screen. */
232 #define S_VI_XAW 0x0000004 /* Vi: Athena widgets screen. */
234 #define IN_EX_MODE(sp) /* If in ex mode. */ \
236 #define IN_VI_MODE(sp) /* If in vi mode. */ \
237 (F_ISSET(sp, S_VI_CURSES | S_VI_XAW))
238 #define S_SCREENS /* Screens. */ \
239 (S_EX | S_VI_CURSES | S_VI_XAW)
241 /* Major screen/file changes. */
242 #define S_EXIT 0x0000008 /* Exiting (not forced). */
243 #define S_EXIT_FORCE 0x0000010 /* Exiting (forced). */
244 #define S_FSWITCH 0x0000020 /* Switch files. */
245 #define S_SSWITCH 0x0000040 /* Switch screens. */
246 #define S_MAJOR_CHANGE /* Screen or file changes. */ \
247 (S_EXIT | S_EXIT_FORCE | S_FSWITCH | S_SSWITCH)
249 #define S_BELLSCHED 0x0000080 /* Bell scheduled. */
250 #define S_CONTINUE 0x0000100 /* Need to ask the user to continue. */
251 #define S_EXSILENT 0x0000200 /* Ex batch script. */
252 #define S_GLOBAL 0x0000400 /* Doing a global command. */
253 #define S_INPUT 0x0000800 /* Doing text input. */
254 #define S_INTERRUPTED 0x0001000 /* If have been interrupted. */
255 #define S_INTERRUPTIBLE 0x0002000 /* If can be interrupted. */
256 #define S_REDRAW 0x0004000 /* Redraw the screen. */
257 #define S_REFORMAT 0x0008000 /* Reformat the screen. */
258 #define S_REFRESH 0x0010000 /* Refresh the screen. */
259 #define S_RENUMBER 0x0020000 /* Renumber the screen. */
260 #define S_RESIZE 0x0040000 /* Resize the screen. */
261 #define S_SCRIPT 0x0080000 /* Window is a shell script. */
262 #define S_SRE_SET 0x0100000 /* The search RE has been set. */
263 #define S_SUBRE_SET 0x0200000 /* The substitute RE has been set. */
264 #define S_TIMER_SET 0x0400000 /* If a busy timer is running. */
265 #define S_UPDATE_MODE 0x0800000 /* Don't repaint modeline. */
269 /* Generic routines to start/stop a screen. */
270 int screen_end
__P((SCR
*));
271 int screen_init
__P((SCR
*, SCR
**, u_int
));
273 /* Public interfaces to the underlying screens. */
274 int ex_screen_copy
__P((SCR
*, SCR
*));
275 int ex_screen_end
__P((SCR
*));
276 int ex_screen_init
__P((SCR
*));
277 int sex_screen_copy
__P((SCR
*, SCR
*));
278 int sex_screen_end
__P((SCR
*));
279 int sex_screen_init
__P((SCR
*));
280 int svi_screen_copy
__P((SCR
*, SCR
*));
281 int svi_screen_end
__P((SCR
*));
282 int svi_screen_init
__P((SCR
*));
283 int v_screen_copy
__P((SCR
*, SCR
*));
284 int v_screen_end
__P((SCR
*));
285 int v_screen_init
__P((SCR
*));
286 int xaw_screen_copy
__P((SCR
*, SCR
*));
287 int xaw_screen_end
__P((SCR
*));
288 int xaw_screen_init
__P((SCR
*));