comparison src/keyboard.c @ 53232:22aaf1e5fbe6

Full support for multiple terminal I/O (with some rough edges). lib-src/emacsclient.c (emacs_pid): New variable. (window_change): Forward the SIGWINCH signal to the Emacs process after copying the size parameters to the proxy terminal. (copy_from_to): New parameter (sigio), kill Emacs with SIGIO if it is nonzero. (main): Set emacs_pid. lisp/server.el (server-process-filter): Send the pid of Emacs to emacsclient. src/cm.c: Added tty parameters to all functions and all Wcm macro calls. src/cm.h: Added tty parameters to all macros. Updated function prototypes. (Wcm): Moved to struct tty_output. src/dispextern.h: Updated function prototypes. src/dispnew.c: Added tty parameters to all Wcm macro calls. (do_switch_frame): Make old frame obscured, not invisible, to solve problems with other-frame. (Wcm): Moved to struct tty_output. src/keyboard.c (read_avail_input): Select the frame corresponding to the tty that was read. Slight rearrangement of tty loop. src/lisp.h (tabs_safe_p): Removed duplicate prototype. src/sysdep.c (hft_init, hft_reset): Added tty_output parameter. (discard_tty_input): Discard input from all ttys on APOLLO, too. Whatever it is. (narrow_foreground_group, widen_foreground_group): Added tty parameter (not really useful, the functions only work on the controlling tty.) (tabs_safe_p): Added tty parameter. src/term.c Added tty parameters to all Wcm macro calls. Standardised updating_frame vs. selected frame and tty_output access. (term_init): Allocate Wcm. (syms_of_term): Provide the `multi-tty' feature. src/termchar.h (struct tty_output): Added Wcm. src/xdisp.c (try_window_id): Make sure we use the tty device corresponding to the current frame. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-8
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 27 Dec 2003 01:12:57 +0000
parents 33c3c7c16e13
children fe9b37bee5f7
comparison
equal deleted inserted replaced
53231:e0c359b85b58 53232:22aaf1e5fbe6
6458 || readable_filtered_events (do_timers_now, filter_events)); 6458 || readable_filtered_events (do_timers_now, filter_events));
6459 6459
6460 /* If input is being read as it arrives, and we have none, there is none. */ 6460 /* If input is being read as it arrives, and we have none, there is none. */
6461 if (*addr > 0 || (interrupt_input && ! interrupts_deferred)) 6461 if (*addr > 0 || (interrupt_input && ! interrupts_deferred))
6462 return; 6462 return;
6463 6463
6464 /* Try to read some input and see how much we get. */ 6464 /* Try to read some input and see how much we get. */
6465 gobble_input (0); 6465 gobble_input (0);
6466 *addr = (!NILP (Vquit_flag) 6466 *addr = (!NILP (Vquit_flag)
6467 || readable_filtered_events (do_timers_now, filter_events)); 6467 || readable_filtered_events (do_timers_now, filter_events));
6468 } 6468 }
6577 int expected; 6577 int expected;
6578 { 6578 {
6579 struct input_event buf[KBD_BUFFER_SIZE]; 6579 struct input_event buf[KBD_BUFFER_SIZE];
6580 register int i; 6580 register int i;
6581 int nread; 6581 int nread;
6582 6582
6583 for (i = 0; i < KBD_BUFFER_SIZE; i++) 6583 for (i = 0; i < KBD_BUFFER_SIZE; i++)
6584 EVENT_INIT (buf[i]); 6584 EVENT_INIT (buf[i]);
6585 6585
6586 if (read_socket_hook) 6586 if (read_socket_hook)
6587 /* No need for FIONREAD or fcntl; just say don't wait. */ 6587 /* No need for FIONREAD or fcntl; just say don't wait. */
6609 6609
6610 struct tty_output *tty; 6610 struct tty_output *tty;
6611 nread = 0; 6611 nread = 0;
6612 6612
6613 /* Try to read from each available tty, until one succeeds. */ 6613 /* Try to read from each available tty, until one succeeds. */
6614 for (tty = tty_list; tty && !nread; tty = tty->next) { 6614 for (tty = tty_list; tty; tty = tty->next) {
6615 6615
6616 /* Determine how many characters we should *try* to read. */ 6616 /* Determine how many characters we should *try* to read. */
6617 #ifdef FIONREAD 6617 #ifdef FIONREAD
6618 /* Find out how much input is available. */ 6618 /* Find out how much input is available. */
6619 if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0) 6619 if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0)
6620 { 6620 {
6622 a failure of Emacs to terminate. 6622 a failure of Emacs to terminate.
6623 SIGHUP seems appropriate if we can't reach the terminal. */ 6623 SIGHUP seems appropriate if we can't reach the terminal. */
6624 /* ??? Is it really right to send the signal just to this process 6624 /* ??? Is it really right to send the signal just to this process
6625 rather than to the whole process group? 6625 rather than to the whole process group?
6626 Perhaps on systems with FIONREAD Emacs is alone in its group. */ 6626 Perhaps on systems with FIONREAD Emacs is alone in its group. */
6627 /* It appears to be the case, see narrow_foreground_group. */
6627 if (! noninteractive) 6628 if (! noninteractive)
6628 { 6629 {
6629 if (! tty_list->next) 6630 if (! tty_list->next)
6630 kill (getpid (), SIGHUP); /* This was the last terminal. */ 6631 kill (getpid (), SIGHUP); /* This was the last terminal. */
6631 else 6632 else
6704 #if defined (USG) || defined (DGUX) || defined (CYGWIN) 6705 #if defined (USG) || defined (DGUX) || defined (CYGWIN)
6705 fcntl (fileno (TTY_INPUT (tty)), F_SETFL, 0); 6706 fcntl (fileno (TTY_INPUT (tty)), F_SETFL, 0);
6706 #endif /* USG or DGUX or CYGWIN */ 6707 #endif /* USG or DGUX or CYGWIN */
6707 #endif /* no FIONREAD */ 6708 #endif /* no FIONREAD */
6708 6709
6710 if (nread > 0)
6711 break;
6709 } /* for each tty */ 6712 } /* for each tty */
6710 6713
6711 if (! nread) 6714 if (nread <= 0)
6712 return 0; 6715 return 0;
6713 6716
6714 #endif /* not MSDOS */ 6717 #endif /* not MSDOS */
6715 #endif /* not WINDOWSNT */ 6718 #endif /* not WINDOWSNT */
6716 6719
6717 /* XXX Select frame corresponding to the tty. */ 6720 /* Select frame corresponding to the active tty. Note that the
6721 value of selected_frame is not reliable here, redisplay tends
6722 to temporarily change it. But tty should always be non-NULL. */
6723 Lisp_Object frame = (tty ? tty->top_frame : selected_frame);
6718 6724
6719 for (i = 0; i < nread; i++) 6725 for (i = 0; i < nread; i++)
6720 { 6726 {
6721 buf[i].kind = ASCII_KEYSTROKE_EVENT; 6727 buf[i].kind = ASCII_KEYSTROKE_EVENT;
6722 buf[i].modifiers = 0; 6728 buf[i].modifiers = 0;
6723 if (meta_key == 1 && (cbuf[i] & 0x80)) 6729 if (meta_key == 1 && (cbuf[i] & 0x80))
6724 buf[i].modifiers = meta_modifier; 6730 buf[i].modifiers = meta_modifier;
6725 if (meta_key != 2) 6731 if (meta_key != 2)
6726 cbuf[i] &= ~0x80; 6732 cbuf[i] &= ~0x80;
6727 6733
6728 buf[i].code = cbuf[i]; 6734 buf[i].code = cbuf[i];
6729 buf[i].frame_or_window = selected_frame; 6735 buf[i].frame_or_window = frame;
6730 buf[i].arg = Qnil; 6736 buf[i].arg = Qnil;
6731 } 6737 }
6732 } 6738 }
6733 6739
6734 /* Scan the chars for C-g and store them in kbd_buffer. */ 6740 /* Scan the chars for C-g and store them in kbd_buffer. */