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