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