comparison src/events.h @ 263:727739f917cb r20-5b30

Import from CVS: tag r20-5b30
author cvs
date Mon, 13 Aug 2007 10:24:41 +0200
parents 83b3d10dcba9
children c5d627a313b1
comparison
equal deleted inserted replaced
262:9d8607af9e13 263:727739f917cb
111 which are polled for user-input. 111 which are polled for user-input.
112 112
113 select_device_cb These callbacks are used by Unixoid event loops 113 select_device_cb These callbacks are used by Unixoid event loops
114 unselect_device_cb (those that use select() and file descriptors and 114 unselect_device_cb (those that use select() and file descriptors and
115 have a separate input fd per device). 115 have a separate input fd per device).
116
117 create_stream_pair_cb These callbacks are called by process code to
118 delete_stream_pair_cb create and delete a pait of input and output lstreams
119 which are used for subprocess I/O.
116 120
117 quitp_cb A handler function called from the `QUIT' macro which 121 quitp_cb A handler function called from the `QUIT' macro which
118 should check whether the quit character has been 122 should check whether the quit character has been
119 typed. On systems with SIGIO, this will not be called 123 typed. On systems with SIGIO, this will not be called
120 unless the `sigio_happened' flag is true (it is set 124 unless the `sigio_happened' flag is true (it is set
266 Currently only the OffiX Dnd Protocol is supported. 270 Currently only the OffiX Dnd Protocol is supported.
267 #endif 271 #endif
268 272
269 */ 273 */
270 274
275 /*
276 Stream pairs description
277 ------------------------
278
279 Since there are many possible processes/event loop combinations, the event code
280 is responsible for creating an appropriare lstream type. The process
281 implementation does not care about that implementation.
282
283 The Create stream pair function is passed two void* values, which identify
284 process-dependant 'handles'. The process implementation uses these handles
285 to communicate with child processes. The function must be prepared to receive
286 handle types of any process implementation. Since there only one process
287 implementation exists in a particular XEmacs configuration, preprocessing
288 is a mean of compiling in the support for the code which deals with particular
289 handle types.
290
291 For example, a unixoid type loop, which relies on file descriptors, may be
292 asked to create a pair of streams by a unix-style process implementation.
293 In this case, the handles passed are unix file descriptors, and the code
294 may deal with these directly. Although, the same code may be used on Win32
295 system with X-Windows. In this case, Win32 process implementation passes
296 handles of type HANDLE, and the create_stream_pair function must call
297 appropriate function to get file descriptors given HANDLEs, so that these
298 descriptors may be passed to XtAddInput.
299
300 The handle given may have special denying value, in which case the
301 corresponding lstream should not be created.
302
303 The return value of the function is a unique stream identifier. It is used
304 by processes implementation, in its platform-independant part. There is
305 the get_process_from_usid function, which returns process object given its
306 USID. The event stream is responsible for converting its internal handle
307 type into USID.
308
309 Example is the TTY event stream. When a file descriptor signals input, the
310 event loop must determine process to which the input is destined. Thus,
311 the imlementation uses process input stream file descriptor as USID, by
312 simply casting the fd value to USID type.
313
314 There are two special USID values. One, USID_ERROR, indicates that the stream
315 pair cannot be created. The second, USID_DONTHASH, indicates that streams are
316 created, but the event stream does not wish to be able to find the process
317 by its USID. Specifically, if an event stream implementation never calss
318 get_process_from_usid, this value should always be returned, to prevent
319 accumulating useless information on USID to process relationship.
320 */
321
322 /* typedef unsigned int USID; in lisp.h */
323 #define USID_ERROR ((USID)-1)
324 #define USID_DONTHASH ((USID)0)
325
271 326
272 struct Lisp_Event; 327 struct Lisp_Event;
273 struct Lisp_Process; 328 struct Lisp_Process;
274 329
275 struct event_stream 330 struct event_stream
282 void (*select_console_cb) (struct console *); 337 void (*select_console_cb) (struct console *);
283 void (*unselect_console_cb) (struct console *); 338 void (*unselect_console_cb) (struct console *);
284 void (*select_process_cb) (struct Lisp_Process *); 339 void (*select_process_cb) (struct Lisp_Process *);
285 void (*unselect_process_cb) (struct Lisp_Process *); 340 void (*unselect_process_cb) (struct Lisp_Process *);
286 void (*quit_p_cb) (void); 341 void (*quit_p_cb) (void);
287 }; 342 USID (*create_stream_pair_cb) (void* /* inhandle*/, void* /*outhandle*/ ,
288 343 Lisp_Object* /* instream */,
344 Lisp_Object* /* outstream */,
345 int /* pty_flag */);
346 USID (*delete_stream_pair_cb) (Lisp_Object /* instream */,
347 Lisp_Object /* outstream */);
348 };
289 349
290 extern struct event_stream *event_stream; 350 extern struct event_stream *event_stream;
291 351
292 typedef enum emacs_event_type 352 typedef enum emacs_event_type
293 { 353 {
459 Lisp_Object allocate_command_builder (Lisp_Object console); 519 Lisp_Object allocate_command_builder (Lisp_Object console);
460 520
461 void format_event_object (char *buf, struct Lisp_Event *e, int brief); 521 void format_event_object (char *buf, struct Lisp_Event *e, int brief);
462 void character_to_event (Emchar c, struct Lisp_Event *event, 522 void character_to_event (Emchar c, struct Lisp_Event *event,
463 struct console *con, 523 struct console *con,
464 int use_console_meta_flag); 524 int use_console_meta_flag,
525 int do_backspace_mapping);
465 void enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object); 526 void enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object);
466 void zero_event (struct Lisp_Event *e); 527 void zero_event (struct Lisp_Event *e);
467 528
468 void deallocate_event_chain (Lisp_Object event); 529 void deallocate_event_chain (Lisp_Object event);
469 Lisp_Object event_chain_tail (Lisp_Object event); 530 Lisp_Object event_chain_tail (Lisp_Object event);
490 void event_stream_handle_magic_event (struct Lisp_Event *event); 551 void event_stream_handle_magic_event (struct Lisp_Event *event);
491 void event_stream_select_console (struct console *c); 552 void event_stream_select_console (struct console *c);
492 void event_stream_unselect_console (struct console *c); 553 void event_stream_unselect_console (struct console *c);
493 void event_stream_select_process (struct Lisp_Process *proc); 554 void event_stream_select_process (struct Lisp_Process *proc);
494 void event_stream_unselect_process (struct Lisp_Process *proc); 555 void event_stream_unselect_process (struct Lisp_Process *proc);
556 USID event_stream_create_stream_pair (void* inhandle, void* outhandle,
557 Lisp_Object* instream, Lisp_Object* outstream, int flags);
558 USID event_stream_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream);
495 void event_stream_quit_p (void); 559 void event_stream_quit_p (void);
496 560
497 struct low_level_timeout 561 struct low_level_timeout
498 { 562 {
499 int id; 563 int id;
544 int event_stream_unixoid_unselect_console (struct console *con); 608 int event_stream_unixoid_unselect_console (struct console *con);
545 int event_stream_unixoid_select_process (struct Lisp_Process *proc); 609 int event_stream_unixoid_select_process (struct Lisp_Process *proc);
546 int event_stream_unixoid_unselect_process (struct Lisp_Process *proc); 610 int event_stream_unixoid_unselect_process (struct Lisp_Process *proc);
547 int read_event_from_tty_or_stream_desc (struct Lisp_Event *event, 611 int read_event_from_tty_or_stream_desc (struct Lisp_Event *event,
548 struct console *c, int fd); 612 struct console *c, int fd);
613 USID event_stream_unixoid_create_stream_pair (void* inhandle, void* outhandle,
614 Lisp_Object* instream,
615 Lisp_Object* outstream,
616 int flags);
617 USID event_stream_unixoid_delete_stream_pair (Lisp_Object instream,
618 Lisp_Object outstream);
619
620 /* Beware: this evil macro evaluates its arg many times */
621 #define FD_TO_USID(fd) ((fd)==0 ? (USID)999999 : ((fd)<0 ? USID_DONTHASH : (USID)(fd)))
622
549 #endif /* HAVE_UNIXOID_EVENT_LOOP */ 623 #endif /* HAVE_UNIXOID_EVENT_LOOP */
550 624
551 extern int emacs_is_blocking; 625 extern int emacs_is_blocking;
552 626
553 extern Lisp_Object Vcontrolling_terminal; 627 extern Lisp_Object Vcontrolling_terminal;