Mercurial > emacs
comparison src/keyboard.c @ 6875:1862df471cac
(make_lispy_event): Put mouse event code
into MULTI_FRAME conditional.
(read_avail_input): Separate local var n_to_read
so that reading doesn't clobber that info when it sets nread.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 14 Apr 1994 11:59:28 +0000 |
parents | ba2176fd811c |
children | 065060f1f9b8 |
comparison
equal
deleted
inserted
replaced
6874:12dcd89cfd88 | 6875:1862df471cac |
---|---|
2462 lispy_function_keys, &func_key_syms, | 2462 lispy_function_keys, &func_key_syms, |
2463 (sizeof (lispy_function_keys) | 2463 (sizeof (lispy_function_keys) |
2464 / sizeof (lispy_function_keys[0]))); | 2464 / sizeof (lispy_function_keys[0]))); |
2465 break; | 2465 break; |
2466 | 2466 |
2467 #ifdef MULTI_FRAME | |
2467 /* A mouse click. Figure out where it is, decide whether it's | 2468 /* A mouse click. Figure out where it is, decide whether it's |
2468 a press, click or drag, and build the appropriate structure. */ | 2469 a press, click or drag, and build the appropriate structure. */ |
2469 case mouse_click: | 2470 case mouse_click: |
2470 case scroll_bar_click: | 2471 case scroll_bar_click: |
2471 { | 2472 { |
2690 return Fcons (head, | 2691 return Fcons (head, |
2691 Fcons (position, | 2692 Fcons (position, |
2692 Qnil)); | 2693 Qnil)); |
2693 } | 2694 } |
2694 } | 2695 } |
2696 #endif /* MULTI_FRAME */ | |
2695 | 2697 |
2696 /* The 'kind' field of the event is something we don't recognize. */ | 2698 /* The 'kind' field of the event is something we don't recognize. */ |
2697 default: | 2699 default: |
2698 abort (); | 2700 abort (); |
2699 } | 2701 } |
3299 { | 3301 { |
3300 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than | 3302 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than |
3301 the kbd_buffer can really hold. That may prevent loss | 3303 the kbd_buffer can really hold. That may prevent loss |
3302 of characters on some systems when input is stuffed at us. */ | 3304 of characters on some systems when input is stuffed at us. */ |
3303 unsigned char cbuf[KBD_BUFFER_SIZE - 1]; | 3305 unsigned char cbuf[KBD_BUFFER_SIZE - 1]; |
3304 | 3306 int n_to_read; |
3307 | |
3308 /* Determine how many characters we should *try* to read. */ | |
3305 #ifdef MSDOS | 3309 #ifdef MSDOS |
3306 nread = dos_keysns (); | 3310 n_to_read = dos_keysns (); |
3307 if (nread == 0) return 0; | 3311 if (n_to_read == 0) |
3312 return 0; | |
3308 #else */ not MSDOS */ | 3313 #else */ not MSDOS */ |
3309 #ifdef FIONREAD | 3314 #ifdef FIONREAD |
3310 /* Find out how much input is available. */ | 3315 /* Find out how much input is available. */ |
3311 if (ioctl (0, FIONREAD, &nread) < 0) | 3316 if (ioctl (0, FIONREAD, &n_to_read) < 0) |
3312 /* Formerly simply reported no input, but that sometimes led to | 3317 /* Formerly simply reported no input, but that sometimes led to |
3313 a failure of Emacs to terminate. | 3318 a failure of Emacs to terminate. |
3314 SIGHUP seems appropriate if we can't reach the terminal. */ | 3319 SIGHUP seems appropriate if we can't reach the terminal. */ |
3315 /* ??? Is it really right to send the signal just to this process | 3320 /* ??? Is it really right to send the signal just to this process |
3316 rather than to the whole process group? | 3321 rather than to the whole process group? |
3317 Perhaps on systems with FIONREAD Emacs is alone in its group. */ | 3322 Perhaps on systems with FIONREAD Emacs is alone in its group. */ |
3318 kill (getpid (), SIGHUP); | 3323 kill (getpid (), SIGHUP); |
3319 if (nread == 0) | 3324 if (n_to_read == 0) |
3320 return 0; | 3325 return 0; |
3321 if (nread > sizeof cbuf) | 3326 if (n_to_read > sizeof cbuf) |
3322 nread = sizeof cbuf; | 3327 n_to_read = sizeof cbuf; |
3323 #else /* no FIONREAD */ | 3328 #else /* no FIONREAD */ |
3324 #if defined(USG) || defined(DGUX) | 3329 #if defined(USG) || defined(DGUX) |
3325 /* Read some input if available, but don't wait. */ | 3330 /* Read some input if available, but don't wait. */ |
3326 nread = sizeof cbuf; | 3331 n_to_read = sizeof cbuf; |
3327 fcntl (fileno (stdin), F_SETFL, O_NDELAY); | 3332 fcntl (fileno (stdin), F_SETFL, O_NDELAY); |
3328 #else | 3333 #else |
3329 you lose; | 3334 you lose; |
3330 #endif | 3335 #endif |
3331 #endif | 3336 #endif |
3332 #endif /* not MSDOS */ | 3337 #endif /* not MSDOS */ |
3333 | 3338 |
3334 /* Now read; for one reason or another, this will not block. */ | 3339 /* Now read; for one reason or another, this will not block. |
3340 NREAD is set to the number of chars read. */ | |
3335 while (1) | 3341 while (1) |
3336 { | 3342 { |
3337 #ifdef MSDOS | 3343 #ifdef MSDOS |
3338 cbuf[0] = dos_keyread(); | 3344 cbuf[0] = dos_keyread(); |
3339 nread = 1; | 3345 nread = 1; |
3340 #else | 3346 #else |
3341 nread = read (fileno (stdin), cbuf, nread); | 3347 nread = read (fileno (stdin), cbuf, n_to_read); |
3342 #endif | 3348 #endif |
3343 #ifdef AIX | 3349 #ifdef AIX |
3344 /* The kernel sometimes fails to deliver SIGHUP for ptys. | 3350 /* The kernel sometimes fails to deliver SIGHUP for ptys. |
3345 This looks incorrect, but it isn't, because _BSD causes | 3351 This looks incorrect, but it isn't, because _BSD causes |
3346 O_NDELAY to be defined in fcntl.h as O_NONBLOCK, | 3352 O_NDELAY to be defined in fcntl.h as O_NONBLOCK, |
3347 and that causes a value other than 0 when there is no input. */ | 3353 and that causes a value other than 0 when there is no input. */ |
3348 if (nread == 0) | 3354 if (nread == 0) |
3349 kill (0, SIGHUP); | 3355 kill (0, SIGHUP); |
3350 #endif | 3356 #endif |
3351 /* This code is wrong, but at least it gets the right results. | 3357 /* Retry the read if it was interrupted. */ |
3352 Fix it for 19.23. */ | |
3353 /* Retry the read if it is interrupted. */ | |
3354 if (nread >= 0 | 3358 if (nread >= 0 |
3355 || ! (errno == EAGAIN | 3359 || ! (errno == EAGAIN |
3356 #ifdef EFAULT | 3360 #ifdef EFAULT |
3357 || errno == EFAULT | 3361 || errno == EFAULT |
3358 #endif | 3362 #endif |