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