@@ -175,8 +175,8 @@ typedef int waitstatus;
175175#endif
176176static pid_t wait4pid (pid_t , waitstatus * );
177177
178- static int WaitForChar (long msec , int * interrupted );
179- static int WaitForCharOrMouse (long msec , int * interrupted );
178+ static int WaitForChar (long msec , int * interrupted , int ignore_input );
179+ static int WaitForCharOrMouse (long msec , int * interrupted , int ignore_input );
180180#if defined(__BEOS__ ) || defined(VMS )
181181int RealWaitForChar (int , long , int * , int * interrupted );
182182#else
@@ -481,7 +481,7 @@ mch_inchar(
481481 * We want to be interrupted by the winch signal
482482 * or by an event on the monitored file descriptors.
483483 */
484- if (WaitForChar (wait_time , & interrupted ))
484+ if (WaitForChar (wait_time , & interrupted , FALSE ))
485485 {
486486 /* If input was put directly in typeahead buffer bail out here. */
487487 if (typebuf_changed (tb_change_cnt ))
@@ -536,9 +536,20 @@ handle_resize(void)
536536 int
537537mch_char_avail (void )
538538{
539- return WaitForChar (0L , NULL );
539+ return WaitForChar (0L , NULL , FALSE );
540540}
541541
542+ #if defined(FEAT_TERMINAL ) || defined(PROTO )
543+ /*
544+ * Check for any pending input or messages.
545+ */
546+ int
547+ mch_check_messages (void )
548+ {
549+ return WaitForChar (0L , NULL , TRUE);
550+ }
551+ #endif
552+
542553#if defined(HAVE_TOTAL_MEM ) || defined(PROTO )
543554# ifdef HAVE_SYS_RESOURCE_H
544555# include <sys/resource.h>
@@ -718,7 +729,7 @@ mch_delay(long msec, int ignoreinput)
718729 in_mch_delay = FALSE;
719730 }
720731 else
721- WaitForChar (msec , NULL );
732+ WaitForChar (msec , NULL , FALSE );
722733}
723734
724735#if defined(HAVE_STACK_LIMIT ) \
@@ -5616,13 +5627,15 @@ mch_breakcheck(int force)
56165627 * from inbuf[].
56175628 * "msec" == -1 will block forever.
56185629 * Invokes timer callbacks when needed.
5630+ * When "ignore_input" is TRUE even check for pending input when input is
5631+ * already available.
56195632 * "interrupted" (if not NULL) is set to TRUE when no character is available
56205633 * but something else needs to be done.
56215634 * Returns TRUE when a character is available.
56225635 * When a GUI is being used, this will never get called -- webb
56235636 */
56245637 static int
5625- WaitForChar (long msec , int * interrupted )
5638+ WaitForChar (long msec , int * interrupted , int ignore_input )
56265639{
56275640#ifdef FEAT_TIMERS
56285641 long due_time ;
@@ -5631,7 +5644,7 @@ WaitForChar(long msec, int *interrupted)
56315644
56325645 /* When waiting very briefly don't trigger timers. */
56335646 if (msec >= 0 && msec < 10L )
5634- return WaitForCharOrMouse (msec , NULL );
5647+ return WaitForCharOrMouse (msec , NULL , ignore_input );
56355648
56365649 while (msec < 0 || remaining > 0 )
56375650 {
@@ -5645,7 +5658,7 @@ WaitForChar(long msec, int *interrupted)
56455658 }
56465659 if (due_time <= 0 || (msec > 0 && due_time > remaining ))
56475660 due_time = remaining ;
5648- if (WaitForCharOrMouse (due_time , interrupted ))
5661+ if (WaitForCharOrMouse (due_time , interrupted , ignore_input ))
56495662 return TRUE;
56505663 if (interrupted != NULL && * interrupted )
56515664 /* Nothing available, but need to return so that side effects get
@@ -5656,20 +5669,21 @@ WaitForChar(long msec, int *interrupted)
56565669 }
56575670 return FALSE;
56585671#else
5659- return WaitForCharOrMouse (msec , interrupted );
5672+ return WaitForCharOrMouse (msec , interrupted , ignore_input );
56605673#endif
56615674}
56625675
56635676/*
56645677 * Wait "msec" msec until a character is available from the mouse or keyboard
56655678 * or from inbuf[].
56665679 * "msec" == -1 will block forever.
5680+ * for "ignore_input" see WaitForCharOr().
56675681 * "interrupted" (if not NULL) is set to TRUE when no character is available
56685682 * but something else needs to be done.
56695683 * When a GUI is being used, this will never get called -- webb
56705684 */
56715685 static int
5672- WaitForCharOrMouse (long msec , int * interrupted )
5686+ WaitForCharOrMouse (long msec , int * interrupted , int ignore_input )
56735687{
56745688#ifdef FEAT_MOUSE_GPM
56755689 int gpm_process_wanted ;
@@ -5679,7 +5693,7 @@ WaitForCharOrMouse(long msec, int *interrupted)
56795693#endif
56805694 int avail ;
56815695
5682- if (input_available ()) /* something in inbuf[] */
5696+ if (! ignore_input && input_available ()) /* something in inbuf[] */
56835697 return 1 ;
56845698
56855699#if defined(FEAT_MOUSE_DEC )
@@ -5722,7 +5736,7 @@ WaitForCharOrMouse(long msec, int *interrupted)
57225736# endif
57235737 if (!avail )
57245738 {
5725- if (input_available ())
5739+ if (! ignore_input && input_available ())
57265740 return 1 ;
57275741# ifdef FEAT_XCLIPBOARD
57285742 if (rest == 0 || !do_xterm_trace ())
0 commit comments