xref: /openbsd/usr.bin/mg/def.h (revision ce7279d8)
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 
15 typedef 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  */
105 typedef int	RSIZE;		/* Type for file/region sizes    */
106 typedef 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  */
114 struct 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  */
134 struct 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  */
166 struct 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  */
191 struct 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 
232 struct undo_rec;
233 TAILQ_HEAD(undoq, undo_rec);
234 
235 /*
236  * Previously from sysdef.h
237  * Only used in struct buffer.
238  */
239 struct 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  */
256 struct 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  */
298 struct 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  */
315 struct varentry {
316 	SLIST_ENTRY(varentry) entry;
317 	char	 v_buf[BUFSIZE];
318 	char	*v_name;
319 	char	*v_vals;
320 	int	 v_count;
321 };
322 SLIST_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 */
339 void		 ttinit(void);
340 void		 ttreinit(void);
341 void		 tttidy(void);
342 void		 ttmove(int, int);
343 void		 tteeol(void);
344 void		 tteeop(void);
345 void		 ttbeep(void);
346 void		 ttinsl(int, int, int);
347 void		 ttdell(int, int, int);
348 void		 ttwindow(int, int);
349 void		 ttnowindow(void);
350 void		 ttcolor(int);
351 void		 ttresize(void);
352 
353 extern volatile sig_atomic_t winch_flag;
354 
355 /* ttyio.c */
356 void		 ttopen(void);
357 int		 ttraw(void);
358 void		 ttclose(void);
359 int		 ttcooked(void);
360 int		 ttputc(int);
361 void		 ttflush(void);
362 int		 ttgetc(void);
363 int		 ttwait(int);
364 int		 charswaiting(void);
365 
366 /* dir.c */
367 void		 dirinit(void);
368 int		 changedir(int, int);
369 int		 showcwdir(int, int);
370 int		 getcwdir(char *, size_t);
371 int		 makedir(int, int);
372 int		 do_makedir(char *);
373 int		 ask_makedir(void);
374 
375 /* dired.c */
376 struct buffer	*dired_(char *);
377 int		 dired_jump(int, int);
378 int 		 do_dired(char *);
379 
380 /* file.c X */
381 int		 fileinsert(int, int);
382 int		 filevisit(int, int);
383 int		 filevisitalt(int, int);
384 int		 filevisitro(int, int);
385 int		 poptofile(int, int);
386 int		 readin(char *);
387 int		 insertfile(char *, char *, int);
388 int		 filewrite(int, int);
389 int		 filesave(int, int);
390 int		 buffsave(struct buffer *);
391 int		 makebkfile(int, int);
392 int		 writeout(FILE **, struct buffer *, char *);
393 void		 upmodes(struct buffer *);
394 size_t		 xbasename(char *, const char *, size_t);
395 int		 do_filevisitalt(char *);
396 
397 /* line.c X */
398 struct line	*lalloc(int);
399 int		 lrealloc(struct line *, int);
400 void		 lfree(struct line *);
401 void		 lchange(int);
402 int		 linsert(int, int);
403 int		 lnewline_at(struct line *, int);
404 int		 lnewline(void);
405 int		 ldelete(RSIZE, int);
406 int		 ldelnewline(void);
407 int		 lreplace(RSIZE, char *);
408 char *		 linetostr(const struct line *);
409 int		 setcasereplace(int, int);
410 
411 /* yank.c X */
412 
413 void		 kdelete(void);
414 int		 kinsert(int, int);
415 int		 kremove(int);
416 int		 kchunk(char *, RSIZE, int);
417 int		 killline(int, int);
418 int		 yank(int, int);
419 
420 /* window.c X */
421 struct mgwin	*new_window(struct buffer *);
422 int		 reposition(int, int);
423 int		 redraw(int, int);
424 int		 do_redraw(int, int, int);
425 int		 nextwind(int, int);
426 int		 prevwind(int, int);
427 int		 onlywind(int, int);
428 int		 splitwind(int, int);
429 int		 enlargewind(int, int);
430 int		 shrinkwind(int, int);
431 int		 delwind(int, int);
432 
433 /* buffer.c */
434 int		 settabw(int, int);
435 int		 togglereadonly(int, int);
436 int		 togglereadonlyall(int, int);
437 struct buffer   *bfind(const char *, int);
438 int		 poptobuffer(int, int);
439 int		 killbuffer(struct buffer *);
440 int		 killbuffer_cmd(int, int);
441 int		 savebuffers(int, int);
442 int		 listbuffers(int, int);
443 int		 addlinef(struct buffer *, char *, ...);
444 #define	 addline(bp, text)	addlinef(bp, "%s", text)
445 int		 anycb(int);
446 int		 bclear(struct buffer *);
447 int		 showbuffer(struct buffer *, struct mgwin *, int);
448 int		 augbname(char *, const char *, size_t);
449 struct mgwin    *popbuf(struct buffer *, int);
450 int		 bufferinsert(int, int);
451 int		 usebuffer(int, int);
452 int		 notmodified(int, int);
453 int		 popbuftop(struct buffer *, int);
454 int		 getbufcwd(char *, size_t);
455 int		 checkdirty(struct buffer *);
456 int		 revertbuffer(int, int);
457 int		 dorevert(void);
458 int		 diffbuffer(int, int);
459 struct buffer	*findbuffer(char *);
460 
461 /* display.c */
462 int		 vtresize(int, int, int);
463 void		 vtinit(void);
464 void		 vttidy(void);
465 void		 update(int);
466 int		 linenotoggle(int, int);
467 int		 colnotoggle(int, int);
468 
469 /* echo.c X */
470 void		 eerase(void);
471 int		 eyorn(const char *);
472 int		 eynorr(const char *);
473 int		 eyesno(const char *);
474 void		 ewprintf(const char *fmt, ...);
475 char		*eread(const char *, char *, size_t, int, ...)
476 				__attribute__((__format__ (printf, 1, 5)));
477 int		 getxtra(struct list *, struct list *, int, int);
478 void		 free_file_list(struct list *);
479 
480 /* fileio.c */
481 int		 ffropen(FILE **, const char *, struct buffer *);
482 void		 ffstat(FILE *, struct buffer *);
483 int		 ffwopen(FILE **, const char *, struct buffer *);
484 int		 ffclose(FILE *, struct buffer *);
485 int		 ffputbuf(FILE *, struct buffer *, int);
486 int		 ffgetline(FILE *, char *, int, int *);
487 int		 fbackupfile(const char *);
488 char		*adjustname(const char *, int);
489 FILE		*startupfile(char *, char *, char *, size_t);
490 int		 copy(char *, char *);
491 struct list	*make_file_list(char *);
492 int		 fisdir(const char *);
493 int		 fchecktime(struct buffer *);
494 int		 fupdstat(struct buffer *);
495 int		 backuptohomedir(int, int);
496 int		 toggleleavetmp(int, int);
497 char		*expandtilde(const char *);
498 
499 /* kbd.c X */
500 int		 do_meta(int, int);
501 int		 bsmap(int, int);
502 void		 ungetkey(int);
503 int		 getkey(int);
504 int		 doin(void);
505 int		 rescan(int, int);
506 int		 universal_argument(int, int);
507 int		 digit_argument(int, int);
508 int		 negative_argument(int, int);
509 int		 ask_selfinsert(int, int);
510 int		 selfinsert(int, int);
511 int		 quote(int, int);
512 
513 /* main.c */
514 int		 ctrlg(int, int);
515 int		 quit(int, int);
516 
517 /* ttyio.c */
518 void		 panic(char *);
519 
520 /* cinfo.c */
521 char		*getkeyname(char  *, size_t, int);
522 
523 /* basic.c */
524 int		 gotobol(int, int);
525 int		 backchar(int, int);
526 int		 gotoeol(int, int);
527 int		 forwchar(int, int);
528 int		 gotobob(int, int);
529 int		 gotoeob(int, int);
530 int		 forwline(int, int);
531 int		 backline(int, int);
532 void		 setgoal(void);
533 int		 getgoal(struct line *);
534 int		 forwpage(int, int);
535 int		 backpage(int, int);
536 int		 forw1page(int, int);
537 int		 back1page(int, int);
538 int		 pagenext(int, int);
539 void		 isetmark(void);
540 int		 setmark(int, int);
541 int		 clearmark(int, int);
542 int		 swapmark(int, int);
543 int		 gotoline(int, int);
544 int		 setlineno(int);
545 
546 /* util.c X */
547 int		 ntabstop(int, int);
548 int		 showcpos(int, int);
549 int		 getcolpos(struct mgwin *);
550 int		 twiddle(int, int);
551 int		 openline(int, int);
552 int		 enewline(int, int);
553 int		 deblank(int, int);
554 int		 justone(int, int);
555 int		 delwhite(int, int);
556 int		 delleadwhite(int, int);
557 int		 deltrailwhite(int, int);
558 int		 lfindent(int, int);
559 int		 indent(int, int);
560 int		 forwdel(int, int);
561 int		 backdel(int, int);
562 int		 space_to_tabstop(int, int);
563 int		 backtoindent(int, int);
564 int		 joinline(int, int);
565 
566 /* tags.c X */
567 int		 findtag(int, int);
568 int 		 poptag(int, int);
569 int		 tagsvisit(int, int);
570 int		 curtoken(int, int, char *);
571 
572 /* cscope.c */
573 int		 cssymbol(int, int);
574 int		 csdefinition(int, int);
575 int		 csfuncalled(int, int);
576 int		 cscallerfuncs(int, int);
577 int		 csfindtext(int, int);
578 int		 csegrep(int, int);
579 int		 csfindfile(int, int);
580 int		 csfindinc(int, int);
581 int		 csnextfile(int, int);
582 int		 csnextmatch(int, int);
583 int		 csprevfile(int, int);
584 int		 csprevmatch(int, int);
585 int		 cscreatelist(int, int);
586 
587 /* extend.c X */
588 int		 insert(int, int);
589 int		 bindtokey(int, int);
590 int		 localbind(int, int);
591 int		 redefine_key(int, int);
592 int		 unbindtokey(int, int);
593 int		 localunbind(int, int);
594 int		 extend(int, int);
595 int		 evalexpr(int, int);
596 int		 evalbuffer(int, int);
597 int		 evalfile(int, int);
598 int		 load(FILE *, const char *);
599 int		 excline(char *, int, int);
600 char		*skipwhite(char *);
601 
602 /* help.c X */
603 int		 desckey(int, int);
604 int		 wallchart(int, int);
605 int		 help_help(int, int);
606 int		 apropos_command(int, int);
607 
608 /* paragraph.c X */
609 int		 gotobop(int, int);
610 int		 gotoeop(int, int);
611 int		 fillpara(int, int);
612 int		 killpara(int, int);
613 int		 fillword(int, int);
614 int		 setfillcol(int, int);
615 int		 markpara(int, int);
616 int		 transposepara(int, int);
617 int		 sentencespace(int, int);
618 
619 /* word.c X */
620 int		 backword(int, int);
621 int		 forwword(int, int);
622 int		 upperword(int, int);
623 int		 lowerword(int, int);
624 int		 capword(int, int);
625 int		 delfword(int, int);
626 int		 delbword(int, int);
627 int		 inword(void);
628 int		 transposeword(int, int);
629 
630 /* region.c X */
631 int		 killregion(int, int);
632 int		 copyregion(int, int);
633 int		 lowerregion(int, int);
634 int		 upperregion(int, int);
635 int		 prefixregion(int, int);
636 int		 setprefix(int, int);
637 int		 region_get_data(struct region *, char *, int);
638 void		 region_put_data(const char *, int);
639 int		 markbuffer(int, int);
640 int		 piperegion(int, int);
641 int		 shellcommand(int, int);
642 int		 pipeio(const char * const, char * const[], char * const, int,
643 		     struct buffer *);
644 
645 /* search.c X */
646 int		 forwsearch(int, int);
647 int		 backsearch(int, int);
648 int		 searchagain(int, int);
649 int		 forwisearch(int, int);
650 int		 backisearch(int, int);
651 int		 queryrepl(int, int);
652 int		 forwsrch(void);
653 int		 backsrch(void);
654 int		 readpattern(char *);
655 int		 zapuptochar(int, int);
656 int		 zaptochar(int, int);
657 int		 zap(int, int);
658 
659 /* spawn.c X */
660 int		 spawncli(int, int);
661 
662 /* ttykbd.c X */
663 void		 ttykeymapinit(void);
664 void		 ttykeymaptidy(void);
665 
666 /* match.c X */
667 int		 showmatch(int, int);
668 
669 /* version.c X */
670 int		 showversion(int, int);
671 
672 /* macro.c X */
673 int		 definemacro(int, int);
674 int		 finishmacro(int, int);
675 int		 executemacro(int, int);
676 
677 /* modes.c X */
678 int		 indentmode(int, int);
679 int		 fillmode(int, int);
680 int		 notabmode(int, int);
681 int		 overwrite_mode(int, int);
682 int		 set_default_mode(int,int);
683 
684 #ifdef REGEX
685 /* re_search.c X */
686 int		 re_forwsearch(int, int);
687 int		 re_backsearch(int, int);
688 int		 re_searchagain(int, int);
689 int		 re_queryrepl(int, int);
690 int		 re_repl(int, int);
691 int		 replstr(int, int);
692 int		 setcasefold(int, int);
693 int		 delmatchlines(int, int);
694 int		 delnonmatchlines(int, int);
695 int		 cntmatchlines(int, int);
696 int		 cntnonmatchlines(int, int);
697 #endif	/* REGEX */
698 
699 /* undo.c X */
700 void		 free_undo_record(struct undo_rec *);
701 int		 undo_dump(int, int);
702 int		 undo_enabled(void);
703 int		 undo_enable(int, int);
704 int		 undo_add_boundary(int, int);
705 void		 undo_add_modified(void);
706 int		 undo_add_insert(struct line *, int, int);
707 int		 undo_add_delete(struct line *, int, int, int);
708 int		 undo_boundary_enable(int, int);
709 int		 undo_add_change(struct line *, int, int);
710 int		 undo(int, int);
711 
712 /* autoexec.c X */
713 int		 auto_execute(int, int);
714 PF		*find_autoexec(const char *);
715 int		 add_autoexec(const char *, const char *);
716 
717 /* cmode.c X */
718 int		 cmode(int, int);
719 int		 cc_brace(int, int);
720 int		 cc_char(int, int);
721 int		 cc_tab(int, int);
722 int		 cc_indent(int, int);
723 int		 cc_lfindent(int, int);
724 
725 /* grep.c X */
726 int		 next_error(int, int);
727 int		 globalwdtoggle(int, int);
728 int		 compile(int, int);
729 
730 /* bell.c */
731 void		 bellinit(void);
732 int		 toggleaudiblebell(int, int);
733 int		 togglevisiblebell(int, int);
734 int		 dobeep_num(const char *, int);
735 int		 dobeep_msgs(const char *, const char *);
736 int		 dobeep_msg(const char *);
737 void		 dobeep(void);
738 
739 /* interpreter.c */
740 int		 foundparen(char *, int, int);
741 void		 cleanup(void);
742 
743 /*
744  * Externals.
745  */
746 extern struct buffer	*bheadp;
747 extern struct buffer	*curbp;
748 extern struct mgwin	*curwp;
749 extern struct mgwin	*wheadp;
750 extern struct vhead	 varhead;
751 extern int		 thisflag;
752 extern int		 lastflag;
753 extern int		 curgoal;
754 extern int		 startrow;
755 extern int		 epresf;
756 extern int		 sgarbf;
757 extern int		 nrow;
758 extern int		 ncol;
759 extern int		 ttrow;
760 extern int		 ttcol;
761 extern int		 tttop;
762 extern int		 ttbot;
763 extern int		 tthue;
764 extern int		 defb_nmodes;
765 extern int		 defb_flag;
766 extern int		 doaudiblebell;
767 extern int		 dovisiblebell;
768 extern int		 dblspace;
769 extern int		 allbro;
770 extern int		 batch;
771 extern char	 	 cinfo[];
772 extern char		*keystrings[];
773 extern char		 pat[NPAT];
774 extern char		 prompt[];
775 extern int		 tceeol;
776 extern int		 tcinsl;
777 extern int		 tcdell;
778 extern int		 rptcount;	/* successive invocation count */
779