only clean out gs when last window goes
[nvi.git] / common / screen.h
blobe541750464b2d034c73c19a94f09e4a969ff7c42
1 /*-
2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
9 * $Id: screen.h,v 10.32 2000/07/02 20:31:59 skimo Exp $ (Berkeley) $Date: 2000/07/02 20:31:59 $
13 * There are minimum values that vi has to have to display a screen. The row
14 * minimum is fixed at 1 (the svi code can share a line between the text line
15 * and the colon command/message line). Column calculation is a lot trickier.
16 * For example, you have to have enough columns to display the line number,
17 * not to mention guaranteeing that tabstop and shiftwidth values are smaller
18 * than the current column value. It's simpler to have a fixed value and not
19 * worry about it.
21 * XXX
22 * MINIMUM_SCREEN_COLS is almost certainly wrong.
24 #define MINIMUM_SCREEN_ROWS 1
25 #define MINIMUM_SCREEN_COLS 20
28 * WIN --
29 * A list of screens that are displayed as a whole.
31 struct _win {
32 CIRCLEQ_ENTRY(_win) q; /* Windows. */
34 CIRCLEQ_HEAD(_scrh, _scr) scrq; /* Screens */
36 GS *gp; /* Pointer to global area. */
38 void *perl_private; /* Perl interpreter. */
40 void *ip_private; /* IP support private area. */
42 void *th_private; /* Threading support private area. */
45 * Ex command structures (EXCMD). Defined here because ex commands
46 * exist outside of any particular screen or file.
48 #define EXCMD_RUNNING(wp) ((wp)->ecq.lh_first->clen != 0)
49 LIST_HEAD(_excmdh, _excmd) ecq; /* Ex command linked list. */
50 EXCMD excmd; /* Default ex command structure. */
51 char *if_name; /* Current associated file. */
52 db_recno_t if_lno; /* Current associated line number. */
56 * SCR --
57 * The screen structure. To the extent possible, all screen information
58 * is stored in the various private areas. The only information here
59 * is used by global routines or is shared by too many screens.
61 struct _scr {
62 /* INITIALIZED AT SCREEN CREATE. */
63 CIRCLEQ_ENTRY(_scr) q; /* Screens. */
65 int id; /* Screen id #. */
66 int refcnt; /* Reference count. */
68 WIN *wp; /* Pointer to window. */
69 GS *gp; /* Pointer to global area. */
70 SCR *nextdisp; /* Next display screen. */
71 SCR *ccl_parent; /* Colon command-line parent screen. */
72 EXF *ep; /* Screen's current EXF structure. */
74 FREF *frp; /* FREF being edited. */
75 char **argv; /* NULL terminated file name array. */
76 char **cargv; /* Current file name. */
78 u_long ccnt; /* Command count. */
79 u_long q_ccnt; /* Quit or ZZ command count. */
81 /* Screen's: */
82 size_t rows; /* 1-N: number of rows. */
83 size_t cols; /* 1-N: number of columns. */
84 size_t t_rows; /* 1-N: cur number of text rows. */
85 size_t t_maxrows; /* 1-N: max number of text rows. */
86 size_t t_minrows; /* 1-N: min number of text rows. */
87 size_t coff; /* 0-N: screen col offset in display. */
88 size_t roff; /* 0-N: screen row offset in display. */
90 /* Cursor's: */
91 db_recno_t lno; /* 1-N: file line. */
92 size_t cno; /* 0-N: file character in line. */
94 size_t rcm; /* Vi: 0-N: Most attractive column. */
96 #define L_ADDED 0 /* Added lines. */
97 #define L_CHANGED 1 /* Changed lines. */
98 #define L_DELETED 2 /* Deleted lines. */
99 #define L_JOINED 3 /* Joined lines. */
100 #define L_MOVED 4 /* Moved lines. */
101 #define L_SHIFT 5 /* Shift lines. */
102 #define L_YANKED 6 /* Yanked lines. */
103 db_recno_t rptlchange; /* Ex/vi: last L_CHANGED lno. */
104 db_recno_t rptlines[L_YANKED + 1];/* Ex/vi: lines changed by last op. */
106 TEXTH tiq; /* Ex/vi: text input queue. */
108 SCRIPT *script; /* Vi: script mode information .*/
110 db_recno_t defscroll; /* Vi: ^D, ^U scroll information. */
112 /* Display character. */
113 CHAR_T cname[MAX_CHARACTER_COLUMNS + 1];
114 size_t clen; /* Length of display character. */
116 enum { /* Vi editor mode. */
117 SM_APPEND = 0, SM_CHANGE, SM_COMMAND, SM_INSERT,
118 SM_REPLACE } showmode;
120 void *ex_private; /* Ex private area. */
121 void *vi_private; /* Vi private area. */
122 void *perl_private; /* Perl private area. */
123 void *cl_private; /* Curses private area. */
125 /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
126 char *alt_name; /* Ex/vi: alternate file name. */
128 CHAR_T at_lbuf; /* Ex/vi: Last executed at buffer. */
130 /* Ex/vi: re_compile flags. */
131 #define RE_WSTART "[[:<:]]" /* Ex/vi: not-in-word search pattern. */
132 #define RE_WSTOP "[[:>:]]"
133 /* Ex/vi: flags to search routines. */
134 #define SEARCH_CSCOPE 0x000001 /* Search for a cscope pattern. */
135 #define SEARCH_CSEARCH 0x000002 /* Compile search replacement. */
136 #define SEARCH_CSUBST 0x000004 /* Compile substitute replacement. */
137 #define SEARCH_EOL 0x000008 /* Offset past EOL is okay. */
138 #define SEARCH_EXTEND 0x000010 /* Extended RE. */
139 #define SEARCH_FIRST 0x000020 /* Search from the first line. */
140 #define SEARCH_IC 0x000040 /* Ignore case. */
141 #define SEARCH_ICL 0x000080 /* Ignore case. */
142 #define SEARCH_INCR 0x000100 /* Search incrementally. */
143 #define SEARCH_LITERAL 0x000200 /* Literal string. */
144 #define SEARCH_MSG 0x000400 /* Display search messages. */
145 #define SEARCH_NOOPT 0x000800 /* Ignore edit options. */
146 #define SEARCH_PARSE 0x001000 /* Parse the search pattern. */
147 #define SEARCH_SET 0x002000 /* Set search direction. */
148 #define SEARCH_TAG 0x004000 /* Search for a tag pattern. */
149 #define SEARCH_WMSG 0x008000 /* Display search-wrapped messages. */
150 #define SEARCH_WRAP 0x010000 /* Wrap past sof/eof. */
152 /* Ex/vi: RE information. */
153 dir_t searchdir; /* Last file search direction. */
154 regex_t re_c; /* Search RE: compiled form. */
155 char *re; /* Search RE: uncompiled form. */
156 size_t re_len; /* Search RE: uncompiled length. */
157 regex_t subre_c; /* Substitute RE: compiled form. */
158 char *subre; /* Substitute RE: uncompiled form. */
159 size_t subre_len; /* Substitute RE: uncompiled length). */
160 char *repl; /* Substitute replacement. */
161 size_t repl_len; /* Substitute replacement length.*/
162 size_t *newl; /* Newline offset array. */
163 size_t newl_len; /* Newline array size. */
164 size_t newl_cnt; /* Newlines in replacement. */
165 u_int8_t c_suffix; /* Edcompatible 'c' suffix value. */
166 u_int8_t g_suffix; /* Edcompatible 'g' suffix value. */
168 OPTION opts[O_OPTIONCOUNT]; /* Ex/vi: Options. */
171 * Screen flags.
173 * Editor screens.
175 #define SC_EX 0x00000001 /* Ex editor. */
176 #define SC_VI 0x00000002 /* Vi editor. */
179 * Screen formatting flags, first major, then minor.
181 * SC_SCR_EX
182 * Ex screen, i.e. cooked mode.
183 * SC_SCR_VI
184 * Vi screen, i.e. raw mode.
185 * SC_SCR_EXWROTE
186 * The editor had to write on the screen behind curses' back, and we can't
187 * let curses change anything until the user agrees, e.g. entering the
188 * commands :!utility followed by :set. We have to switch back into the
189 * vi "editor" to read the user's command input, but we can't touch the
190 * rest of the screen because it's known to be wrong.
191 * SC_SCR_REFORMAT
192 * The expected presentation of the lines on the screen have changed,
193 * requiring that the intended screen lines be recalculated. Implies
194 * SC_SCR_REDRAW.
195 * SC_SCR_REDRAW
196 * The screen doesn't correctly represent the file; repaint it. Note,
197 * setting SC_SCR_REDRAW in the current window causes *all* windows to
198 * be repainted.
199 * SC_SCR_CENTER
200 * If the current line isn't already on the screen, center it.
201 * SC_SCR_TOP
202 * If the current line isn't already on the screen, put it at the to@.
204 #define SC_SCR_EX 0x00000004 /* Screen is in ex mode. */
205 #define SC_SCR_VI 0x00000008 /* Screen is in vi mode. */
206 #define SC_SCR_EXWROTE 0x00000010 /* Ex overwrite: see comment above. */
207 #define SC_SCR_REFORMAT 0x00000020 /* Reformat (refresh). */
208 #define SC_SCR_REDRAW 0x00000040 /* Refresh. */
210 #define SC_SCR_CENTER 0x00000080 /* Center the line if not visible. */
211 #define SC_SCR_TOP 0x00000100 /* Top the line if not visible. */
213 /* Screen/file changes. */
214 #define SC_EXIT 0x00000200 /* Exiting (not forced). */
215 #define SC_EXIT_FORCE 0x00000400 /* Exiting (forced). */
216 #define SC_FSWITCH 0x00000800 /* Switch underlying files. */
217 #define SC_SSWITCH 0x00001000 /* Switch screens. */
219 #define SC_ARGNOFREE 0x00002000 /* Argument list wasn't allocated. */
220 #define SC_ARGRECOVER 0x00004000 /* Argument list is recovery files. */
221 #define SC_AT_SET 0x00008000 /* Last at buffer set. */
222 #define SC_COMEDIT 0x00010000 /* Colon command-line edit window. */
223 #define SC_EX_GLOBAL 0x00020000 /* Ex: executing a global command. */
224 #define SC_EX_SILENT 0x00040000 /* Ex: batch script. */
225 #define SC_EX_WAIT_NO 0x00080000 /* Ex: don't wait for the user. */
226 #define SC_EX_WAIT_YES 0x00100000 /* Ex: do wait for the user. */
227 #define SC_READONLY 0x00200000 /* Persistent readonly state. */
228 #define SC_RE_SEARCH 0x00400000 /* Search RE has been compiled. */
229 #define SC_RE_SUBST 0x00800000 /* Substitute RE has been compiled. */
230 #define SC_SCRIPT 0x01000000 /* Shell script window. */
231 #define SC_STATUS 0x02000000 /* Welcome message. */
232 #define SC_STATUS_CNT 0x04000000 /* Welcome message plus file count. */
233 #define SC_TINPUT 0x08000000 /* Doing text input. */
234 #define SC_TINPUT_INFO 0x10000000 /* Doing text input on info line. */
235 u_int32_t flags;
237 int db_error; /* Return code from db function. */