xref: /freebsd/contrib/nvi/common/msg.h (revision 193d9e768ba63fcfb187cfd17f461f7d41345048)
1 /*-
2  * Copyright (c) 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  * Copyright (c) 1993, 1994, 1995, 1996
5  *	Keith Bostic.  All rights reserved.
6  *
7  * See the LICENSE file for redistribution information.
8  *
9  *	@(#)msg.h	10.10 (Berkeley) 5/10/96
10  */
11 
12 /*
13  * Common messages (continuation or confirmation).
14  */
15 typedef enum {
16 	CMSG_CONF, CMSG_CONT, CMSG_CONT_EX,
17 	CMSG_CONT_R, CMSG_CONT_S, CMSG_CONT_Q } cmsg_t;
18 
19 /*
20  * Message types.
21  *
22  * !!!
23  * In historical vi, O_VERBOSE didn't exist, and O_TERSE made the error
24  * messages shorter.  In this implementation, O_TERSE has no effect and
25  * O_VERBOSE results in informational displays about common errors, for
26  * naive users.
27  *
28  * M_NONE	Display to the user, no reformatting, no nothing.
29  *
30  * M_BERR	Error: M_ERR if O_VERBOSE, else bell.
31  * M_ERR	Error: Display in inverse video.
32  * M_INFO	 Info: Display in normal video.
33  * M_SYSERR	Error: M_ERR, using strerror(3) message.
34  * M_VINFO	 Info: M_INFO if O_VERBOSE, else ignore.
35  *
36  * The underlying message display routines only need to know about M_NONE,
37  * M_ERR and M_INFO -- all the other message types are converted into one
38  * of them by the message routines.
39  */
40 typedef enum {
41 	M_NONE = 1, M_BERR, M_ERR, M_INFO, M_SYSERR, M_VINFO } mtype_t;
42 
43 /*
44  * There are major problems with error messages being generated by routines
45  * preparing the screen to display error messages.  It's possible for the
46  * editor to generate messages before we have a screen in which to display
47  * them, or during the transition between ex (and vi startup) and a true vi.
48  * There's a queue in the global area to hold them.
49  *
50  * If SC_EX/SC_VI is set, that's the mode that the editor is in.  If the flag
51  * S_SCREEN_READY is set, that means that the screen is prepared to display
52  * messages.
53  */
54 typedef struct _msgh MSGH;	/* MSGS list head structure. */
55 SLIST_HEAD(_msgh, _msg);
56 struct _msg {
57 	SLIST_ENTRY(_msg) q;	/* Linked list of messages. */
58 	mtype_t	 mtype;		/* Message type: M_NONE, M_ERR, M_INFO. */
59 	char	*buf;		/* Message buffer. */
60 	size_t	 len;		/* Message length. */
61 };
62 
63 /* Flags to msgq_status(). */
64 #define	MSTAT_SHOWLAST	0x01	/* Show the line number of the last line. */
65 #define	MSTAT_TRUNCATE	0x02	/* Truncate the file name if it's too long. */
66