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)
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 ****************************************************************
30 #ifndef SCREEN_WINDOW_H
31 #define SCREEN_WINDOW_H
33 /* keep this in sync with the initialisations in window.c */
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" */
46 int wlock
; /* default writelock setting */
49 int Lflag
; /* logging */
50 int slow
; /* inter character milliseconds */
66 struct event p_readev
;
67 struct event p_writeev
;
70 char p_inbuf
[IOSIZE
]; /* buffered writing to p_ptyfd */
75 #define F_PMASK 0x0003
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 */
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)
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 */
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 */
135 struct win
*w_next
; /* next window */
136 int w_type
; /* type of window */
138 struct layer w_layer
; /* our layer */
139 struct layer
*w_savelayer
; /* the layer to keep */
140 int w_blocked
; /* block input */
142 struct pseudowin
*w_pwin
; /* ptr to pseudo */
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
];
153 char w_outbuf
[IOSIZE
];
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 */
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 */
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 */
178 char w_FontL
; /* character font GL */
179 char w_FontR
; /* character font GR */
181 char w_FontE
; /* character font GR locked */
183 int w_Charset
; /* charset number GL */
184 int w_CharsetR
; /* charset number GR */
185 int w_charsets
[4]; /* Font = charsets[Charset] */
189 int w_Saved_x
, w_Saved_y
;
190 struct mchar w_SavedRend
;
194 int w_SavedCharsets
[4];
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 */
211 int w_encoding
; /* for input and paste */
213 int w_decodestate
; /* state of our input decoder */
215 int w_mbcs
; /* saved char for multibytes charset */
217 char w_string
[MAXSTR
];
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) */
228 char w_norefresh
; /* dont redisplay when switching to that win */
230 char w_xtermosc
[4][MAXSTR
]; /* special xterm/rxvt escapes */
232 int w_mouse
; /* mouse mode 0,9,1000 */
234 int w_bd_x
, w_bd_y
; /* Braille cursor position */
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 */
244 int w_histheight
; /* always 0 */
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 */
256 struct utmp w_savut
; /* utmp entry of this window */
263 struct display
*w_zdisplay
;
265 #ifdef BUILTIN_TELNET
266 struct sockaddr_in w_telsa
;
267 char w_telbuf
[IOSIZE
];
269 char w_telmopts
[256];
270 char w_telropts
[256];
272 char w_telsubbuf
[128];
274 struct event w_telconnev
;
276 struct mline
*w_alt_mlines
;
279 int w_alt_histheight
;
280 int w_alt_x
, w_alt_y
;
282 struct mline
*w_alt_hlines
;
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 */
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 */