ifdef checks so doesn't get included more than once.
[screen-lua.git] / src / window.h
blobce6af93726bf9f8755392e5fe6e7db0580f6900f
1 /* Copyright (c) 2008, 2009
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Micah Cowan (micah@cowan.name)
5 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
6 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
7 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
8 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
9 * Copyright (c) 1987 Oliver Laumann
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3, or (at your option)
14 * any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program (see the file COPYING); if not, see
23 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 ****************************************************************
27 * $Id$ FAU
30 #ifndef SCREEN_WINDOW_H
31 #define SCREEN_WINDOW_H
33 /* keep this in sync with the initialisations in window.c */
34 struct NewWindow
36 int StartAt; /* where to start the search for the slot */
37 char *aka; /* aka string */
38 char **args; /* argv vector */
39 char *dir; /* directory for chdir */
40 char *term; /* TERM to be set instead of "screen" */
41 int aflag;
42 int flowflag;
43 int lflag;
44 int histheight;
45 int monitor;
46 int wlock; /* default writelock setting */
47 int silence;
48 int wrap;
49 int Lflag; /* logging */
50 int slow; /* inter character milliseconds */
51 int gr;
52 int c1;
53 int bce;
54 int encoding;
55 char *hstatus;
56 char *charset;
59 #ifdef PSEUDOS
61 struct pseudowin
63 int p_fdpat;
64 int p_pid;
65 int p_ptyfd;
66 struct event p_readev;
67 struct event p_writeev;
68 char p_cmd[MAXSTR];
69 char p_tty[MAXSTR];
70 char p_inbuf[IOSIZE]; /* buffered writing to p_ptyfd */
71 int p_inlen;
74 /* bits for fdpat: */
75 #define F_PMASK 0x0003
76 #define F_PSHIFT 2
77 #define F_PFRONT 0x0001 /* . */
78 #define F_PBACK 0x0002 /* ! */
79 #define F_PBOTH (F_PFRONT | F_PBACK) /* : */
81 #define F_UWP 0x1000 /* | */
83 /* The screen process ...)
84 * ... wants to write to pseudo */
85 #define W_WP(w) ((w)->w_pwin && ((w)->w_pwin->p_fdpat & F_PFRONT))
87 /* ... wants to write to window: user writes to window
88 * or stdout/stderr of pseudo are duplicated to window */
89 #define W_WW(w) (!((w)->w_pwin) || \
90 (((w)->w_pwin->p_fdpat & F_PMASK) == F_PBACK) || \
91 ((((w)->w_pwin->p_fdpat >> F_PSHIFT) & F_PMASK) == F_PBOTH) || \
92 ((((w)->w_pwin->p_fdpat >> (F_PSHIFT * 2)) & F_PMASK) == F_PBOTH))
94 /* ... wants to read from pseudowin */
95 #define W_RP(w) ((w)->w_pwin && ((w)->w_pwin->p_fdpat & \
96 ((F_PFRONT << (F_PSHIFT * 2)) | (F_PFRONT << F_PSHIFT)) ))
98 /* ... wants to read from window */
99 #define W_RW(w) (!((w)->w_pwin) || ((w)->w_pwin->p_fdpat & F_PFRONT))
101 /* user input is written to pseudo */
102 #define W_UWP(w) ((w)->w_pwin && ((w)->w_pwin->p_fdpat & F_UWP))
104 /* pseudo output has to be stuffed in window */
105 #define W_PTOW(w) (\
106 ((w)->w_pwin->p_fdpat & F_PMASK << F_PSHIFT) == F_PBOTH << F_PSHIFT || \
107 ((w)->w_pwin->p_fdpat & F_PMASK << F_PSHIFT * 2) == F_PBOTH << F_PSHIFT * 2 )
109 /* window output has to be stuffed in pseudo */
110 #define W_WTOP(w) (((w)->w_pwin->p_fdpat & F_PMASK) == F_PBOTH)
112 #endif /* PSEUDOS */
114 /* definitions for wlocktype */
115 #define WLOCK_OFF 0 /* all in w_userbits can write */
116 #define WLOCK_AUTO 1 /* who selects first, can write */
117 #define WLOCK_ON 2 /* user writes even if deselected */
120 #ifdef COPY_PASTE
121 struct paster
123 char *pa_pastebuf; /* this gets pasted in the window */
124 char *pa_pasteptr; /* pointer in pastebuf */
125 int pa_pastelen; /* bytes left to paste */
126 struct layer *pa_pastelayer; /* layer to paste into */
127 struct event pa_slowev; /* slowpaste event */
129 #else
130 struct paster;
131 #endif
133 struct win
135 struct win *w_next; /* next window */
136 int w_type; /* type of window */
137 void *w_data;
138 struct layer w_layer; /* our layer */
139 struct layer *w_savelayer; /* the layer to keep */
140 int w_blocked; /* block input */
141 #ifdef PSEUDOS
142 struct pseudowin *w_pwin; /* ptr to pseudo */
143 #endif
144 struct display *w_pdisplay; /* display for printer relay */
145 struct display *w_lastdisp; /* where the last input was made */
146 int w_number; /* window number */
147 struct event w_readev;
148 struct event w_writeev;
149 struct event w_silenceev; /* silence event */
150 int w_ptyfd; /* fd of the master pty */
151 char w_inbuf[IOSIZE];
152 int w_inlen;
153 char w_outbuf[IOSIZE];
154 int w_outlen;
155 int w_aflag; /* (-a option) */
156 char *w_title; /* name of the window */
157 char *w_akachange; /* autoaka hack */
158 char w_akabuf[MAXSTR]; /* aka buffer */
159 int w_autoaka; /* autoaka hack */
160 struct win *w_group; /* window group we belong to */
161 int w_intermediate; /* char used while parsing ESC-seq */
162 int w_args[MAXARGS]; /* emulator args */
163 int w_NumArgs;
165 #ifdef MULTIUSER
166 int w_wlock; /* WLOCK_AUTO, WLOCK_OFF, WLOCK_ON */
167 struct acluser *w_wlockuser; /* NULL when unlocked or user who writes */
168 AclBits w_userbits[ACL_BITS_PER_WIN];
169 AclBits w_lio_notify; /* whom to tell when lastio+seconds < time() */
170 AclBits w_mon_notify; /* whom to tell monitor statis */
171 #endif
173 enum state_t w_state; /* parser state */
174 enum string_t w_StringType;
175 struct mline *w_mlines;
176 struct mchar w_rend; /* current rendition */
177 #ifdef FONT
178 char w_FontL; /* character font GL */
179 char w_FontR; /* character font GR */
180 # ifdef ENCODINGS
181 char w_FontE; /* character font GR locked */
182 # endif
183 int w_Charset; /* charset number GL */
184 int w_CharsetR; /* charset number GR */
185 int w_charsets[4]; /* Font = charsets[Charset] */
186 #endif
187 int w_ss;
188 int w_saved;
189 int w_Saved_x, w_Saved_y;
190 struct mchar w_SavedRend;
191 #ifdef FONT
192 int w_SavedCharset;
193 int w_SavedCharsetR;
194 int w_SavedCharsets[4];
195 #endif
196 int w_top, w_bot; /* scrollregion */
197 int w_wrap; /* autowrap */
198 int w_origin; /* origin mode */
199 int w_insert; /* window is in insert mode */
200 int w_keypad; /* keypad mode */
201 int w_cursorkeys; /* appl. cursorkeys mode */
202 int w_revvid; /* reverse video */
203 int w_curinv; /* cursor invisible */
204 int w_curvvis; /* cursor very visible */
205 int w_autolf; /* automatic linefeed */
206 char *w_hstatus; /* hardstatus line */
207 int w_gr; /* enable GR flag */
208 int w_c1; /* enable C1 flag */
209 int w_bce; /* enable backcol erase */
210 #if 0
211 int w_encoding; /* for input and paste */
212 #endif
213 int w_decodestate; /* state of our input decoder */
214 #ifdef DW_CHARS
215 int w_mbcs; /* saved char for multibytes charset */
216 #endif
217 char w_string[MAXSTR];
218 char *w_stringp;
219 char *w_tabs; /* line with tabs */
220 int w_bell; /* bell status of this window */
221 int w_flow; /* flow flags */
222 struct logfile *w_log; /* log to file */
223 int w_logsilence; /* silence in secs */
224 int w_monitor; /* monitor status */
225 int w_silencewait; /* wait for silencewait secs */
226 int w_silence; /* silence status (Lloyd Zusman) */
227 char w_vbwait;
228 char w_norefresh; /* dont redisplay when switching to that win */
229 #ifdef RXVT_OSC
230 char w_xtermosc[4][MAXSTR]; /* special xterm/rxvt escapes */
231 #endif
232 int w_mouse; /* mouse mode 0,9,1000 */
233 #ifdef HAVE_BRAILLE
234 int w_bd_x, w_bd_y; /* Braille cursor position */
235 #endif
237 #ifdef COPY_PASTE
238 int w_slowpaste; /* do careful writes to the window */
239 int w_histheight; /* all histbases are malloced with width * histheight */
240 int w_histidx; /* 0 <= histidx < histheight; where we insert lines */
241 struct mline *w_hlines; /* history buffer */
242 struct paster w_paster; /* paste info */
243 #else
244 int w_histheight; /* always 0 */
245 #endif
246 int w_pid; /* process at the other end of ptyfd */
247 int w_deadpid; /* saved w_pid of a process that closed the ptyfd to us */
249 char *w_cmdargs[MAXARGS]; /* command line argument vector */
250 char *w_dir; /* directory for chdir */
251 char *w_term; /* TERM to be set instead of "screen" */
253 int w_lflag; /* login flag */
254 slot_t w_slot; /* utmp slot */
255 #if defined (UTMPOK)
256 struct utmp w_savut; /* utmp entry of this window */
257 #endif
259 char w_tty[MAXSTR];
261 int w_zauto;
262 #ifdef ZMODEM
263 struct display *w_zdisplay;
264 #endif
265 #ifdef BUILTIN_TELNET
266 struct sockaddr_in w_telsa;
267 char w_telbuf[IOSIZE];
268 int w_telbufl;
269 char w_telmopts[256];
270 char w_telropts[256];
271 int w_telstate;
272 char w_telsubbuf[128];
273 int w_telsubidx;
274 struct event w_telconnev;
275 #endif
276 struct mline *w_alt_mlines;
277 int w_alt_width;
278 int w_alt_height;
279 int w_alt_histheight;
280 int w_alt_x, w_alt_y;
281 #ifdef COPY_PASTE
282 struct mline *w_alt_hlines;
283 int w_alt_histidx;
284 #endif
288 #define w_encoding w_layer.l_encoding
289 #define w_width w_layer.l_width
290 #define w_height w_layer.l_height
291 #define w_x w_layer.l_x
292 #define w_y w_layer.l_y
294 /* definitions for w_type */
295 #define W_TYPE_PTY 0
296 #define W_TYPE_PLAIN 1
297 #define W_TYPE_TELNET 2
298 #define W_TYPE_GROUP 3
302 * Definitions for flow
303 * 000 -(-) flow off, auto would be off
304 * 001 +(-) flow on , auto would be off
305 * 010 -(+) flow off, auto would be on
306 * 011 +(+) flow on , auto would be on
307 * 100 - flow auto, currently off
308 * 111 + flow auto, currently on
309 * Application controls auto_flow via TIOCPKT, if available,
310 * else via application keypad mode.
312 #define FLOW_NOW (1<<0)
313 #define FLOW_AUTO (1<<1)
314 #define FLOW_AUTOFLAG (1<<2)
318 * WIN gives us a reference to line y of the *whole* image
319 * where line 0 is the oldest line in our history.
320 * y must be in whole image coordinate system, not in display.
323 #define WIN(y) ((y < fore->w_histheight) ? \
324 &fore->w_hlines[(fore->w_histidx + y) % fore->w_histheight] \
325 : &fore->w_mlines[y - fore->w_histheight])
327 #define Layer2Window(l) ((struct win *)(l)->l_bottom->l_data)
329 #endif /* SCREEN_WINDOW_H */