Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / common / screen.h
blob49ee595944ab3ceebe974f4c6fe2433511adb7be
1 /* $NetBSD$ */
3 /*-
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1992, 1993, 1994, 1995, 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
11 * Id: screen.h,v 10.49 2002/03/02 23:47:02 skimo Exp (Berkeley) Date: 2002/03/02 23:47:02
15 * There are minimum values that vi has to have to display a screen. The row
16 * minimum is fixed at 1 (the svi code can share a line between the text line
17 * and the colon command/message line). Column calculation is a lot trickier.
18 * For example, you have to have enough columns to display the line number,
19 * not to mention guaranteeing that tabstop and shiftwidth values are smaller
20 * than the current column value. It's simpler to have a fixed value and not
21 * worry about it.
23 * XXX
24 * MINIMUM_SCREEN_COLS is almost certainly wrong.
26 #define MINIMUM_SCREEN_ROWS 1
27 #define MINIMUM_SCREEN_COLS 20
30 * WIN --
31 * A list of screens that are displayed as a whole.
33 struct _win {
34 CIRCLEQ_ENTRY(_win) q; /* Windows. */
36 CIRCLEQ_HEAD(_scrh, _scr) scrq; /* Screens */
38 GS *gp; /* Pointer to global area. */
40 SCR *ccl_sp; /* Colon command-line screen. */
42 void *perl_private; /* Perl interpreter. */
44 void *ip_private; /* IP support private area. */
46 void *th_private; /* Threading support private area. */
49 * Ex command structures (EXCMD). Defined here because ex commands
50 * exist outside of any particular screen or file.
52 #define EXCMD_RUNNING(wp) ((wp)->ecq.lh_first->clen != 0)
53 LIST_HEAD(_excmdh, _excmd) ecq; /* Ex command linked list. */
54 EXCMD excmd; /* Default ex command structure. */
55 char *if_name; /* Current associated file. */
56 db_recno_t if_lno; /* Current associated line number. */
58 EVENT *i_event; /* Array of input events. */
59 size_t i_nelem; /* Number of array elements. */
60 size_t i_cnt; /* Count of events. */
61 size_t i_next; /* Offset of next event. */
63 CB *dcbp; /* Default cut buffer pointer. */
64 CB dcb_store; /* Default cut buffer storage. */
65 LIST_HEAD(_cuth, _cb) cutq; /* Linked list of cut buffers. */
67 /* For now, can be either char or CHAR_T buffer */
68 char *tmp_bp; /* Temporary buffer. */
69 size_t tmp_blen; /* Temporary buffer size. */
71 char *l_lp; /* Log buffer. */
72 size_t l_len; /* Log buffer length. */
74 CONVWIN cw;
76 /* Flags. */
77 #define W_TMP_INUSE 0x0001 /* Temporary buffer in use. */
78 u_int32_t flags;
80 /* Message or ex output. */
81 void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
85 * SCR --
86 * The screen structure. To the extent possible, all screen information
87 * is stored in the various private areas. The only information here
88 * is used by global routines or is shared by too many screens.
90 struct _scr {
91 /* INITIALIZED AT SCREEN CREATE. */
92 CIRCLEQ_ENTRY(_scr) q; /* Screens. */
93 CIRCLEQ_ENTRY(_scr) eq; /* Screens. */
95 int id; /* Screen id #. */
96 int refcnt; /* Reference count. */
98 WIN *wp; /* Pointer to window. */
99 GS *gp; /* Pointer to global area. */
100 SCR *nextdisp; /* Next display screen. */
101 SCR *ccl_parent; /* Colon command-line parent screen. */
102 EXF *ep; /* Screen's current EXF structure. */
104 CHAR_T *c_lp; /* Cached line. */
105 size_t c_len; /* Cached line length. */
106 /* May move out again once we use DB
107 * to cache internal representation
109 size_t c_blen; /* Cached line buffer length. */
110 db_recno_t c_lno; /* Cached line number. */
112 FREF *frp; /* FREF being edited. */
113 char **argv; /* NULL terminated file name array. */
114 char **cargv; /* Current file name. */
116 u_long ccnt; /* Command count. */
117 u_long q_ccnt; /* Quit or ZZ command count. */
119 /* Screen's: */
120 size_t rows; /* 1-N: number of rows. */
121 size_t cols; /* 1-N: number of columns. */
122 size_t t_rows; /* 1-N: cur number of text rows. */
123 size_t t_maxrows; /* 1-N: max number of text rows. */
124 size_t t_minrows; /* 1-N: min number of text rows. */
125 size_t coff; /* 0-N: screen col offset in display. */
126 size_t roff; /* 0-N: screen row offset in display. */
128 /* Cursor's: */
129 db_recno_t lno; /* 1-N: file line. */
130 size_t cno; /* 0-N: file character in line. */
132 size_t rcm; /* Vi: 0-N: Most attractive column. */
134 #define L_ADDED 0 /* Added lines. */
135 #define L_CHANGED 1 /* Changed lines. */
136 #define L_DELETED 2 /* Deleted lines. */
137 #define L_JOINED 3 /* Joined lines. */
138 #define L_MOVED 4 /* Moved lines. */
139 #define L_SHIFT 5 /* Shift lines. */
140 #define L_YANKED 6 /* Yanked lines. */
141 db_recno_t rptlchange; /* Ex/vi: last L_CHANGED lno. */
142 db_recno_t rptlines[L_YANKED + 1];/* Ex/vi: lines changed by last op. */
144 TEXTH tiq; /* Ex/vi: text input queue. */
146 SCRIPT *script; /* Vi: script mode information .*/
148 db_recno_t defscroll; /* Vi: ^D, ^U scroll information. */
150 /* Display character. */
151 u_char cname[MAX_CHARACTER_COLUMNS + 1];
152 size_t clen; /* Length of display character. */
154 enum { /* Vi editor mode. */
155 SM_APPEND = 0, SM_CHANGE, SM_COMMAND, SM_INSERT,
156 SM_REPLACE } showmode;
158 void *ex_private; /* Ex private area. */
159 void *vi_private; /* Vi private area. */
160 void *perl_private; /* Perl private area. */
161 void *cl_private; /* Curses private area. */
163 CONV conv;
165 struct _log_state state; /* State during log traversal. */
167 /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
168 char *alt_name; /* Ex/vi: alternate file name. */
170 CHAR_T at_lbuf; /* Ex/vi: Last executed at buffer. */
172 /* Ex/vi: re_compile flags. */
173 #define RE_WSTART L("[[:<:]]") /* Ex/vi: not-in-word search pattern. */
174 #define RE_WSTOP L("[[:>:]]")
175 #define RE_WSTART_LEN (sizeof(RE_WSTART)/sizeof(CHAR_T)-1)
176 #define RE_WSTOP_LEN (sizeof(RE_WSTOP)/sizeof(CHAR_T)-1)
177 /* Ex/vi: flags to search routines. */
178 #define SEARCH_CSCOPE 0x000001 /* Search for a cscope pattern. */
179 #define SEARCH_CSEARCH 0x000002 /* Compile search replacement. */
180 #define SEARCH_CSUBST 0x000004 /* Compile substitute replacement. */
181 #define SEARCH_EOL 0x000008 /* Offset past EOL is okay. */
182 #define SEARCH_EXTEND 0x000010 /* Extended RE. */
183 #define SEARCH_FIRST 0x000020 /* Search from the first line. */
184 #define SEARCH_IC 0x000040 /* Ignore case. */
185 #define SEARCH_ICL 0x000080 /* Ignore case. */
186 #define SEARCH_INCR 0x000100 /* Search incrementally. */
187 #define SEARCH_LITERAL 0x000200 /* Literal string. */
188 #define SEARCH_MSG 0x000400 /* Display search messages. */
189 #define SEARCH_NOOPT 0x000800 /* Ignore edit options. */
190 #define SEARCH_PARSE 0x001000 /* Parse the search pattern. */
191 #define SEARCH_SET 0x002000 /* Set search direction. */
192 #define SEARCH_TAG 0x004000 /* Search for a tag pattern. */
193 #define SEARCH_WMSG 0x008000 /* Display search-wrapped messages. */
194 #define SEARCH_WRAP 0x010000 /* Wrap past sof/eof. */
196 /* Ex/vi: RE information. */
197 dir_t searchdir; /* Last file search direction. */
198 regex_t re_c; /* Search RE: compiled form. */
199 CHAR_T *re; /* Search RE: uncompiled form. */
200 size_t re_len; /* Search RE: uncompiled length. */
201 regex_t subre_c; /* Substitute RE: compiled form. */
202 CHAR_T *subre; /* Substitute RE: uncompiled form. */
203 size_t subre_len; /* Substitute RE: uncompiled length). */
204 CHAR_T *repl; /* Substitute replacement. */
205 size_t repl_len; /* Substitute replacement length.*/
206 size_t *newl; /* Newline offset array. */
207 size_t newl_len; /* Newline array size. */
208 size_t newl_cnt; /* Newlines in replacement. */
209 u_int8_t c_suffix; /* Edcompatible 'c' suffix value. */
210 u_int8_t g_suffix; /* Edcompatible 'g' suffix value. */
212 OPTION opts[O_OPTIONCOUNT]; /* Ex/vi: Options. */
215 * Screen flags.
217 * Editor screens.
219 #define SC_EX 0x00000001 /* Ex editor. */
220 #define SC_VI 0x00000002 /* Vi editor. */
223 * Screen formatting flags, first major, then minor.
225 * SC_SCR_EX
226 * Ex screen, i.e. cooked mode.
227 * SC_SCR_VI
228 * Vi screen, i.e. raw mode.
229 * SC_SCR_EXWROTE
230 * The editor had to write on the screen behind curses' back, and we can't
231 * let curses change anything until the user agrees, e.g. entering the
232 * commands :!utility followed by :set. We have to switch back into the
233 * vi "editor" to read the user's command input, but we can't touch the
234 * rest of the screen because it's known to be wrong.
235 * SC_SCR_REFORMAT
236 * The expected presentation of the lines on the screen have changed,
237 * requiring that the intended screen lines be recalculated. Implies
238 * SC_SCR_REDRAW.
239 * SC_SCR_REDRAW
240 * The screen doesn't correctly represent the file; repaint it. Note,
241 * setting SC_SCR_REDRAW in the current window causes *all* windows to
242 * be repainted.
243 * SC_SCR_CENTER
244 * If the current line isn't already on the screen, center it.
245 * SC_SCR_TOP
246 * If the current line isn't already on the screen, put it at the to@.
248 #define SC_SCR_EX 0x00000004 /* Screen is in ex mode. */
249 #define SC_SCR_VI 0x00000008 /* Screen is in vi mode. */
250 #define SC_SCR_EXWROTE 0x00000010 /* Ex overwrite: see comment above. */
251 #define SC_SCR_REFORMAT 0x00000020 /* Reformat (refresh). */
252 #define SC_SCR_REDRAW 0x00000040 /* Refresh. */
254 #define SC_SCR_CENTER 0x00000080 /* Center the line if not visible. */
255 #define SC_SCR_TOP 0x00000100 /* Top the line if not visible. */
257 /* Screen/file changes. */
258 #define SC_EXIT 0x00000200 /* Exiting (not forced). */
259 #define SC_EXIT_FORCE 0x00000400 /* Exiting (forced). */
260 #define SC_FSWITCH 0x00000800 /* Switch underlying files. */
261 #define SC_SSWITCH 0x00001000 /* Switch screens. */
263 #define SC_ARGNOFREE 0x00002000 /* Argument list wasn't allocated. */
264 #define SC_ARGRECOVER 0x00004000 /* Argument list is recovery files. */
265 #define SC_AT_SET 0x00008000 /* Last at buffer set. */
266 #define SC_COMEDIT 0x00010000 /* Colon command-line edit window. */
267 #define SC_EX_GLOBAL 0x00020000 /* Ex: executing a global command. */
268 #define SC_EX_SILENT 0x00040000 /* Ex: batch script. */
269 #define SC_EX_WAIT_NO 0x00080000 /* Ex: don't wait for the user. */
270 #define SC_EX_WAIT_YES 0x00100000 /* Ex: do wait for the user. */
271 #define SC_READONLY 0x00200000 /* Persistent readonly state. */
272 #define SC_RE_SEARCH 0x00400000 /* Search RE has been compiled. */
273 #define SC_RE_SUBST 0x00800000 /* Substitute RE has been compiled. */
274 #define SC_SCRIPT 0x01000000 /* Shell script window. */
275 #define SC_STATUS 0x02000000 /* Welcome message. */
276 #define SC_STATUS_CNT 0x04000000 /* Welcome message plus file count. */
277 #define SC_TINPUT 0x08000000 /* Doing text input. */
278 #define SC_TINPUT_INFO 0x10000000 /* Doing text input on info line. */
279 #define SC_CONV_ERROR 0x20000000 /* Met with a conversion error. */
280 u_int32_t flags;
282 int db_error; /* Return code from db function. */