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.64 1993/11/20 10:05:23 bostic Exp $ (Berkeley) $Date: 1993/11/20 10:05:23 $
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 TAILQ_ENTRY(_fref
) q
; /* Linked list of file references. */
46 char *cname
; /* Changed file name. */
47 size_t clen
; /* Changed file name length. */
48 char *name
; /* File name. */
49 size_t nlen
; /* File name length. */
50 char *tname
; /* Temporary file name. */
51 size_t tlen
; /* Temporary file name length. */
53 recno_t lno
; /* 1-N: file cursor line. */
54 size_t cno
; /* 0-N: file cursor column. */
55 time_t mtime
; /* Last modification time. */
57 #define FR_CHANGEWRITE 0x001 /* Name changed and then written. */
58 #define FR_CURSORSET 0x002 /* If lno/cno valid. */
59 #define FR_EDITED 0x004 /* If the file was ever edited. */
60 #define FR_IGNORE 0x008 /* File isn't part of argument list. */
61 #define FR_NEWFILE 0x010 /* File doesn't really exist yet. */
62 #define FR_RDONLY 0x020 /* File is read-only. */
67 * There's a file name hierarchy -- if the user has changed the name, we
68 * use it, otherwise, we use the original name, if there was one, othewise
69 * use the temporary name.
71 #define FILENAME(frp) \
72 ((frp)->cname != NULL) ? (frp)->cname : \
73 ((frp)->name != NULL) ? (frp)->name : (frp)->tname
77 * The screen structure. To the extent possible, all screen information
78 * is stored in the various private areas. The only information here
79 * is used by global routines or is shared by too many screens.
82 /* INITIALIZED AT SCREEN CREATE. */
83 CIRCLEQ_ENTRY(_scr
) q
; /* Screens. */
85 GS
*gp
; /* Pointer to global area. */
87 SCR
*nextdisp
; /* Next display screen. */
89 EXF
*ep
; /* Screen's current EXF structure. */
91 MSGH msgq
; /* Message list. */
93 TAILQ_HEAD(_frefh
, _fref
) frefq
;/* FREF list. */
94 FREF
*frp
; /* Current FREF. */
95 FREF
*p_frp
; /* Previous FREF. */
97 u_long ccnt
; /* Command count. */
100 size_t rows
; /* 1-N: number of rows. */
101 size_t cols
; /* 1-N: number of columns. */
102 size_t woff
; /* 0-N: row offset in screen. */
103 size_t t_rows
; /* 1-N: cur number of text rows. */
104 size_t t_maxrows
; /* 1-N: max number of text rows. */
105 size_t t_minrows
; /* 1-N: min number of text rows. */
108 recno_t lno
; /* 1-N: file line. */
109 recno_t olno
; /* 1-N: old cursor file line. */
110 size_t cno
; /* 0-N: file character in line. */
111 size_t ocno
; /* 0-N: old file cursor column. */
112 size_t sc_col
; /* 0-N: LOGICAL screen column. */
114 size_t rcm
; /* Vi: 0-N: Column suck. */
115 #define RCM_FNB 0x01 /* Column suck: first non-blank. */
116 #define RCM_LAST 0x02 /* Column suck: last. */
119 #define L_ADDED 0 /* Added lines. */
120 #define L_CHANGED 1 /* Changed lines. */
121 #define L_COPIED 2 /* Copied lines. */
122 #define L_DELETED 3 /* Deleted lines. */
123 #define L_JOINED 4 /* Joined lines. */
124 #define L_MOVED 5 /* Moved lines. */
125 #define L_PUT 6 /* Put lines. */
126 #define L_LSHIFT 7 /* Left shift lines. */
127 #define L_RSHIFT 8 /* Right shift lines. */
128 #define L_YANKED 9 /* Yanked lines. */
129 recno_t rptlines
[L_YANKED
+ 1];/* Ex/vi: lines changed by last op. */
131 FILE *stdfp
; /* Ex output file pointer. */
133 fd_set rdfd
; /* Ex/vi: read fd select mask. */
135 TEXTH tiq
; /* Ex/vi: text input queue. */
137 int sh_in
[2]; /* Script: pipe. */
138 int sh_out
[2]; /* Script: pipe. */
139 pid_t sh_pid
; /* Script: shell pid. */
140 char *sh_prompt
; /* Script: prompt. */
141 size_t sh_prompt_len
; /* Script: prompt length. */
143 char const *time_msg
; /* ITIMER_REAL message. */
144 struct itimerval time_value
; /* ITIMER_REAL saved value. */
145 struct sigaction time_handler
; /* ITIMER_REAL saved handler. */
147 void *vi_private
; /* Vi private area. */
148 void *ex_private
; /* Ex private area. */
149 void *svi_private
; /* Vi curses screen private area. */
150 void *xaw_private
; /* Vi XAW screen private area. */
152 /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
153 char *alt_name
; /* Ex/vi: alternate file name. */
155 /* Ex/vi: search/substitute info. */
156 regex_t sre
; /* Last search RE. */
157 regex_t subre
; /* Last substitute RE. */
158 enum direction searchdir
; /* File search direction. */
159 enum cdirection csearchdir
; /* Character search direction. */
160 u_char lastckey
; /* Last search character. */
161 regmatch_t
*match
; /* Substitute match array. */
162 size_t matchsize
; /* Substitute match array size. */
163 char *repl
; /* Substitute replacement. */
164 size_t repl_len
; /* Substitute replacement length.*/
165 size_t *newl
; /* Newline offset array. */
166 size_t newl_len
; /* Newline array size. */
167 size_t newl_cnt
; /* Newlines in replacement. */
169 CHNAME
const *cname
; /* Display names of characters. */
170 u_char special
[UCHAR_MAX
]; /* Special character array. */
172 u_int saved_vi_mode
; /* Saved vi display type. */
174 OPTION opts
[O_OPTIONCOUNT
]; /* Options. */
177 * SCREEN SUPPORT ROUTINES.
179 * A SCR * MUST be the first argument to these routines.
181 /* Ring the screen bell. */
182 void (*s_bell
) __P((SCR
*));
183 /* Background the screen. */
184 int (*s_bg
) __P((SCR
*));
185 /* Put up a busy message. */
186 int (*s_busy
) __P((SCR
*, char const *));
187 /* Change a screen line. */
188 int (*s_change
) __P((SCR
*, EXF
*, recno_t
, enum operation
));
189 /* Return column close to specified. */
190 size_t (*s_chposition
) __P((SCR
*, EXF
*, recno_t
, size_t));
191 /* Clear the screen. */
192 int (*s_clear
) __P((SCR
*));
193 enum confirm
/* Confirm an action with the user. */
194 (*s_confirm
) __P((SCR
*, EXF
*, MARK
*, MARK
*));
195 /* Copy to a new screen. */
196 int (*s_copy
) __P((SCR
*, SCR
*));
197 /* Move down the screen. */
198 int (*s_down
) __P((SCR
*, EXF
*, MARK
*, recno_t
, int));
200 int (*s_edit
) __P((SCR
*, EXF
*));
202 int (*s_end
) __P((SCR
*));
203 /* Run a single ex command. */
204 int (*s_ex_cmd
) __P((SCR
*, EXF
*, EXCMDARG
*, MARK
*));
205 /* Run user's ex commands. */
206 int (*s_ex_run
) __P((SCR
*, EXF
*, MARK
*));
207 /* Screen's ex write function. */
208 int (*s_ex_write
) __P((void *, const char *, int));
209 /* Foreground the screen. */
210 int (*s_fg
) __P((SCR
*, char *));
211 /* Fill the screen's map. */
212 int (*s_fill
) __P((SCR
*, EXF
*, recno_t
, enum position
));
213 enum input
/* Get a line from the user. */
214 (*s_get
) __P((SCR
*, EXF
*, TEXTH
*, int, u_int
));
215 enum input
/* Get a key from the user. */
216 (*s_key_read
) __P((SCR
*, int *, int));
217 /* Tell the screen an option changed. */
218 int (*s_optchange
) __P((SCR
*, int));
219 /* Return column at screen position. */
220 int (*s_position
) __P((SCR
*, EXF
*,
221 MARK
*, u_long
, enum position
));
222 /* Refresh the screen. */
223 int (*s_refresh
) __P((SCR
*, EXF
*));
224 /* Return column close to last char. */
225 size_t (*s_relative
) __P((SCR
*, EXF
*, recno_t
));
226 /* Change the screen size. */
227 int (*s_resize
) __P((SCR
*, long));
228 /* Split the screen. */
229 int (*s_split
) __P((SCR
*, char *[]));
230 /* Suspend the screen. */
231 int (*s_suspend
) __P((SCR
*));
232 /* Move up the screen. */
233 int (*s_up
) __P((SCR
*, EXF
*, MARK
*, recno_t
, int));
235 /* Editor screens. */
236 #define S_EX 0x0000001 /* Ex screen. */
237 #define S_VI_CURSES 0x0000002 /* Vi: curses screen. */
238 #define S_VI_XAW 0x0000004 /* Vi: Athena widgets screen. */
240 #define IN_EX_MODE(sp) /* If in ex mode. */ \
242 #define IN_VI_MODE(sp) /* If in vi mode. */ \
243 (F_ISSET(sp, S_VI_CURSES | S_VI_XAW))
244 #define S_SCREENS /* Screens. */ \
245 (S_EX | S_VI_CURSES | S_VI_XAW)
247 /* Major screen/file changes. */
248 #define S_EXIT 0x0000008 /* Exiting (not forced). */
249 #define S_EXIT_FORCE 0x0000010 /* Exiting (forced). */
250 #define S_FSWITCH 0x0000020 /* Switch files. */
251 #define S_SSWITCH 0x0000040 /* Switch screens. */
252 #define S_MAJOR_CHANGE /* Screen or file changes. */ \
253 (S_EXIT | S_EXIT_FORCE | S_FSWITCH | S_SSWITCH)
255 #define S_ABBREV 0x0000080 /* If have abbreviations. */
256 #define S_AUTOPRINT 0x0000100 /* Autoprint flag. */
257 #define S_BELLSCHED 0x0000200 /* Bell scheduled. */
258 #define S_CONTINUE 0x0000400 /* Need to ask the user to continue. */
259 #define S_GLOBAL 0x0000800 /* Doing a global command. */
260 #define S_INPUT 0x0001000 /* Doing text input. */
261 #define S_INTERRUPTED 0x0002000 /* If have been interrupted. */
262 #define S_INTERRUPTIBLE 0x0004000 /* If can be interrupted. */
263 #define S_REDRAW 0x0008000 /* Redraw the screen. */
264 #define S_REFORMAT 0x0010000 /* Reformat the screen. */
265 #define S_REFRESH 0x0020000 /* Refresh the screen. */
266 #define S_RESIZE 0x0040000 /* Resize the screen. */
267 #define S_SCRIPT 0x0080000 /* Window is a shell script. */
268 #define S_SRE_SET 0x0100000 /* The search RE has been set. */
269 #define S_SUBRE_SET 0x0200000 /* The substitute RE has been set. */
270 #define S_TIMER_SET 0x0400000 /* If a busy timer is running. */
271 #define S_UPDATE_MODE 0x0800000 /* Don't repaint modeline. */
275 /* Generic routines to start/stop a screen. */
276 int screen_end
__P((SCR
*));
277 int screen_init
__P((SCR
*, SCR
**, u_int
));
279 /* Public interfaces to the underlying screens. */
280 int sex_screen_init
__P((SCR
*));
281 int svi_screen_init
__P((SCR
*));
282 int xaw_screen_init
__P((SCR
*));