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