xref: /openbsd/usr.bin/vi/cl/cl.h (revision d373ec5f)
1 /*	$OpenBSD: cl.h,v 1.12 2021/09/02 11:19:02 schwarze Exp $	*/
2 
3 /*-
4  * Copyright (c) 1993, 1994
5  *	The Regents of the University of California.  All rights reserved.
6  * Copyright (c) 1993, 1994, 1995, 1996
7  *	Keith Bostic.  All rights reserved.
8  *
9  * See the LICENSE file for redistribution information.
10  *
11  *	@(#)cl.h	10.19 (Berkeley) 9/24/96
12  */
13 
14 extern	volatile sig_atomic_t cl_sigint;
15 extern	volatile sig_atomic_t cl_sigterm;
16 extern	volatile sig_atomic_t cl_sigwinch;
17 
18 typedef struct _cl_private {
19 	CHAR_T	 ibuf[256];	/* Input keys. */
20 
21 	int	 eof_count;	/* EOF count. */
22 
23 	struct termios orig;	/* Original terminal values. */
24 	struct termios ex_enter;/* Terminal values to enter ex. */
25 	struct termios vi_enter;/* Terminal values to enter vi. */
26 
27 	char	*el;		/* Clear to EOL terminal string. */
28 	char	*cup;		/* Cursor movement terminal string. */
29 	char	*cuu1;		/* Cursor up terminal string. */
30 	char	*rmso, *smso;	/* Inverse video terminal strings. */
31 	char	*smcup, *rmcup;	/* Terminal start/stop strings. */
32 
33 #define	INDX_HUP	0
34 #define	INDX_INT	1
35 #define	INDX_TERM	2
36 #define	INDX_WINCH	3
37 #define	INDX_MAX	4	/* Original signal information. */
38 	struct sigaction oact[INDX_MAX];
39 
40 	enum {			/* Tty group write mode. */
41 	    TGW_UNKNOWN=0, TGW_SET, TGW_UNSET } tgw;
42 
43 	enum {			/* Terminal initialization strings. */
44 	    TE_SENT=0, TI_SENT } ti_te;
45 
46 #define	CL_IN_EX	0x0001	/* Currently running ex. */
47 #define	CL_RENAME	0x0002	/* X11 xterm icon/window renamed. */
48 #define	CL_RENAME_OK	0x0004	/* User wants the windows renamed. */
49 #define	CL_SCR_EX_INIT	0x0008	/* Ex screen initialized. */
50 #define	CL_SCR_VI_INIT	0x0010	/* Vi screen initialized. */
51 #define	CL_STDIN_TTY	0x0020	/* Talking to a terminal. */
52 	u_int32_t flags;
53 } CL_PRIVATE;
54 
55 #define	CLP(sp)		((CL_PRIVATE *)((sp)->gp->cl_private))
56 #define	GCLP(gp)	((CL_PRIVATE *)(gp)->cl_private)
57 
58 /* Return possibilities from the keyboard read routine. */
59 typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t;
60 
61 /* The screen line relative to a specific window. */
62 #define	RLNO(sp, lno)	(sp)->woff + (lno)
63 
64 /* X11 xterm escape sequence to rename the icon/window. */
65 #define	XTERM_RENAME	"\033]0;%s\007"
66 
67 #include "cl_extern.h"
68