1 /*-
2  * Copyright (c) 1996
3  *	Keith Bostic.  All rights reserved.
4  *
5  * See the LICENSE file for redistribution information.
6  *
7  *	@(#)ip.h	8.3 (Berkeley) 10/13/96
8  */
9 
10 typedef struct _ip_private {
11 	int	 i_fd;		/* Input file descriptor. */
12 	int	 o_fd;		/* Output file descriptor. */
13 
14 	size_t	 row;		/* Current row. */
15 	size_t	 col;		/* Current column. */
16 
17 	size_t	 iblen;		/* Input buffer length. */
18 	size_t	 iskip;		/* Returned input buffer. */
19 	char	 ibuf[256];	/* Input buffer. */
20 
21 #define	IP_SCR_VI_INIT  0x0001  /* Vi screen initialized. */
22 	u_int32_t flags;
23 } IP_PRIVATE;
24 
25 #define	IPP(sp)		((IP_PRIVATE *)((sp)->gp->ip_private))
26 #define	GIPP(gp)	((IP_PRIVATE *)((gp)->ip_private))
27 
28 /* The screen line relative to a specific window. */
29 #define	RLNO(sp, lno)	(sp)->woff + (lno)
30 
31 /*
32  * The IP protocol consists of frames, each containing:
33  *
34  *	<IPO_><object>
35  *
36  * XXX
37  * We should have a marking byte, 0xaa to delimit frames.
38  *
39  */
40 #define	IPO_CODE	1	/* An event specification. */
41 #define	IPO_INT		2	/* 4-byte, network order integer. */
42 #define	IPO_STR		3	/* IPO_INT: followed by N bytes. */
43 
44 #define	IPO_CODE_LEN	1
45 #define	IPO_INT_LEN	4
46 
47 /* A structure that can hold the information for any frame. */
48 typedef struct _ip_buf {
49 	int code;		/* Event code. */
50 	const char *str;	/* String. */
51 	size_t len;		/* String length. */
52 	u_int32_t val1;		/* First value. */
53 	u_int32_t val2;		/* Second value. */
54 } IP_BUF;
55 
56 /*
57  * Screen/editor IP_CODE's.
58  *
59  * The program structure depends on the event loop being able to return
60  * IPO_EOF/IPOE_ERR multiple times -- eventually enough things will end
61  * due to the events that vi will reach the command level for the screen,
62  * at which point the exit flags will be set and vi will exit.
63  *
64  * IP events sent from the screen to vi.
65  */
66 #define	IPO_EOF		 1	/* End of input (NOT ^D). */
67 #define	IPO_ERR		 2	/* Input error. */
68 #define	IPO_INTERRUPT	 3	/* Interrupt. */
69 #define	IPO_QUIT	 4	/* Quit. */
70 #define	IPO_RESIZE	 5	/* Screen resize: IPO_INT, IPO_INT. */
71 #define	IPO_SIGHUP	 6	/* SIGHUP. */
72 #define	IPO_SIGTERM	 7	/* SIGTERM. */
73 #define	IPO_STRING	 8	/* Input string: IPO_STR. */
74 #define	IPO_WRITE	 9	/* Write. */
75 
76 /*
77  * IP events sent from vi to the screen.
78  */
79 #define	IPO_ADDSTR	 1	/* Add a string: IPO_STR. */
80 #define	IPO_ATTRIBUTE	 2	/* Set screen attribute: IPO_INT, IPO_INT. */
81 #define	IPO_BELL	 3	/* Beep/bell/flash the terminal. */
82 #define	IPO_BUSY	 4	/* Display a busy message: IPO_STR. */
83 #define	IPO_CLRTOEOL	 5	/* Clear to the end of the line. */
84 #define	IPO_DELETELN	 6	/* Delete a line. */
85 #define	IPO_INSERTLN	 7	/* Insert a line. */
86 #define	IPO_MOVE	 8	/* Move the cursor: IPO_INT, IPO_INT. */
87 #define	IPO_REDRAW	 9	/* Redraw the screen. */
88 #define	IPO_REFRESH	10	/* Refresh the screen. */
89 #define	IPO_RENAME	11	/* Rename the screen: IPO_STR. */
90 #define	IPO_REWRITE	12	/* Rewrite a line: IPO_INT. */
91 
92 #include "ip_extern.h"
93