1/*	$OpenBSD: def.h,v 1.181 2024/05/21 05:00:48 jsg Exp $	*/
2
3/* This file is in the public domain. */
4
5/*
6 * This file is the general header file for all parts
7 * of the Mg display editor. It contains all of the
8 * general definitions and macros. It also contains some
9 * conditional compilation flags. All of the per-system and
10 * per-terminal definitions are in special header files.
11 */
12
13#include	"chrdef.h"
14
15typedef int	(*PF)(int, int);	/* generally useful type */
16
17/*
18 * Table sizes, etc.
19 */
20#define NFILEN	1024		/* Length, file name.		 */
21#define NBUFN	NFILEN		/* Length, buffer name.		 */
22#define NLINE	256		/* Length, line.		 */
23#define PBMODES 4		/* modes per buffer		 */
24#define NPAT	80		/* Length, pattern.		 */
25#define HUGE	1000		/* A rather large number.	 */
26#define NSRCH	128		/* Undoable search commands.	 */
27#define NXNAME	64		/* Length, extended command.	 */
28#define NKNAME	20		/* Length, key names.		 */
29#define NTIME	50		/* Length, timestamp string.	 */
30
31/*
32 * Universal.
33 */
34#define FALSE	0		/* False, no, bad, etc.		 */
35#define TRUE	1		/* True, yes, good, etc.	 */
36#define ABORT	2		/* Death, ^G, abort, etc.	 */
37#define UERROR	3		/* User Error.			 */
38#define REVERT	4		/* Revert the buffer		 */
39
40#define KCLEAR	2		/* clear echo area		 */
41
42/*
43 * These flag bits keep track of
44 * some aspects of the last command. The CFCPCN
45 * flag controls goal column setting. The CFKILL
46 * flag controls the clearing versus appending
47 * of data in the kill buffer.
48 */
49#define CFCPCN	0x0001		/* Last command was C-p or C-n	 */
50#define CFKILL	0x0002		/* Last command was a kill	 */
51#define CFINS	0x0004		/* Last command was self-insert	 */
52
53/*
54 * File I/O.
55 */
56#define FIOSUC	0		/* Success.			 */
57#define FIOFNF	1		/* File not found.		 */
58#define FIOEOF	2		/* End of file.			 */
59#define FIOERR	3		/* Error.			 */
60#define FIOLONG 4		/* long line partially read	 */
61#define FIODIR 5		/* File is a directory		 */
62
63/*
64 * Display colors.
65 */
66#define CNONE	0		/* Unknown color.		 */
67#define CTEXT	1		/* Text color.			 */
68#define CMODE	2		/* Mode line color.		 */
69
70/*
71 * Flags for keyboard invoked functions.
72 */
73#define FFUNIV		1	/* universal argument		 */
74#define FFNEGARG	2	/* negative only argument	 */
75#define FFOTHARG	4	/* other argument		 */
76#define FFARG		7	/* any argument			 */
77#define FFRAND		8	/* Called by other function	 */
78
79/*
80 * Flags for "eread".
81 */
82#define EFFUNC	0x0001		/* Autocomplete functions.	 */
83#define EFBUF	0x0002		/* Autocomplete buffers.	 */
84#define EFFILE	0x0004		/* " files (maybe someday)	 */
85#define EFAUTO	0x0007		/* Some autocompletion on	 */
86#define EFNEW	0x0008		/* New prompt.			 */
87#define EFCR	0x0010		/* Echo CR at end; last read.	 */
88#define EFDEF	0x0020		/* buffer contains default args	 */
89#define EFNUL	0x0040		/* Null Minibuffer OK		 */
90
91/*
92 * Direction of insert into kill ring
93 */
94#define KNONE	0x00
95#define KFORW	0x01		/* forward insert into kill ring */
96#define KBACK	0x02		/* Backwards insert into kill ring */
97#define KREG	0x04		/* This is a region-based kill */
98
99#define MAX_TOKEN 64
100
101#define	BUFSIZE	128	/* Size of line contents in extend.c  */
102/*
103 * Previously from sysdef.h
104 */
105typedef int	RSIZE;		/* Type for file/region sizes    */
106typedef short	KCHAR;		/* Type for internal keystrokes  */
107
108/*
109 * This structure holds the starting position
110 * (as a line/offset pair) and the number of characters in a
111 * region of a buffer. This makes passing the specification
112 * of a region around a little bit easier.
113 */
114struct region {
115	struct line	*r_linep;	/* Origin line address.		 */
116	int		 r_offset;	/* Origin line offset.		 */
117	int		 r_lineno;	/* Origin line number		 */
118	RSIZE		 r_size;	/* Length in characters.	 */
119};
120
121
122/*
123 * All text is kept in circularly linked
124 * lists of "line" structures. These begin at the
125 * header line (which is the blank line beyond the
126 * end of the buffer). This line is pointed to by
127 * the "buffer" structure. Each line contains the number of
128 * bytes in the line (the "used" size), the size
129 * of the text array, and the text. The end of line
130 * is not stored as a byte; it's implied. Future
131 * additions will include update hints, and a
132 * list of marks into the line.
133 */
134struct line {
135	struct line	*l_fp;		/* Link to the next line	 */
136	struct line	*l_bp;		/* Link to the previous line	 */
137	int		 l_size;	/* Allocated size		 */
138	int		 l_used;	/* Used size			 */
139	char		*l_text;	/* Content of the line		 */
140};
141
142/*
143 * The rationale behind these macros is that you
144 * could (with some editing, like changing the type of a line
145 * link from a "struct line *" to a "REFLINE", and fixing the commands
146 * like file reading that break the rules) change the actual
147 * storage representation of lines to use something fancy on
148 * machines with small address spaces.
149 */
150#define lforw(lp)	((lp)->l_fp)
151#define lback(lp)	((lp)->l_bp)
152#define lgetc(lp, n)	(CHARMASK((lp)->l_text[(n)]))
153#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
154#define llength(lp)	((lp)->l_used)
155#define ltext(lp)	((lp)->l_text)
156
157/*
158 * All repeated structures are kept as linked lists of structures.
159 * All of these start with a LIST structure (except lines, which
160 * have their own abstraction). This will allow for
161 * later conversion to generic list manipulation routines should
162 * I decide to do that. It does mean that there are four extra
163 * bytes per window. I feel that this is an acceptable price,
164 * considering that there are usually only one or two windows.
165 */
166struct list {
167	union {
168		struct mgwin	*l_wp;
169		struct buffer	*x_bp;	/* l_bp is used by struct line */
170		struct list	*l_nxt;
171	} l_p;
172	char *l_name;
173};
174
175/*
176 * Usual hack - to keep from uglifying the code with lotsa
177 * references through the union, we #define something for it.
178 */
179#define l_next	l_p.l_nxt
180
181/*
182 * There is a window structure allocated for
183 * every active display window. The windows are kept in a
184 * big list, in top to bottom screen order, with the listhead at
185 * "wheadp". Each window contains its own values of dot and mark.
186 * The flag field contains some bits that are set by commands
187 * to guide redisplay; although this is a bit of a compromise in
188 * terms of decoupling, the full blown redisplay is just too
189 * expensive to run for every input character.
190 */
191struct mgwin {
192	struct list	 w_list;	/* List header			*/
193	struct buffer	*w_bufp;	/* Buffer displayed in window	*/
194	struct line	*w_linep;	/* Top line in the window	*/
195	struct line	*w_dotp;	/* Line containing "."		*/
196	struct line	*w_markp;	/* Line containing "mark"	*/
197	int		 w_doto;	/* Byte offset for "."		*/
198	int		 w_marko;	/* Byte offset for "mark"	*/
199	int		 w_toprow;	/* Origin 0 top row of window	*/
200	int		 w_ntrows;	/* # of rows of text in window	*/
201	int		 w_frame;	/* #lines to reframe by.	*/
202	char		 w_rflag;	/* Redisplay Flags.		*/
203	char		 w_flag;	/* Flags.			*/
204	struct line	*w_wrapline;
205	int		 w_dotline;	/* current line number of dot	*/
206	int		 w_markline;	/* current line number of mark	*/
207};
208#define w_wndp	w_list.l_p.l_wp
209#define w_name	w_list.l_name
210
211/*
212 * Window redisplay flags are set by command processors to
213 * tell the display system what has happened to the buffer
214 * mapped by the window. Setting "WFFULL" is always a safe thing
215 * to do, but it may do more work than is necessary. Always try
216 * to set the simplest action that achieves the required update.
217 * Because commands set bits in the "w_flag", update will see
218 * all change flags, and do the most general one.
219 */
220#define WFFRAME 0x01			/* Force reframe.		 */
221#define WFMOVE	0x02			/* Movement from line to line.	 */
222#define WFEDIT	0x04			/* Editing within a line.	 */
223#define WFFULL	0x08			/* Do a full display.		 */
224#define WFMODE	0x10			/* Update mode line.		 */
225
226/*
227 * Window flags
228 */
229#define WNONE  0x00 			/* No special window options.	*/
230#define WEPHEM 0x01 			/* Window is ephemeral.	 	*/
231
232struct undo_rec;
233TAILQ_HEAD(undoq, undo_rec);
234
235/*
236 * Previously from sysdef.h
237 * Only used in struct buffer.
238 */
239struct fileinfo {
240        uid_t           fi_uid;
241        gid_t           fi_gid;
242        mode_t          fi_mode;
243        struct timespec fi_mtime;       /* Last modified time */
244};
245
246/*
247 * Text is kept in buffers. A buffer header, described
248 * below, exists for every buffer in the system. The buffers are
249 * kept in a big list, so that commands that search for a buffer by
250 * name can find the buffer header. There is a safe store for the
251 * dot and mark in the header, but this is only valid if the buffer
252 * is not being displayed (that is, if "b_nwnd" is 0). The text for
253 * the buffer is kept in a circularly linked list of lines, with
254 * a pointer to the header line in "b_headp".
255 */
256struct buffer {
257	struct list	 b_list;	/* buffer list pointer		 */
258	struct buffer	*b_altb;	/* Link to alternate buffer	 */
259	struct line	*b_dotp;	/* Link to "." line structure	 */
260	struct line	*b_markp;	/* ditto for mark		 */
261	struct line	*b_headp;	/* Link to the header line	 */
262	struct maps_s	*b_modes[PBMODES]; /* buffer modes		 */
263	int		 b_doto;	/* Offset of "." in above line	 */
264	int		 b_marko;	/* ditto for the "mark"		 */
265	short		 b_nmodes;	/* number of non-fundamental modes */
266	char		 b_nwnd;	/* Count of windows on buffer	 */
267	char		 b_flag;	/* Flags			 */
268	char		 b_fname[NFILEN]; /* File name			 */
269	char		 b_cwd[NFILEN]; /* working directory		 */
270	char		*b_nlseq;	/* Newline sequence of chars	 */
271	char		*b_nlchr;	/* 1st newline character	 */
272	int		 b_tabw;	/* Width of a tab character	 */
273	struct fileinfo	 b_fi;		/* File attributes		 */
274	struct undoq	 b_undo;	/* Undo actions list		 */
275	struct undo_rec *b_undoptr;
276	int		 b_dotline;	/* Line number of dot */
277	int		 b_markline;	/* Line number of mark */
278	int		 b_lines;	/* Number of lines in file	*/
279};
280#define b_bufp	b_list.l_p.x_bp
281#define b_bname b_list.l_name
282
283/* Some helper macros, in case they ever change to functions */
284#define bfirstlp(buf)	(lforw((buf)->b_headp))
285#define blastlp(buf)	(lback((buf)->b_headp))
286
287#define BFCHG	0x01			/* Changed.			 */
288#define BFBAK	0x02			/* Need to make a backup.	 */
289#define BFNOTAB 0x04			/* no tab mode			 */
290#define BFOVERWRITE 0x08		/* overwrite mode		 */
291#define BFREADONLY  0x10		/* read only mode		 */
292#define BFDIRTY     0x20		/* Buffer was modified elsewhere */
293#define BFIGNDIRTY  0x40		/* Ignore modifications 	 */
294#define BFDIREDDEL  0x80		/* Dired has a deleted 'D' file	 */
295/*
296 * This structure holds information about recent actions for the Undo command.
297 */
298struct undo_rec {
299	TAILQ_ENTRY(undo_rec) next;
300	enum {
301		INSERT = 1,
302		DELETE,
303		BOUNDARY,
304		MODIFIED,
305		DELREG
306	} type;
307	struct region	 region;
308	int		 pos;
309	char		*content;
310};
311
312/*
313 * Variable structure.
314 */
315struct varentry {
316	SLIST_ENTRY(varentry) entry;
317	char	 v_buf[BUFSIZE];
318	char	*v_name;
319	char	*v_vals;
320	int	 v_count;
321};
322SLIST_HEAD(vhead, varentry);
323
324/*
325 * Previously from ttydef.h
326 */
327#define STANDOUT_GLITCH			/* possible standout glitch	*/
328
329#define putpad(str, num)	tputs(str, num, ttputc)
330
331#define KFIRST	K00
332#define KLAST	K00
333
334/*
335 * Prototypes.
336 */
337
338/* tty.c X */
339void		 ttinit(void);
340void		 ttreinit(void);
341void		 tttidy(void);
342void		 ttmove(int, int);
343void		 tteeol(void);
344void		 tteeop(void);
345void		 ttbeep(void);
346void		 ttinsl(int, int, int);
347void		 ttdell(int, int, int);
348void		 ttwindow(int, int);
349void		 ttnowindow(void);
350void		 ttcolor(int);
351void		 ttresize(void);
352
353extern volatile sig_atomic_t winch_flag;
354
355/* ttyio.c */
356void		 ttopen(void);
357int		 ttraw(void);
358void		 ttclose(void);
359int		 ttcooked(void);
360int		 ttputc(int);
361void		 ttflush(void);
362int		 ttgetc(void);
363int		 ttwait(int);
364int		 charswaiting(void);
365
366/* dir.c */
367void		 dirinit(void);
368int		 changedir(int, int);
369int		 showcwdir(int, int);
370int		 getcwdir(char *, size_t);
371int		 makedir(int, int);
372int		 do_makedir(char *);
373int		 ask_makedir(void);
374
375/* dired.c */
376struct buffer	*dired_(char *);
377int		 dired_jump(int, int);
378int 		 do_dired(char *);
379
380/* file.c X */
381int		 fileinsert(int, int);
382int		 filevisit(int, int);
383int		 filevisitalt(int, int);
384int		 filevisitro(int, int);
385int		 poptofile(int, int);
386int		 readin(char *);
387int		 insertfile(char *, char *, int);
388int		 filewrite(int, int);
389int		 filesave(int, int);
390int		 buffsave(struct buffer *);
391int		 makebkfile(int, int);
392int		 writeout(FILE **, struct buffer *, char *);
393void		 upmodes(struct buffer *);
394size_t		 xbasename(char *, const char *, size_t);
395int		 do_filevisitalt(char *);
396
397/* line.c X */
398struct line	*lalloc(int);
399int		 lrealloc(struct line *, int);
400void		 lfree(struct line *);
401void		 lchange(int);
402int		 linsert(int, int);
403int		 lnewline_at(struct line *, int);
404int		 lnewline(void);
405int		 ldelete(RSIZE, int);
406int		 ldelnewline(void);
407int		 lreplace(RSIZE, char *);
408char *		 linetostr(const struct line *);
409int		 setcasereplace(int, int);
410
411/* yank.c X */
412
413void		 kdelete(void);
414int		 kinsert(int, int);
415int		 kremove(int);
416int		 kchunk(char *, RSIZE, int);
417int		 killline(int, int);
418int		 yank(int, int);
419
420/* window.c X */
421struct mgwin	*new_window(struct buffer *);
422int		 reposition(int, int);
423int		 redraw(int, int);
424int		 do_redraw(int, int, int);
425int		 nextwind(int, int);
426int		 prevwind(int, int);
427int		 onlywind(int, int);
428int		 splitwind(int, int);
429int		 enlargewind(int, int);
430int		 shrinkwind(int, int);
431int		 delwind(int, int);
432
433/* buffer.c */
434int		 settabw(int, int);
435int		 togglereadonly(int, int);
436int		 togglereadonlyall(int, int);
437struct buffer   *bfind(const char *, int);
438int		 poptobuffer(int, int);
439int		 killbuffer(struct buffer *);
440int		 killbuffer_cmd(int, int);
441int		 savebuffers(int, int);
442int		 listbuffers(int, int);
443int		 addlinef(struct buffer *, char *, ...);
444#define	 addline(bp, text)	addlinef(bp, "%s", text)
445int		 anycb(int);
446int		 bclear(struct buffer *);
447int		 showbuffer(struct buffer *, struct mgwin *, int);
448int		 augbname(char *, const char *, size_t);
449struct mgwin    *popbuf(struct buffer *, int);
450int		 bufferinsert(int, int);
451int		 usebuffer(int, int);
452int		 notmodified(int, int);
453int		 popbuftop(struct buffer *, int);
454int		 getbufcwd(char *, size_t);
455int		 checkdirty(struct buffer *);
456int		 revertbuffer(int, int);
457int		 dorevert(void);
458int		 diffbuffer(int, int);
459struct buffer	*findbuffer(char *);
460
461/* display.c */
462int		 vtresize(int, int, int);
463void		 vtinit(void);
464void		 vttidy(void);
465void		 update(int);
466int		 linenotoggle(int, int);
467int		 colnotoggle(int, int);
468
469/* echo.c X */
470void		 eerase(void);
471int		 eyorn(const char *);
472int		 eynorr(const char *);
473int		 eyesno(const char *);
474void		 ewprintf(const char *fmt, ...);
475char		*eread(const char *, char *, size_t, int, ...)
476				__attribute__((__format__ (printf, 1, 5)));
477int		 getxtra(struct list *, struct list *, int, int);
478void		 free_file_list(struct list *);
479
480/* fileio.c */
481int		 ffropen(FILE **, const char *, struct buffer *);
482void		 ffstat(FILE *, struct buffer *);
483int		 ffwopen(FILE **, const char *, struct buffer *);
484int		 ffclose(FILE *, struct buffer *);
485int		 ffputbuf(FILE *, struct buffer *, int);
486int		 ffgetline(FILE *, char *, int, int *);
487int		 fbackupfile(const char *);
488char		*adjustname(const char *, int);
489FILE		*startupfile(char *, char *, char *, size_t);
490int		 copy(char *, char *);
491struct list	*make_file_list(char *);
492int		 fisdir(const char *);
493int		 fchecktime(struct buffer *);
494int		 fupdstat(struct buffer *);
495int		 backuptohomedir(int, int);
496int		 toggleleavetmp(int, int);
497char		*expandtilde(const char *);
498
499/* kbd.c X */
500int		 do_meta(int, int);
501int		 bsmap(int, int);
502void		 ungetkey(int);
503int		 getkey(int);
504int		 doin(void);
505int		 rescan(int, int);
506int		 universal_argument(int, int);
507int		 digit_argument(int, int);
508int		 negative_argument(int, int);
509int		 ask_selfinsert(int, int);
510int		 selfinsert(int, int);
511int		 quote(int, int);
512
513/* main.c */
514int		 ctrlg(int, int);
515int		 quit(int, int);
516
517/* ttyio.c */
518void		 panic(char *);
519
520/* cinfo.c */
521char		*getkeyname(char  *, size_t, int);
522
523/* basic.c */
524int		 gotobol(int, int);
525int		 backchar(int, int);
526int		 gotoeol(int, int);
527int		 forwchar(int, int);
528int		 gotobob(int, int);
529int		 gotoeob(int, int);
530int		 forwline(int, int);
531int		 backline(int, int);
532void		 setgoal(void);
533int		 getgoal(struct line *);
534int		 forwpage(int, int);
535int		 backpage(int, int);
536int		 forw1page(int, int);
537int		 back1page(int, int);
538int		 pagenext(int, int);
539void		 isetmark(void);
540int		 setmark(int, int);
541int		 clearmark(int, int);
542int		 swapmark(int, int);
543int		 gotoline(int, int);
544int		 setlineno(int);
545
546/* util.c X */
547int		 ntabstop(int, int);
548int		 showcpos(int, int);
549int		 getcolpos(struct mgwin *);
550int		 twiddle(int, int);
551int		 openline(int, int);
552int		 enewline(int, int);
553int		 deblank(int, int);
554int		 justone(int, int);
555int		 delwhite(int, int);
556int		 delleadwhite(int, int);
557int		 deltrailwhite(int, int);
558int		 lfindent(int, int);
559int		 indent(int, int);
560int		 forwdel(int, int);
561int		 backdel(int, int);
562int		 space_to_tabstop(int, int);
563int		 backtoindent(int, int);
564int		 joinline(int, int);
565
566/* tags.c X */
567int		 findtag(int, int);
568int 		 poptag(int, int);
569int		 tagsvisit(int, int);
570int		 curtoken(int, int, char *);
571
572/* cscope.c */
573int		 cssymbol(int, int);
574int		 csdefinition(int, int);
575int		 csfuncalled(int, int);
576int		 cscallerfuncs(int, int);
577int		 csfindtext(int, int);
578int		 csegrep(int, int);
579int		 csfindfile(int, int);
580int		 csfindinc(int, int);
581int		 csnextfile(int, int);
582int		 csnextmatch(int, int);
583int		 csprevfile(int, int);
584int		 csprevmatch(int, int);
585int		 cscreatelist(int, int);
586
587/* extend.c X */
588int		 insert(int, int);
589int		 bindtokey(int, int);
590int		 localbind(int, int);
591int		 redefine_key(int, int);
592int		 unbindtokey(int, int);
593int		 localunbind(int, int);
594int		 extend(int, int);
595int		 evalexpr(int, int);
596int		 evalbuffer(int, int);
597int		 evalfile(int, int);
598int		 load(FILE *, const char *);
599int		 excline(char *, int, int);
600char		*skipwhite(char *);
601
602/* help.c X */
603int		 desckey(int, int);
604int		 wallchart(int, int);
605int		 help_help(int, int);
606int		 apropos_command(int, int);
607
608/* paragraph.c X */
609int		 gotobop(int, int);
610int		 gotoeop(int, int);
611int		 fillpara(int, int);
612int		 killpara(int, int);
613int		 fillword(int, int);
614int		 setfillcol(int, int);
615int		 markpara(int, int);
616int		 transposepara(int, int);
617int		 sentencespace(int, int);
618
619/* word.c X */
620int		 backword(int, int);
621int		 forwword(int, int);
622int		 upperword(int, int);
623int		 lowerword(int, int);
624int		 capword(int, int);
625int		 delfword(int, int);
626int		 delbword(int, int);
627int		 inword(void);
628int		 transposeword(int, int);
629
630/* region.c X */
631int		 killregion(int, int);
632int		 copyregion(int, int);
633int		 lowerregion(int, int);
634int		 upperregion(int, int);
635int		 prefixregion(int, int);
636int		 setprefix(int, int);
637int		 region_get_data(struct region *, char *, int);
638void		 region_put_data(const char *, int);
639int		 markbuffer(int, int);
640int		 piperegion(int, int);
641int		 shellcommand(int, int);
642int		 pipeio(const char * const, char * const[], char * const, int,
643		     struct buffer *);
644
645/* search.c X */
646int		 forwsearch(int, int);
647int		 backsearch(int, int);
648int		 searchagain(int, int);
649int		 forwisearch(int, int);
650int		 backisearch(int, int);
651int		 queryrepl(int, int);
652int		 forwsrch(void);
653int		 backsrch(void);
654int		 readpattern(char *);
655int		 zapuptochar(int, int);
656int		 zaptochar(int, int);
657int		 zap(int, int);
658
659/* spawn.c X */
660int		 spawncli(int, int);
661
662/* ttykbd.c X */
663void		 ttykeymapinit(void);
664void		 ttykeymaptidy(void);
665
666/* match.c X */
667int		 showmatch(int, int);
668
669/* version.c X */
670int		 showversion(int, int);
671
672/* macro.c X */
673int		 definemacro(int, int);
674int		 finishmacro(int, int);
675int		 executemacro(int, int);
676
677/* modes.c X */
678int		 indentmode(int, int);
679int		 fillmode(int, int);
680int		 notabmode(int, int);
681int		 overwrite_mode(int, int);
682int		 set_default_mode(int,int);
683
684#ifdef REGEX
685/* re_search.c X */
686int		 re_forwsearch(int, int);
687int		 re_backsearch(int, int);
688int		 re_searchagain(int, int);
689int		 re_queryrepl(int, int);
690int		 re_repl(int, int);
691int		 replstr(int, int);
692int		 setcasefold(int, int);
693int		 delmatchlines(int, int);
694int		 delnonmatchlines(int, int);
695int		 cntmatchlines(int, int);
696int		 cntnonmatchlines(int, int);
697#endif	/* REGEX */
698
699/* undo.c X */
700void		 free_undo_record(struct undo_rec *);
701int		 undo_dump(int, int);
702int		 undo_enabled(void);
703int		 undo_enable(int, int);
704int		 undo_add_boundary(int, int);
705void		 undo_add_modified(void);
706int		 undo_add_insert(struct line *, int, int);
707int		 undo_add_delete(struct line *, int, int, int);
708int		 undo_boundary_enable(int, int);
709int		 undo_add_change(struct line *, int, int);
710int		 undo(int, int);
711
712/* autoexec.c X */
713int		 auto_execute(int, int);
714PF		*find_autoexec(const char *);
715int		 add_autoexec(const char *, const char *);
716
717/* cmode.c X */
718int		 cmode(int, int);
719int		 cc_brace(int, int);
720int		 cc_char(int, int);
721int		 cc_tab(int, int);
722int		 cc_indent(int, int);
723int		 cc_lfindent(int, int);
724
725/* grep.c X */
726int		 next_error(int, int);
727int		 globalwdtoggle(int, int);
728int		 compile(int, int);
729
730/* bell.c */
731void		 bellinit(void);
732int		 toggleaudiblebell(int, int);
733int		 togglevisiblebell(int, int);
734int		 dobeep_num(const char *, int);
735int		 dobeep_msgs(const char *, const char *);
736int		 dobeep_msg(const char *);
737void		 dobeep(void);
738
739/* interpreter.c */
740int		 foundparen(char *, int, int);
741void		 cleanup(void);
742
743/*
744 * Externals.
745 */
746extern struct buffer	*bheadp;
747extern struct buffer	*curbp;
748extern struct mgwin	*curwp;
749extern struct mgwin	*wheadp;
750extern struct vhead	 varhead;
751extern int		 thisflag;
752extern int		 lastflag;
753extern int		 curgoal;
754extern int		 startrow;
755extern int		 epresf;
756extern int		 sgarbf;
757extern int		 nrow;
758extern int		 ncol;
759extern int		 ttrow;
760extern int		 ttcol;
761extern int		 tttop;
762extern int		 ttbot;
763extern int		 tthue;
764extern int		 defb_nmodes;
765extern int		 defb_flag;
766extern int		 doaudiblebell;
767extern int		 dovisiblebell;
768extern int		 dblspace;
769extern int		 allbro;
770extern int		 batch;
771extern char	 	 cinfo[];
772extern char		*keystrings[];
773extern char		 pat[NPAT];
774extern char		 prompt[];
775extern int		 tceeol;
776extern int		 tcinsl;
777extern int		 tcdell;
778extern int		 rptcount;	/* successive invocation count */
779