2183bb912f18c8f8e370b8cbfd93dcb2d13179f1
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 ****************************************************************
31 /* keep this in sync with the initialisations in window.c */
34 int StartAt
; /* where to start the search for the slot */
35 char *aka
; /* aka string */
36 char **args
; /* argv vector */
37 char *dir
; /* directory for chdir */
38 char *term
; /* TERM to be set instead of "screen" */
44 int wlock
; /* default writelock setting */
47 int Lflag
; /* logging */
48 int slow
; /* inter character milliseconds */
64 struct event p_readev
;
65 struct event p_writeev
;
68 char p_inbuf
[IOSIZE
]; /* buffered writing to p_ptyfd */
73 #define F_PMASK 0x0003
75 #define F_PFRONT 0x0001 /* . */
76 #define F_PBACK 0x0002 /* ! */
77 #define F_PBOTH (F_PFRONT | F_PBACK) /* : */
79 #define F_UWP 0x1000 /* | */
81 /* The screen process ...)
82 * ... wants to write to pseudo */
83 #define W_WP(w) ((w)->w_pwin && ((w)->w_pwin->p_fdpat & F_PFRONT))
85 /* ... wants to write to window: user writes to window
86 * or stdout/stderr of pseudo are duplicated to window */
87 #define W_WW(w) (!((w)->w_pwin) || \
88 (((w)->w_pwin->p_fdpat & F_PMASK) == F_PBACK) || \
89 ((((w)->w_pwin->p_fdpat >> F_PSHIFT) & F_PMASK) == F_PBOTH) || \
90 ((((w)->w_pwin->p_fdpat >> (F_PSHIFT * 2)) & F_PMASK) == F_PBOTH))
92 /* ... wants to read from pseudowin */
93 #define W_RP(w) ((w)->w_pwin && ((w)->w_pwin->p_fdpat & \
94 ((F_PFRONT << (F_PSHIFT * 2)) | (F_PFRONT << F_PSHIFT)) ))
96 /* ... wants to read from window */
97 #define W_RW(w) (!((w)->w_pwin) || ((w)->w_pwin->p_fdpat & F_PFRONT))
99 /* user input is written to pseudo */
100 #define W_UWP(w) ((w)->w_pwin && ((w)->w_pwin->p_fdpat & F_UWP))
102 /* pseudo output has to be stuffed in window */
104 ((w)->w_pwin->p_fdpat & F_PMASK << F_PSHIFT) == F_PBOTH << F_PSHIFT || \
105 ((w)->w_pwin->p_fdpat & F_PMASK << F_PSHIFT * 2) == F_PBOTH << F_PSHIFT * 2 )
107 /* window output has to be stuffed in pseudo */
108 #define W_WTOP(w) (((w)->w_pwin->p_fdpat & F_PMASK) == F_PBOTH)
112 /* definitions for wlocktype */
113 #define WLOCK_OFF 0 /* all in w_userbits can write */
114 #define WLOCK_AUTO 1 /* who selects first, can write */
115 #define WLOCK_ON 2 /* user writes even if deselected */
121 char *pa_pastebuf
; /* this gets pasted in the window */
122 char *pa_pasteptr
; /* pointer in pastebuf */
123 int pa_pastelen
; /* bytes left to paste */
124 struct layer
*pa_pastelayer
; /* layer to paste into */
125 struct event pa_slowev
; /* slowpaste event */
133 struct win
*w_next
; /* next window */
134 int w_type
; /* type of window */
136 struct layer w_layer
; /* our layer */
137 struct layer
*w_savelayer
; /* the layer to keep */
138 int w_blocked
; /* block input */
140 struct pseudowin
*w_pwin
; /* ptr to pseudo */
142 struct display
*w_pdisplay
; /* display for printer relay */
143 struct display
*w_lastdisp
; /* where the last input was made */
144 int w_number
; /* window number */
145 struct event w_readev
;
146 struct event w_writeev
;
147 struct event w_silenceev
; /* silence event */
148 int w_ptyfd
; /* fd of the master pty */
149 char w_inbuf
[IOSIZE
];
151 char w_outbuf
[IOSIZE
];
153 int w_aflag
; /* (-a option) */
154 char *w_title
; /* name of the window */
155 char *w_akachange
; /* autoaka hack */
156 char w_akabuf
[MAXSTR
]; /* aka buffer */
157 int w_autoaka
; /* autoaka hack */
158 struct win
*w_group
; /* window group we belong to */
159 int w_intermediate
; /* char used while parsing ESC-seq */
160 int w_args
[MAXARGS
]; /* emulator args */
164 int w_wlock
; /* WLOCK_AUTO, WLOCK_OFF, WLOCK_ON */
165 struct acluser
*w_wlockuser
; /* NULL when unlocked or user who writes */
166 AclBits w_userbits
[ACL_BITS_PER_WIN
];
167 AclBits w_lio_notify
; /* whom to tell when lastio+seconds < time() */
168 AclBits w_mon_notify
; /* whom to tell monitor statis */
171 enum state_t w_state
; /* parser state */
172 enum string_t w_StringType
;
173 struct mline
*w_mlines
;
174 struct mchar w_rend
; /* current rendition */
176 char w_FontL
; /* character font GL */
177 char w_FontR
; /* character font GR */
179 char w_FontE
; /* character font GR locked */
181 int w_Charset
; /* charset number GL */
182 int w_CharsetR
; /* charset number GR */
183 int w_charsets
[4]; /* Font = charsets[Charset] */
187 int w_Saved_x
, w_Saved_y
;
188 struct mchar w_SavedRend
;
192 int w_SavedCharsets
[4];
194 int w_top
, w_bot
; /* scrollregion */
195 int w_wrap
; /* autowrap */
196 int w_origin
; /* origin mode */
197 int w_insert
; /* window is in insert mode */
198 int w_keypad
; /* keypad mode */
199 int w_cursorkeys
; /* appl. cursorkeys mode */
200 int w_revvid
; /* reverse video */
201 int w_curinv
; /* cursor invisible */
202 int w_curvvis
; /* cursor very visible */
203 int w_autolf
; /* automatic linefeed */
204 char *w_hstatus
; /* hardstatus line */
205 int w_gr
; /* enable GR flag */
206 int w_c1
; /* enable C1 flag */
207 int w_bce
; /* enable backcol erase */
209 int w_encoding
; /* for input and paste */
211 int w_decodestate
; /* state of our input decoder */
213 int w_mbcs
; /* saved char for multibytes charset */
215 char w_string
[MAXSTR
];
217 char *w_tabs
; /* line with tabs */
218 int w_bell
; /* bell status of this window */
219 int w_flow
; /* flow flags */
220 struct logfile
*w_log
; /* log to file */
221 int w_logsilence
; /* silence in secs */
222 int w_monitor
; /* monitor status */
223 int w_silencewait
; /* wait for silencewait secs */
224 int w_silence
; /* silence status (Lloyd Zusman) */
226 char w_norefresh
; /* dont redisplay when switching to that win */
228 char w_xtermosc
[4][MAXSTR
]; /* special xterm/rxvt escapes */
230 int w_mouse
; /* mouse mode 0,9,1000 */
232 int w_bd_x
, w_bd_y
; /* Braille cursor position */
236 int w_slowpaste
; /* do careful writes to the window */
237 int w_histheight
; /* all histbases are malloced with width * histheight */
238 int w_histidx
; /* 0 <= histidx < histheight; where we insert lines */
239 struct mline
*w_hlines
; /* history buffer */
240 struct paster w_paster
; /* paste info */
242 int w_histheight
; /* always 0 */
244 int w_pid
; /* process at the other end of ptyfd */
245 int w_deadpid
; /* saved w_pid of a process that closed the ptyfd to us */
247 char *w_cmdargs
[MAXARGS
]; /* command line argument vector */
248 char *w_dir
; /* directory for chdir */
249 char *w_term
; /* TERM to be set instead of "screen" */
251 int w_lflag
; /* login flag */
252 slot_t w_slot
; /* utmp slot */
254 struct utmp w_savut
; /* utmp entry of this window */
261 struct display
*w_zdisplay
;
263 #ifdef BUILTIN_TELNET
264 struct sockaddr_in w_telsa
;
265 char w_telbuf
[IOSIZE
];
267 char w_telmopts
[256];
268 char w_telropts
[256];
270 char w_telsubbuf
[128];
272 struct event w_telconnev
;
274 struct mline
*w_alt_mlines
;
277 int w_alt_histheight
;
278 int w_alt_x
, w_alt_y
;
280 struct mline
*w_alt_hlines
;
286 struct script_event canresize
;
287 struct script_event onresize
;
288 struct script_event onfocus
;
289 struct script_event onleave
;
290 struct script_event onhide
;
291 struct script_event onshow
;
292 struct script_event onclose
;
293 } w_sev
; /*For Script events. */
298 #define w_encoding w_layer.l_encoding
299 #define w_width w_layer.l_width
300 #define w_height w_layer.l_height
301 #define w_x w_layer.l_x
302 #define w_y w_layer.l_y
304 /* definitions for w_type */
306 #define W_TYPE_PLAIN 1
307 #define W_TYPE_TELNET 2
308 #define W_TYPE_GROUP 3
312 * Definitions for flow
313 * 000 -(-) flow off, auto would be off
314 * 001 +(-) flow on , auto would be off
315 * 010 -(+) flow off, auto would be on
316 * 011 +(+) flow on , auto would be on
317 * 100 - flow auto, currently off
318 * 111 + flow auto, currently on
319 * Application controls auto_flow via TIOCPKT, if available,
320 * else via application keypad mode.
322 #define FLOW_NOW (1<<0)
323 #define FLOW_AUTO (1<<1)
324 #define FLOW_AUTOFLAG (1<<2)
328 * WIN gives us a reference to line y of the *whole* image
329 * where line 0 is the oldest line in our history.
330 * y must be in whole image coordinate system, not in display.
333 #define WIN(y) ((y < fore->w_histheight) ? \
334 &fore->w_hlines[(fore->w_histidx + y) % fore->w_histheight] \
335 : &fore->w_mlines[y - fore->w_histheight])
337 #define Layer2Window(l) ((struct win *)(l)->l_bottom->l_data)