Document the onsilent/onactivity event.
[screen-lua.git] / src / screen.h
blob6ba07e849e4a66756030aa401806dd4b13b6bebb
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)
14 * any later version.
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 ****************************************************************
27 * $Id$ FAU
30 #include "os.h"
32 #if defined(__STDC__)
33 # ifndef __P
34 # define __P(a) a
35 # endif
36 #else
37 # ifndef __P
38 # define __P(a) ()
39 # endif
40 # define const
41 #endif
43 #include "osdef.h"
45 #include "ansi.h"
46 #include "sched.h"
47 #include "acls.h"
48 #include "comm.h"
49 #include "layer.h"
50 #include "term.h"
51 #include "script.h"
54 #ifdef DEBUG
55 # define STATIC /* a function that the debugger should see */
56 #else
57 # define STATIC static
58 #endif
60 #ifdef DEBUG
61 # define DEBUGDIR "/tmp/debug"
62 # define debugf(a) do {if(dfp){fprintf a;fflush(dfp);}} while (0)
63 # define debug(x) debugf((dfp,x))
64 # define debug1(x,a) debugf((dfp,x,a))
65 # define debug2(x,a,b) debugf((dfp,x,a,b))
66 # define debug3(x,a,b,c) debugf((dfp,x,a,b,c))
67 extern FILE *dfp;
68 #else
69 # define debugf(a) do {} while (0)
70 # define debug(x) debugf(x)
71 # define debug1(x,a) debugf(x)
72 # define debug2(x,a,b) debugf(x)
73 # define debug3(x,a,b,c) debugf(x)
74 #endif
76 #ifndef DEBUG
77 # define NOASSERT
78 #endif
80 #ifndef NOASSERT
81 # if defined(__STDC__)
82 # define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT("#lousy_cpp") failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0)
83 # else
84 # define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT(lousy_cpp) failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0)
85 # endif
86 #else
87 # define ASSERT(lousy_cpp) do {} while (0)
88 #endif
90 /* here comes my own Free: jw. */
91 #define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;}
93 #define Ctrl(c) ((c)&037)
95 #define MAXSTR 512
96 #define MAXARGS 64
97 #define MSGWAIT 5
98 #define MSGMINWAIT 1
99 #define SILENCEWAIT 30
102 * if a nasty user really wants to try a history of 3000 lines on all 10
103 * windows, he will allocate 8 MegaBytes of memory, which is quite enough.
105 #define MAXHISTHEIGHT 3000
106 #define DEFAULTHISTHEIGHT 100
107 #if defined(NAME_MAX) && NAME_MAX < 16
108 # define DEFAULT_BUFFERFILE "/tmp/screen-xchg"
109 #else
110 # define DEFAULT_BUFFERFILE "/tmp/screen-exchange"
111 #endif
114 #if defined(hpux) && !(defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT))
115 # define HPUX_LTCHARS_HACK
116 #endif
118 struct mode
120 #ifdef POSIX
121 struct termios tio;
122 # ifdef HPUX_LTCHARS_HACK
123 struct ltchars m_ltchars;
124 # endif /* HPUX_LTCHARS_HACK */
125 #else /* POSIX */
126 # ifdef TERMIO
127 struct termio tio;
128 # ifdef CYTERMIO
129 int m_mapkey;
130 int m_mapscreen;
131 int m_backspace;
132 # endif
133 # else /* TERMIO */
134 struct sgttyb m_ttyb;
135 struct tchars m_tchars;
136 struct ltchars m_ltchars;
137 int m_ldisc;
138 int m_lmode;
139 # endif /* TERMIO */
140 #endif /* POSIX */
141 #if defined(KANJI) && defined(TIOCKSET)
142 struct jtchars m_jtchars;
143 int m_knjmode;
144 #endif
148 /* #include "logfile.h" */ /* (requires stat.h) struct logfile */
149 #include "image.h"
150 #include "display.h"
151 #include "window.h"
154 * Parameters for the Detach() routine
156 #define D_DETACH 0
157 #define D_STOP 1
158 #define D_REMOTE 2
159 #define D_POWER 3
160 #define D_REMOTE_POWER 4
161 #define D_LOCK 5
162 #define D_HANGUP 6
165 * Here are the messages the attacher sends to the backend
167 #define MSG_CREATE 0
168 #define MSG_ERROR 1
169 #define MSG_ATTACH 2
170 #define MSG_CONT 3
171 #define MSG_DETACH 4
172 #define MSG_POW_DETACH 5
173 #define MSG_WINCH 6
174 #define MSG_HANGUP 7
175 #define MSG_COMMAND 8
178 * versions of struct msg:
179 * 0: screen version 3.6.6 (version count introduced)
180 * 1: screen version 4.1.0
182 #define MSG_VERSION 1
183 #define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION)
184 struct msg
186 int protocol_revision; /* reduce harm done by incompatible messages */
187 int type;
188 char m_tty[MAXPATHLEN]; /* ttyname */
189 union
191 struct
193 int lflag;
194 int aflag;
195 int flowflag;
196 int hheight; /* size of scrollback buffer */
197 int nargs;
198 char line[MAXPATHLEN];
199 char dir[MAXPATHLEN];
200 char screenterm[20]; /* is screen really "screen" ? */
202 create;
203 struct
205 char auser[20 + 1]; /* username */
206 int apid; /* pid of frontend */
207 int adaptflag; /* adapt window size? */
208 int lines, columns; /* display size */
209 char preselect[20];
210 int esc; /* his new escape character unless -1 */
211 int meta_esc; /* his new meta esc character unless -1 */
212 char envterm[20 + 1]; /* terminal type */
213 int encoding; /* encoding of display */
214 int detachfirst; /* whether to detach remote sessions first */
216 attach;
217 struct
219 char duser[20 + 1]; /* username */
220 int dpid; /* pid of frontend */
222 detach;
223 struct
225 char auser[20 + 1]; /* username */
226 int nargs;
227 char cmd[MAXPATHLEN]; /* command */
228 int apid; /* pid of frontend */
229 char preselect[20];
231 command;
232 char message[MAXPATHLEN * 2];
233 } m;
237 * And the signals the attacher receives from the backend
239 #define SIG_BYE SIGHUP
240 #define SIG_POWER_BYE SIGUSR1
241 #define SIG_LOCK SIGUSR2
242 #define SIG_STOP SIGTSTP
243 #ifdef SIGIO
244 #define SIG_NODEBUG SIGIO /* triggerd by command 'debug off' */
245 #endif
248 #define BELL (Ctrl('g'))
249 #define VBELLWAIT 1 /* No. of seconds a vbell will be displayed */
251 #define BELL_ON 0 /* No bell has occurred in the window */
252 #define BELL_FOUND 1 /* A bell has occurred, but user not yet notified */
253 #define BELL_DONE 2 /* A bell has occured, user has been notified */
255 #define BELL_VISUAL 3 /* A bell has occured in fore win, notify him visually */
257 #define MON_OFF 0 /* Monitoring is off in the window */
258 #define MON_ON 1 /* No activity has occurred in the window */
259 #define MON_FOUND 2 /* Activity has occured, but user not yet notified */
260 #define MON_DONE 3 /* Activity has occured, user has been notified */
262 #define DUMP_TERMCAP 0 /* WriteFile() options */
263 #define DUMP_HARDCOPY 1
264 #define DUMP_EXCHANGE 2
265 #define DUMP_SCROLLBACK 3
267 #define SILENCE_OFF 0
268 #define SILENCE_ON 1
270 extern char strnomem[];
273 * line modes used by Input()
275 #define INP_COOKED 0
276 #define INP_NOECHO 1
277 #define INP_RAW 2
278 #define INP_EVERY 4
281 #ifdef MULTIUSER
282 struct acl
284 struct acl *next;
285 char *name;
287 #endif
289 /* register list */
290 #define MAX_PLOP_DEFS 256
292 struct baud_values
294 int idx; /* the index in the bsd-is padding lookup table */
295 int bps; /* bits per seconds */
296 int sym; /* symbol defined in ttydev.h */
300 * windowlist orders
302 #define WLIST_NUM 0
303 #define WLIST_MRU 1
304 #define WLIST_NESTED 2