xref: /openbsd-src/usr.bin/vi/common/msg.h (revision d4e7c603042317101df5b56db72417d951eb90f7)
1*d4e7c603Sniklas /*	$OpenBSD: msg.h,v 1.3 2001/01/29 01:58:31 niklas Exp $	*/
2*d4e7c603Sniklas 
3df930be7Sderaadt /*-
4df930be7Sderaadt  * Copyright (c) 1993, 1994
5df930be7Sderaadt  *	The Regents of the University of California.  All rights reserved.
645f2ab88Sderaadt  * Copyright (c) 1993, 1994, 1995, 1996
745f2ab88Sderaadt  *	Keith Bostic.  All rights reserved.
8df930be7Sderaadt  *
945f2ab88Sderaadt  * See the LICENSE file for redistribution information.
10df930be7Sderaadt  *
1145f2ab88Sderaadt  *	@(#)msg.h	10.10 (Berkeley) 5/10/96
12df930be7Sderaadt  */
13df930be7Sderaadt 
14df930be7Sderaadt /*
1545f2ab88Sderaadt  * Common messages (continuation or confirmation).
1645f2ab88Sderaadt  */
1745f2ab88Sderaadt typedef enum {
1845f2ab88Sderaadt 	CMSG_CONF, CMSG_CONT, CMSG_CONT_EX,
1945f2ab88Sderaadt 	CMSG_CONT_R, CMSG_CONT_S, CMSG_CONT_Q } cmsg_t;
2045f2ab88Sderaadt 
2145f2ab88Sderaadt /*
22df930be7Sderaadt  * Message types.
23df930be7Sderaadt  *
24df930be7Sderaadt  * !!!
25df930be7Sderaadt  * In historical vi, O_VERBOSE didn't exist, and O_TERSE made the error
26df930be7Sderaadt  * messages shorter.  In this implementation, O_TERSE has no effect and
2745f2ab88Sderaadt  * O_VERBOSE results in informational displays about common errors, for
28df930be7Sderaadt  * naive users.
29df930be7Sderaadt  *
3045f2ab88Sderaadt  * M_NONE	Display to the user, no reformatting, no nothing.
3145f2ab88Sderaadt  *
32df930be7Sderaadt  * M_BERR	Error: M_ERR if O_VERBOSE, else bell.
33df930be7Sderaadt  * M_ERR	Error: Display in inverse video.
34df930be7Sderaadt  * M_INFO	 Info: Display in normal video.
35df930be7Sderaadt  * M_SYSERR	Error: M_ERR, using strerror(3) message.
36df930be7Sderaadt  * M_VINFO	 Info: M_INFO if O_VERBOSE, else ignore.
3745f2ab88Sderaadt  *
3845f2ab88Sderaadt  * The underlying message display routines only need to know about M_NONE,
3945f2ab88Sderaadt  * M_ERR and M_INFO -- all the other message types are converted into one
4045f2ab88Sderaadt  * of them by the message routines.
41df930be7Sderaadt  */
4245f2ab88Sderaadt typedef enum {
4345f2ab88Sderaadt 	M_NONE = 1, M_BERR, M_ERR, M_INFO, M_SYSERR, M_VINFO } mtype_t;
44df930be7Sderaadt 
45df930be7Sderaadt /*
4645f2ab88Sderaadt  * There are major problems with error messages being generated by routines
4745f2ab88Sderaadt  * preparing the screen to display error messages.  It's possible for the
4845f2ab88Sderaadt  * editor to generate messages before we have a screen in which to display
4945f2ab88Sderaadt  * them, or during the transition between ex (and vi startup) and a true vi.
5045f2ab88Sderaadt  * There's a queue in the global area to hold them.
5145f2ab88Sderaadt  *
5245f2ab88Sderaadt  * If SC_EX/SC_VI is set, that's the mode that the editor is in.  If the flag
5345f2ab88Sderaadt  * S_SCREEN_READY is set, that means that the screen is prepared to display
5445f2ab88Sderaadt  * messages.
55df930be7Sderaadt  */
5645f2ab88Sderaadt typedef struct _msgh MSGH;	/* MSGS list head structure. */
5745f2ab88Sderaadt LIST_HEAD(_msgh, _msg);
5845f2ab88Sderaadt struct _msg {
5945f2ab88Sderaadt 	LIST_ENTRY(_msg) q;	/* Linked list of messages. */
6045f2ab88Sderaadt 	mtype_t	 mtype;		/* Message type: M_NONE, M_ERR, M_INFO. */
6145f2ab88Sderaadt 	char	*buf;		/* Message buffer. */
6245f2ab88Sderaadt 	size_t	 len;		/* Message length. */
6345f2ab88Sderaadt };
64df930be7Sderaadt 
6545f2ab88Sderaadt /* Flags to msgq_status(). */
6645f2ab88Sderaadt #define	MSTAT_SHOWLAST	0x01	/* Show the line number of the last line. */
6745f2ab88Sderaadt #define	MSTAT_TRUNCATE	0x02	/* Truncate the file name if it's too long. */
68