4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 /* Copyright (c) 1981 Regents of the University of California */
35 #pragma ident "%Z%%M% %I% %E% SMI"
44 * Open and visual mode definitions.
46 * There are actually 4 major states in open/visual modes. These
47 * are visual, crt open (where the cursor can move about the screen and
48 * the screen can scroll and be erased), one line open (on dumb glass-crt's
49 * like the adm3), and hardcopy open (for everything else).
51 * The basic state is given by bastate, and the current state by state,
52 * since we can be in pseudo-hardcopy mode if we are on an adm3 and the
53 * line is longer than 80.
65 * The screen in visual and crtopen is of varying size; the basic
66 * window has top basWTOP and basWLINES lines are thereby implied.
67 * The current window (which may have grown from the basic size)
68 * has top WTOP and WLINES lines. The top line of the window is WTOP,
69 * and the bottom line WBOT. The line WECHO is used for messages,
70 * search strings and the like. If WBOT==WECHO then we are in ONEOPEN
71 * or HARDOPEN and there is no way back to the line we were on if we
72 * go to WECHO (i.e. we will have to scroll before we go there, and
73 * we can't get back). There are WCOLS columns per line.
74 * If WBOT!=WECHO then WECHO will be the last line on the screen
75 * and WBOT is the line before it.
86 * When we are dealing with the echo area we consider the window
87 * to be "split" and set the variable splitw. Otherwise, moving
88 * off the bottom of the screen into WECHO causes a screen rollup.
93 * Information about each line currently on the screen includes
94 * the y coordinate associated with the line, the printing depth
95 * of the line (0 indicates unknown), and a mask which indicates
96 * whether the line is "unclean", i.e. whether we should check
97 * to make sure the line is displayed correctly at the next
98 * appropriate juncture.
101 short vliny
; /* Y coordinate */ /* was char */
102 short vdepth
; /* Depth of displayed line */ /* was char */
103 short vflags
; /* Is line potentially dirty ? */
105 var
struct vlinfo vlinfo
[TUBELINES
+ 2];
107 #define DEPTH(c) (vlinfo[c].vdepth)
108 #define LINE(c) (vlinfo[c].vliny)
109 #define FLAGS(c) (vlinfo[c].vflags)
114 * Hacks to copy vlinfo structures around
117 /* Kludge to make up for no structure assignment */
121 #define vlcopy(i, j) i.longi = j.longi
123 #define vlcopy(i, j) i = j;
127 * The current line on the screen is represented by vcline.
128 * There are vcnt lines on the screen, the last being "vcnt - 1".
129 * Vcline is intimately tied to the current value of dot,
130 * and when command mode is used as a subroutine fancy footwork occurs.
136 * To allow many optimizations on output, an exact image of the terminal
137 * screen is maintained in the space addressed by vtube0. The vtube
138 * array indexes this space as lines, and is shuffled on scrolls, insert+delete
139 * lines and the like rather than (more expensively) shuffling the screen
140 * data itself. It is also rearranged during insert mode across line
141 * boundaries to make incore work easier.
143 var
wchar_t *vtube
[TUBELINES
];
147 * The current cursor position within the current line is kept in
148 * cursor. The current line is kept in linebuf. During insertions
149 * we use the auxiliary array genbuf as scratch area.
150 * The cursor wcursor and wdot are used in operations within/spanning
151 * lines to mark the other end of the affected area, or the target
154 var
unsigned char *cursor
;
155 var
unsigned char *wcursor
;
159 * Undo information is saved in a LBSIZE buffer at "vutmp" for changes
160 * within the current line, or as for command mode for multi-line changes
161 * or changes on lines no longer the current line.
162 * The change kind "VCAPU" is used immediately after a U undo to prevent
163 * two successive U undo's from destroying the previous state.
172 var
short vundkind
; /* Which kind of undo - from above */
173 var
unsigned char *vutmp
; /* Prev line image when "VCHNG" */
176 * State information for undoing of macros. The basic idea is that
177 * if the macro does only 1 change or even none, we don't treat it
178 * specially. If it does 2 or more changes we want to be able to
179 * undo it as a unit. We remember how many changes have been made
180 * within the current macro. (Remember macros can be nested.)
182 #define VC_NOTINMAC 0 /* Not in a macro */
183 #define VC_NOCHANGE 1 /* In a macro, no changes so far */
184 #define VC_ONECHANGE 2 /* In a macro, one change so far */
185 #define VC_MANYCHANGE 3 /* In a macro, at least 2 changes so far */
187 var
short vch_mac
; /* Change state - one of the above */
190 * For U undo's the line is grabbed by "vmove" after it first appears
191 * on that line. The "vUNDdot" which specifies which line has been
192 * saved is selectively cleared when changes involving other lines
193 * are made, i.e. after a 'J' join. This is because a 'JU' would
194 * lose completely the text of the line just joined on.
196 var
unsigned char *vUNDcurs
; /* Cursor just before 'U' */
197 var line
*vUNDdot
; /* The line address of line saved in vUNDsav */
198 var line vUNDsav
; /* Grabbed initial "*dot" */
200 #define killU() vUNDdot = NOLINE
203 * There are a number of cases where special behaviour is needed
204 * from deeply nested routines. This is accomplished by setting
205 * the bits of hold, which acts to change the state of the general
206 * visual editing behaviour in specific ways.
208 * HOLDAT prevents the clreol (clear to end of line) routines from
209 * putting out @'s or ~'s on empty lines.
211 * HOLDDOL prevents the reopen routine from putting a '$' at the
212 * end of a reopened line in list mode (for hardcopy mode, e.g.).
214 * HOLDROL prevents spurious blank lines when scrolling in hardcopy
217 * HOLDQIK prevents the fake insert mode during repeated commands.
219 * HOLDPUPD prevents updating of the physical screen image when
220 * mucking around while in insert mode.
222 * HOLDECH prevents clearing of the echo area while rolling the screen
223 * backwards (e.g.) in deference to the clearing of the area at the
224 * end of the scroll (1 time instead of n times). The fact that this
225 * is actually needed is recorded in heldech, which says that a clear
226 * of the echo area was actually held off.
229 var
short holdupd
; /* Hold off update when echo line is too long */
240 * Miscellaneous variables
242 var
short CDCNT
; /* Count of ^D's in insert on this line */
243 var
unsigned char DEL
[VBSIZE
+1]; /* Last deleted text */
244 var
bool HADUP
; /* This insert line started with ^ then ^D */
245 var
bool HADZERO
; /* This insert line started with 0 then ^D */
246 var
unsigned char INS
[VBSIZE
+1]; /* Last inserted text */
247 var
int Vlines
; /* Number of file lines "before" vi command */
248 var
int Xcnt
; /* External variable holding last cmd's count */
249 var
bool Xhadcnt
; /* Last command had explicit count? */
251 var
short dir
; /* Direction for search (+1 or -1) */
252 var
short doomed
; /* Disply chars right of cursor to be killed */
253 var
bool gobblebl
; /* Wrapmargin space generated nl, eat a space */
254 var
bool hadcnt
; /* (Almost) internal to vmain() */
255 var
bool heldech
; /* We owe a clear of echo area */
256 var
bool insmode
; /* Are in character insert mode */
257 var
unsigned char lastcmd
[5]; /* Chars in last command */
258 var
int lastcnt
; /* Count for last command */
259 var
unsigned char *lastcp
; /* Save current command here to repeat */
260 var
bool lasthad
; /* Last command had a count? */
261 var
short lastvgk
; /* Previous input key, if not from keyboard */
262 var
short lastreg
; /* Register with last command */
263 var
unsigned char *ncols
['z'-'a'+2]; /* Cursor positions of marks */
264 var
unsigned char *notenam
; /* Name to be noted with change count */
265 var
unsigned char *notesgn
; /* Change count from last command */
266 var
unsigned char op
; /* Operation of current command */
267 var
int Peekkey
; /* Peek ahead key */
268 var
bool rubble
; /* Line is filthy (in hardcopy open), redraw! */
269 var
int vSCROLL
; /* Number lines to scroll on ^D/^U */
270 var
unsigned char *vglobp
; /* Untyped input (e.g. repeat insert text) */
271 var
unsigned char vmacbuf
[VBSIZE
]; /* Text of visual macro, hence nonnestable */
272 var
unsigned char *vmacp
; /* Like vglobp but for visual macros */
273 var
unsigned char *vmcurs
; /* Cursor for restore after undo d), e.g. */
274 var
short vmovcol
; /* Column to try to keep on arrow keys */
275 var
bool vmoving
; /* Are trying to keep vmovcol */
276 var
short vreg
; /* Reg for this command */ /* mjm: was char */
277 var
short wdkind
; /* Liberal/conservative words? */
278 var
unsigned char workcmd
[5]; /* Temporary for lastcmd */
281 var
int P_cursor_offset
; /* cursor adjust for Put */
284 var
unsigned char wcharfiller
; /* Right margin filler for wide char */
285 #endif /* PRESUNEUC */
292 #define LASTLINE LINE(vcnt)
294 #define cindent() ((outline - vlinfo[vcline].vliny) * WCOLS + outcol)
295 #define vputp(cp, cnt) tputs(cp, cnt, vputch)
296 #define vputc(c) putch(c)
306 int vchange(unsigned char);
307 int vdelete(unsigned char);
315 #define FILLER 0177 /* fill positions for multibyte characters */
321 #endif /* _EX_VIS_H */