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