Start converting to GPL v3+ (ref: ticket #23900)
[screen-lua.git] / src / display.h
blob09b4842ca9ac225723e41d53e3c061fe203951e0
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 3, 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, see
18 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 ****************************************************************
22 * $Id$ FAU
25 #ifdef MAPKEYS
27 #define KMAP_KEYS (T_OCAPS-T_CAPS)
28 #define KMAP_AKEYS (T_OCAPS-T_CURSOR)
30 #define KMAP_NOTIMEOUT 0x4000
32 #define MAXLAY 10
34 struct kmap_ext
36 char *str;
37 int fl;
38 struct action um;
39 struct action dm;
40 struct action mm;
43 #else
45 #define KMAP_KEYS 0
47 #endif
49 struct win; /* forward declaration */
51 #define SLICE_UNKN 0
52 #define SLICE_VERT (1 << 0)
53 #define SLICE_HORI (1 << 1)
55 #define SLICE_THIS (1 << 2) /* used in equal test */
56 #define SLICE_GLOBAL (1 << 3)
58 struct canvas
60 struct canvas *c_next; /* next canvas on display */
61 struct display *c_display; /* back pointer to display */
63 struct canvas *c_slnext; /* next canvas in display slice */
64 struct canvas *c_slprev; /* prev canvas in display slice */
65 struct canvas *c_slperp; /* perpendicular slice */
66 struct canvas *c_slback; /* perpendicular slice back pointer */
67 int c_slorient; /* our slice orientation */
68 int c_slweight; /* size ratio */
70 struct viewport *c_vplist;
71 struct layer *c_layer; /* layer on this canvas */
72 struct canvas *c_lnext; /* next canvas that displays layer */
73 struct layer c_blank; /* bottom layer, always blank */
74 int c_xoff; /* canvas x offset on display */
75 int c_yoff; /* canvas y offset on display */
76 int c_xs;
77 int c_xe;
78 int c_ys;
79 int c_ye;
80 struct event c_captev; /* caption changed event */
83 struct layout
85 struct layout *lay_next;
86 char *lay_title;
87 int lay_number;
88 struct canvas lay_canvas;
89 struct canvas *lay_forecv;
90 struct canvas *lay_cvlist;
91 int lay_autosave;
94 struct viewport
96 struct viewport *v_next; /* next vp on canvas */
97 struct canvas *v_canvas; /* back pointer to canvas */
98 int v_xoff; /* layer x offset on display */
99 int v_yoff; /* layer y offset on display */
100 int v_xs; /* vp upper left */
101 int v_xe; /* vp upper right */
102 int v_ys; /* vp lower left */
103 int v_ye; /* vp lower right */
106 struct display
108 struct display *d_next; /* linked list */
109 struct acluser *d_user; /* user who owns that display */
110 struct canvas d_canvas; /* our canvas slice */
111 struct canvas *d_cvlist; /* the canvases of this display */
112 struct canvas *d_forecv; /* current input focus */
113 struct layout *d_layout; /* layout we're using */
114 void (*d_processinput) __P((char *, int));
115 char *d_processinputdata; /* data for processinput */
116 int d_vpxmin, d_vpxmax; /* min/max used position on display */
117 struct win *d_fore; /* pointer to fore window */
118 struct win *d_other; /* pointer to other window */
119 int d_nonblock; /* -1 don't block if obufmax reached */
120 /* >0: block after nonblock secs */
121 char d_termname[20 + 1]; /* $TERM */
122 char *d_tentry; /* buffer for tgetstr */
123 char d_tcinited; /* termcap inited flag */
124 int d_width, d_height; /* width/height of the screen */
125 int d_defwidth, d_defheight; /* default width/height of windows */
126 int d_top, d_bot; /* scrollregion start/end */
127 int d_x, d_y; /* cursor position */
128 struct mchar d_rend; /* current rendition */
129 int d_col16change; /* the 16col bits changed in attr */
130 char d_atyp; /* current attribute types */
131 #ifdef DW_CHARS
132 int d_mbcs; /* saved char for multibytes charset */
133 #endif
134 #ifdef ENCODINGS
135 int d_encoding; /* what encoding type the display is */
136 int d_decodestate; /* state of our decoder */
137 int d_realfont; /* real font of terminal */
138 #endif
139 int d_insert; /* insert mode flag */
140 int d_keypad; /* application keypad flag */
141 int d_cursorkeys; /* application cursorkeys flag */
142 int d_revvid; /* reverse video */
143 int d_curvis; /* cursor visibility */
144 int d_has_hstatus; /* display has hardstatus line */
145 int d_hstatus; /* hardstatus used */
146 int d_lp_missing; /* last character on bot line missing */
147 int d_mouse; /* mouse mode */
148 #ifdef RXVT_OSC
149 int d_xtermosc[4]; /* osc used */
150 #endif
151 struct mchar d_lpchar; /* missing char */
152 struct timeval d_status_time; /* time of status display */
153 int d_status; /* is status displayed? */
154 char d_status_bell; /* is it only a vbell? */
155 int d_status_len; /* length of status line */
156 char *d_status_lastmsg; /* last displayed message */
157 int d_status_buflen; /* last message buffer len */
158 int d_status_lastx; /* position of the cursor */
159 int d_status_lasty; /* before status was displayed */
160 int d_status_obuflen; /* saved obuflen */
161 int d_status_obuffree; /* saved obuffree */
162 struct event d_statusev; /* timeout event */
163 struct event d_hstatusev; /* hstatus changed event */
164 int d_kaablamm; /* display kaablamm msg */
165 struct action *d_ESCseen; /* Was the last char an ESC (^a) */
166 int d_userpid; /* pid of attacher */
167 char d_usertty[MAXPATHLEN]; /* tty we are attached to */
168 int d_userfd; /* fd of the tty */
169 struct event d_readev; /* userfd read event */
170 struct event d_writeev; /* userfd write event */
171 struct event d_blockedev; /* blocked timeout */
172 struct mode d_OldMode; /* tty mode when screen was started */
173 struct mode d_NewMode; /* New tty mode */
174 int d_flow; /* tty's flow control on/off flag*/
175 int d_intrc; /* current intr when flow is on */
176 char *d_obuf; /* output buffer */
177 int d_obuflen; /* len of buffer */
178 int d_obufmax; /* len where we are blocking the pty */
179 int d_obuflenmax; /* len - max */
180 char *d_obufp; /* pointer in buffer */
181 int d_obuffree; /* free bytes in buffer */
182 #ifdef AUTO_NUKE
183 int d_auto_nuke; /* autonuke flag */
184 #endif
185 #ifdef MAPKEYS
186 int d_nseqs; /* number of valid mappings */
187 int d_aseqs; /* number of allocated mappings */
188 unsigned char *d_kmaps; /* keymaps */
189 unsigned char *d_seqp; /* pointer into keymap array */
190 int d_seql; /* number of parsed chars */
191 unsigned char *d_seqh; /* last hit */
192 struct event d_mapev; /* timeout event */
193 int d_dontmap; /* do not map next */
194 int d_mapdefault; /* do map next to default */
195 #endif
196 union tcu d_tcs[T_N]; /* terminal capabilities */
197 char *d_attrtab[NATTR]; /* attrib emulation table */
198 char d_attrtyp[NATTR]; /* attrib group table */
199 int d_hascolor; /* do we support color */
200 short d_dospeed; /* baudrate of tty */
201 #ifdef FONT
202 char d_c0_tab[256]; /* conversion for C0 */
203 char ***d_xtable; /* char translation table */
204 #endif
205 int d_UPcost, d_DOcost, d_LEcost, d_NDcost;
206 int d_CRcost, d_IMcost, d_EIcost, d_NLcost;
207 int d_printfd; /* fd for vt100 print sequence */
208 #ifdef UTMPOK
209 slot_t d_loginslot; /* offset, where utmp_logintty belongs */
210 struct utmp d_utmp_logintty; /* here the original utmp structure is stored */
211 int d_loginttymode;
212 # ifdef _SEQUENT_
213 char d_loginhost[100+1];
214 # endif /* _SEQUENT_ */
215 #endif
216 int d_blocked;
217 int d_blocked_fuzz;
218 struct event d_idleev; /* screen blanker */
219 #ifdef BLANKER_PRG
220 int d_blankerpid;
221 struct event d_blankerev;
222 #endif
225 #ifdef MULTI
226 # define DISPLAY(x) display->x
227 #else
228 extern struct display TheDisplay;
229 # define DISPLAY(x) TheDisplay.x
230 #endif
232 #define D_user DISPLAY(d_user)
233 #define D_username (DISPLAY(d_user) ? DISPLAY(d_user)->u_name : 0)
234 #define D_canvas DISPLAY(d_canvas)
235 #define D_cvlist DISPLAY(d_cvlist)
236 #define D_layout DISPLAY(d_layout)
237 #define D_forecv DISPLAY(d_forecv)
238 #define D_processinput DISPLAY(d_processinput)
239 #define D_processinputdata DISPLAY(d_processinputdata)
240 #define D_vpxmin DISPLAY(d_vpxmin)
241 #define D_vpxmax DISPLAY(d_vpxmax)
242 #define D_fore DISPLAY(d_fore)
243 #define D_other DISPLAY(d_other)
244 #define D_nonblock DISPLAY(d_nonblock)
245 #define D_termname DISPLAY(d_termname)
246 #define D_tentry DISPLAY(d_tentry)
247 #define D_tcinited DISPLAY(d_tcinited)
248 #define D_width DISPLAY(d_width)
249 #define D_height DISPLAY(d_height)
250 #define D_defwidth DISPLAY(d_defwidth)
251 #define D_defheight DISPLAY(d_defheight)
252 #define D_top DISPLAY(d_top)
253 #define D_bot DISPLAY(d_bot)
254 #define D_x DISPLAY(d_x)
255 #define D_y DISPLAY(d_y)
256 #define D_rend DISPLAY(d_rend)
257 #define D_col16change DISPLAY(d_col16change)
258 #define D_atyp DISPLAY(d_atyp)
259 #define D_mbcs DISPLAY(d_mbcs)
260 #define D_encoding DISPLAY(d_encoding)
261 #define D_decodestate DISPLAY(d_decodestate)
262 #define D_realfont DISPLAY(d_realfont)
263 #define D_insert DISPLAY(d_insert)
264 #define D_keypad DISPLAY(d_keypad)
265 #define D_cursorkeys DISPLAY(d_cursorkeys)
266 #define D_revvid DISPLAY(d_revvid)
267 #define D_curvis DISPLAY(d_curvis)
268 #define D_has_hstatus DISPLAY(d_has_hstatus)
269 #define D_hstatus DISPLAY(d_hstatus)
270 #define D_lp_missing DISPLAY(d_lp_missing)
271 #define D_mouse DISPLAY(d_mouse)
272 #define D_xtermosc DISPLAY(d_xtermosc)
273 #define D_lpchar DISPLAY(d_lpchar)
274 #define D_status DISPLAY(d_status)
275 #define D_status_time DISPLAY(d_status_time)
276 #define D_status_bell DISPLAY(d_status_bell)
277 #define D_status_len DISPLAY(d_status_len)
278 #define D_status_lastmsg DISPLAY(d_status_lastmsg)
279 #define D_status_buflen DISPLAY(d_status_buflen)
280 #define D_status_lastx DISPLAY(d_status_lastx)
281 #define D_status_lasty DISPLAY(d_status_lasty)
282 #define D_status_obuflen DISPLAY(d_status_obuflen)
283 #define D_status_obuffree DISPLAY(d_status_obuffree)
284 #define D_statusev DISPLAY(d_statusev)
285 #define D_hstatusev DISPLAY(d_hstatusev)
286 #define D_kaablamm DISPLAY(d_kaablamm)
287 #define D_ESCseen DISPLAY(d_ESCseen)
288 #define D_userpid DISPLAY(d_userpid)
289 #define D_usertty DISPLAY(d_usertty)
290 #define D_userfd DISPLAY(d_userfd)
291 #define D_OldMode DISPLAY(d_OldMode)
292 #define D_NewMode DISPLAY(d_NewMode)
293 #define D_flow DISPLAY(d_flow)
294 #define D_intr DISPLAY(d_intr)
295 #define D_obuf DISPLAY(d_obuf)
296 #define D_obuflen DISPLAY(d_obuflen)
297 #define D_obufmax DISPLAY(d_obufmax)
298 #define D_obuflenmax DISPLAY(d_obuflenmax)
299 #define D_obufp DISPLAY(d_obufp)
300 #define D_obuffree DISPLAY(d_obuffree)
301 #define D_auto_nuke DISPLAY(d_auto_nuke)
302 #define D_nseqs DISPLAY(d_nseqs)
303 #define D_aseqs DISPLAY(d_aseqs)
304 #define D_seqp DISPLAY(d_seqp)
305 #define D_seql DISPLAY(d_seql)
306 #define D_seqh DISPLAY(d_seqh)
307 #define D_dontmap DISPLAY(d_dontmap)
308 #define D_mapdefault DISPLAY(d_mapdefault)
309 #define D_kmaps DISPLAY(d_kmaps)
310 #define D_tcs DISPLAY(d_tcs)
311 #define D_attrtab DISPLAY(d_attrtab)
312 #define D_attrtyp DISPLAY(d_attrtyp)
313 #define D_hascolor DISPLAY(d_hascolor)
314 #define D_dospeed DISPLAY(d_dospeed)
315 #define D_c0_tab DISPLAY(d_c0_tab)
316 #define D_xtable DISPLAY(d_xtable)
317 #define D_UPcost DISPLAY(d_UPcost)
318 #define D_DOcost DISPLAY(d_DOcost)
319 #define D_LEcost DISPLAY(d_LEcost)
320 #define D_NDcost DISPLAY(d_NDcost)
321 #define D_CRcost DISPLAY(d_CRcost)
322 #define D_IMcost DISPLAY(d_IMcost)
323 #define D_EIcost DISPLAY(d_EIcost)
324 #define D_NLcost DISPLAY(d_NLcost)
325 #define D_printfd DISPLAY(d_printfd)
326 #define D_loginslot DISPLAY(d_loginslot)
327 #define D_utmp_logintty DISPLAY(d_utmp_logintty)
328 #define D_loginttymode DISPLAY(d_loginttymode)
329 #define D_loginhost DISPLAY(d_loginhost)
330 #define D_readev DISPLAY(d_readev)
331 #define D_writeev DISPLAY(d_writeev)
332 #define D_blockedev DISPLAY(d_blockedev)
333 #define D_mapev DISPLAY(d_mapev)
334 #define D_blocked DISPLAY(d_blocked)
335 #define D_blocked_fuzz DISPLAY(d_blocked_fuzz)
336 #define D_idleev DISPLAY(d_idleev)
337 #define D_blankerev DISPLAY(d_blankerev)
338 #define D_blankerpid DISPLAY(d_blankerpid)
341 #define GRAIN 4096 /* Allocation grain size for output buffer */
342 #define OBUF_MAX 256 /* default for obuflimit */
344 #define OUTPUT_BLOCK_SIZE 256 /* Block size of output to tty */
346 #define AddChar(c) \
347 do \
349 if (--D_obuffree <= 0) \
350 Resize_obuf(); \
351 *D_obufp++ = (c); \
353 while (0)
355 #define CV_CALL(cv, cmd) \
357 struct display *olddisplay = display; \
358 struct layer *oldflayer = flayer; \
359 struct layer *l = cv->c_layer; \
360 struct canvas *cvlist = l->l_cvlist; \
361 struct canvas *cvlnext = cv->c_lnext; \
362 flayer = l; \
363 l->l_cvlist = cv; \
364 cv->c_lnext = 0; \
365 cmd; \
366 flayer = oldflayer; \
367 l->l_cvlist = cvlist; \
368 cv->c_lnext = cvlnext; \
369 display = olddisplay; \
372 #define STATUS_OFF 0
373 #define STATUS_ON_WIN 1
374 #define STATUS_ON_HS 2
376 #define HSTATUS_IGNORE 0
377 #define HSTATUS_LASTLINE 1
378 #define HSTATUS_MESSAGE 2
379 #define HSTATUS_HS 3
380 #define HSTATUS_ALWAYS (1<<2)