comparison src/keyboard.c @ 9652:13a13988685a

(read_avail_input): Use input_fd.
author Richard M. Stallman <rms@gnu.org>
date Sat, 22 Oct 1994 03:55:39 +0000
parents 9fe4987e4896
children 38a4e4386aed
comparison
equal deleted inserted replaced
9651:3c2685c4e09d 9652:13a13988685a
71 during the current critical section. */ 71 during the current critical section. */
72 int interrupt_input_pending; 72 int interrupt_input_pending;
73 73
74 74
75 #ifdef HAVE_X_WINDOWS 75 #ifdef HAVE_X_WINDOWS
76 extern Lisp_Object Vmouse_grabbed; 76 /* File descriptor to use for input. */
77 extern int input_fd;
77 78
78 /* Make all keyboard buffers much bigger when using X windows. */ 79 /* Make all keyboard buffers much bigger when using X windows. */
79 #define KBD_BUFFER_SIZE 4096 80 #define KBD_BUFFER_SIZE 4096
80 #else /* No X-windows, character input */ 81 #else /* No X-windows, character input */
81 #define KBD_BUFFER_SIZE 256 82 #define KBD_BUFFER_SIZE 256
3513 register int i; 3514 register int i;
3514 int nread; 3515 int nread;
3515 3516
3516 if (read_socket_hook) 3517 if (read_socket_hook)
3517 /* No need for FIONREAD or fcntl; just say don't wait. */ 3518 /* No need for FIONREAD or fcntl; just say don't wait. */
3518 nread = (*read_socket_hook) (0, buf, KBD_BUFFER_SIZE, expected, expected); 3519 nread = (*read_socket_hook) (input_fd, buf, KBD_BUFFER_SIZE,
3520 expected, expected);
3519 else 3521 else
3520 { 3522 {
3521 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than 3523 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than
3522 the kbd_buffer can really hold. That may prevent loss 3524 the kbd_buffer can really hold. That may prevent loss
3523 of characters on some systems when input is stuffed at us. */ 3525 of characters on some systems when input is stuffed at us. */
3530 if (n_to_read == 0) 3532 if (n_to_read == 0)
3531 return 0; 3533 return 0;
3532 #else /* not MSDOS */ 3534 #else /* not MSDOS */
3533 #ifdef FIONREAD 3535 #ifdef FIONREAD
3534 /* Find out how much input is available. */ 3536 /* Find out how much input is available. */
3535 if (ioctl (0, FIONREAD, &n_to_read) < 0) 3537 if (ioctl (input_fd, FIONREAD, &n_to_read) < 0)
3536 /* Formerly simply reported no input, but that sometimes led to 3538 /* Formerly simply reported no input, but that sometimes led to
3537 a failure of Emacs to terminate. 3539 a failure of Emacs to terminate.
3538 SIGHUP seems appropriate if we can't reach the terminal. */ 3540 SIGHUP seems appropriate if we can't reach the terminal. */
3539 /* ??? Is it really right to send the signal just to this process 3541 /* ??? Is it really right to send the signal just to this process
3540 rather than to the whole process group? 3542 rather than to the whole process group?
3546 n_to_read = sizeof cbuf; 3548 n_to_read = sizeof cbuf;
3547 #else /* no FIONREAD */ 3549 #else /* no FIONREAD */
3548 #if defined(USG) || defined(DGUX) 3550 #if defined(USG) || defined(DGUX)
3549 /* Read some input if available, but don't wait. */ 3551 /* Read some input if available, but don't wait. */
3550 n_to_read = sizeof cbuf; 3552 n_to_read = sizeof cbuf;
3551 fcntl (fileno (stdin), F_SETFL, O_NDELAY); 3553 fcntl (input_fd, F_SETFL, O_NDELAY);
3552 #else 3554 #else
3553 you lose; 3555 you lose;
3554 #endif 3556 #endif
3555 #endif 3557 #endif
3556 #endif /* not MSDOS */ 3558 #endif /* not MSDOS */
3561 { 3563 {
3562 #ifdef MSDOS 3564 #ifdef MSDOS
3563 cbuf[0] = dos_keyread(); 3565 cbuf[0] = dos_keyread();
3564 nread = 1; 3566 nread = 1;
3565 #else 3567 #else
3566 nread = read (fileno (stdin), cbuf, n_to_read); 3568 nread = read (input_fd, cbuf, n_to_read);
3567 #endif 3569 #endif
3568 #if defined (AIX) && (! defined (aix386) && defined (_BSD)) 3570 #if defined (AIX) && (! defined (aix386) && defined (_BSD))
3569 /* The kernel sometimes fails to deliver SIGHUP for ptys. 3571 /* The kernel sometimes fails to deliver SIGHUP for ptys.
3570 This looks incorrect, but it isn't, because _BSD causes 3572 This looks incorrect, but it isn't, because _BSD causes
3571 O_NDELAY to be defined in fcntl.h as O_NONBLOCK, 3573 O_NDELAY to be defined in fcntl.h as O_NONBLOCK,
3593 #endif 3595 #endif
3594 ); 3596 );
3595 3597
3596 #ifndef FIONREAD 3598 #ifndef FIONREAD
3597 #if defined (USG) || defined (DGUX) 3599 #if defined (USG) || defined (DGUX)
3598 fcntl (fileno (stdin), F_SETFL, 0); 3600 fcntl (input_fd, F_SETFL, 0);
3599 #endif /* USG or DGUX */ 3601 #endif /* USG or DGUX */
3600 #endif /* no FIONREAD */ 3602 #endif /* no FIONREAD */
3601 for (i = 0; i < nread; i++) 3603 for (i = 0; i < nread; i++)
3602 { 3604 {
3603 buf[i].kind = ascii_keystroke; 3605 buf[i].kind = ascii_keystroke;