Mercurial > emacs
diff src/process.c @ 109164:a7b09b567d58
If kbd_buffer is becoming full, stop reading until it drains (Bug#6571).
* keyboard.c (input_available_signal): Declare.
(kbd_buffer_nr_stored): New function.
(kbd_buffer_store_event_hold): If kbd_buffer_nr_stored returns
more than KBD_BUFFER_SIZE/2, stop reding input (Bug#6571).
(kbd_buffer_get_event): If input is suspended and kbd_buffer_nr_stored
returns less than KBD_BUFFER_SIZE/4, resume reding input (Bug#6571).
(tty_read_avail_input): If input is on hold, return.
Don't read more that free slots in kbd_buffer (Bug#6571).
* process.h (hold_keyboard_input, unhold_keyboard_input)
(kbd_on_hold_p): Declare.
* process.c (kbd_is_on_hold): New variable.
(hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p): New
functions.
(wait_reading_process_output): If kbd_on_hold_p returns non-zero,
select on empty input mask.
(init_process): Initialize kbd_is_on_hold to 0.
| author | Jan D <jan.h.d@swipnet.se> |
|---|---|
| date | Wed, 07 Jul 2010 19:39:49 +0200 |
| parents | f8660b83cdbf |
| children | 750db9f3e6d8 |
line wrap: on
line diff
--- a/src/process.c Wed Jul 07 18:31:11 2010 +0300 +++ b/src/process.c Wed Jul 07 19:39:49 2010 +0200 @@ -306,6 +306,10 @@ static SELECT_TYPE input_wait_mask; +/* Non-zero if keyboard input is on hold, zero otherwise. */ + +static int kbd_is_on_hold; + /* Mask that excludes keyboard input descriptor(s). */ static SELECT_TYPE non_keyboard_wait_mask; @@ -4731,7 +4735,10 @@ SELECT_TYPE Ctemp; #endif - Atemp = input_wait_mask; + if (kbd_on_hold_p ()) + FD_ZERO (&Atemp); + else + Atemp = input_wait_mask; IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); EMACS_SET_SECS_USECS (timeout, 0, 0); @@ -7010,6 +7017,30 @@ +/* Stop reading input from keyboard sources. */ + +void +hold_keyboard_input (void) +{ + kbd_is_on_hold = 1; +} + +/* Resume reading input from keyboard sources. */ + +void +unhold_keyboard_input (void) +{ + kbd_is_on_hold = 0; +} + +/* Return non-zero if keyboard input is on hold, zero otherwise. */ + +int +kbd_on_hold_p (void) +{ + return kbd_is_on_hold; +} + /* Add DESC to the set of keyboard input descriptors. */ void @@ -7901,6 +7932,7 @@ void init_process () { + kbd_is_on_hold = 0; } void
