@@ -2885,6 +2885,18 @@ gui_insert_lines(int row, int count)
28852885 }
28862886}
28872887
2888+ /*
2889+ * Passed to ui_wait_for_chars_or_timer(), ignoring extra arguments.
2890+ */
2891+ static int
2892+ gui_wait_for_chars_3 (
2893+ long wtime ,
2894+ int * interrupted UNUSED ,
2895+ int ignore_input UNUSED )
2896+ {
2897+ return gui_mch_wait_for_chars (wtime );
2898+ }
2899+
28882900/*
28892901 * Returns OK if a character was found to be available within the given time,
28902902 * or FAIL otherwise.
@@ -2893,32 +2905,7 @@ gui_insert_lines(int row, int count)
28932905gui_wait_for_chars_or_timer (long wtime )
28942906{
28952907#ifdef FEAT_TIMERS
2896- int due_time ;
2897- long remaining = wtime ;
2898- int tb_change_cnt = typebuf .tb_change_cnt ;
2899-
2900- /* When waiting very briefly don't trigger timers. */
2901- if (wtime >= 0 && wtime < 10L )
2902- return gui_mch_wait_for_chars (wtime );
2903-
2904- while (wtime < 0 || remaining > 0 )
2905- {
2906- /* Trigger timers and then get the time in wtime until the next one is
2907- * due. Wait up to that time. */
2908- due_time = check_due_timer ();
2909- if (typebuf .tb_change_cnt != tb_change_cnt )
2910- {
2911- /* timer may have used feedkeys() */
2912- return FAIL ;
2913- }
2914- if (due_time <= 0 || (wtime > 0 && due_time > remaining ))
2915- due_time = remaining ;
2916- if (gui_mch_wait_for_chars (due_time ))
2917- return OK ;
2918- if (wtime > 0 )
2919- remaining -= due_time ;
2920- }
2921- return FAIL ;
2908+ return ui_wait_for_chars_or_timer (wtime , gui_wait_for_chars_3 , NULL , 0 );
29222909#else
29232910 return gui_mch_wait_for_chars (wtime );
29242911#endif
@@ -2933,10 +2920,9 @@ gui_wait_for_chars_or_timer(long wtime)
29332920 * or FAIL otherwise.
29342921 */
29352922 int
2936- gui_wait_for_chars (long wtime )
2923+ gui_wait_for_chars (long wtime , int tb_change_cnt )
29372924{
29382925 int retval ;
2939- int tb_change_cnt = typebuf .tb_change_cnt ;
29402926
29412927#ifdef FEAT_MENU
29422928 /*
@@ -2974,13 +2960,13 @@ gui_wait_for_chars(long wtime)
29742960 retval = FAIL ;
29752961 /*
29762962 * We may want to trigger the CursorHold event. First wait for
2977- * 'updatetime' and if nothing is typed within that time put the
2978- * K_CURSORHOLD key in the input buffer.
2963+ * 'updatetime' and if nothing is typed within that time, and feedkeys()
2964+ * wasn't used, put the K_CURSORHOLD key in the input buffer.
29792965 */
29802966 if (gui_wait_for_chars_or_timer (p_ut ) == OK )
29812967 retval = OK ;
29822968#ifdef FEAT_AUTOCMD
2983- else if (trigger_cursorhold ())
2969+ else if (trigger_cursorhold () && typebuf . tb_change_cnt == tb_change_cnt )
29842970 {
29852971 char_u buf [3 ];
29862972
@@ -3005,6 +2991,22 @@ gui_wait_for_chars(long wtime)
30052991 return retval ;
30062992}
30072993
2994+ /*
2995+ * Equivalent of mch_inchar() for the GUI.
2996+ */
2997+ int
2998+ gui_inchar (
2999+ char_u * buf ,
3000+ int maxlen ,
3001+ long wtime , /* milli seconds */
3002+ int tb_change_cnt )
3003+ {
3004+ if (gui_wait_for_chars (wtime , tb_change_cnt )
3005+ && !typebuf_changed (tb_change_cnt ))
3006+ return read_from_input_buf (buf , (long )maxlen );
3007+ return 0 ;
3008+ }
3009+
30083010/*
30093011 * Fill p[4] with mouse coordinates encoded for check_termcode().
30103012 */
0 commit comments