File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3685,16 +3685,30 @@ vim_beep(
36853685 {
36863686 if (!((bo_flags & val ) || (bo_flags & BO_ALL )))
36873687 {
3688- if (p_vb
3688+ #ifdef ELAPSED_FUNC
3689+ static int did_init = FALSE;
3690+ static ELAPSED_TYPE start_tv ;
3691+
3692+ /* Only beep once per half a second, otherwise a sequence of beeps
3693+ * would freeze Vim. */
3694+ if (!did_init || ELAPSED_FUNC (start_tv ) > 500 )
3695+ {
3696+ did_init = TRUE;
3697+ ELAPSED_INIT (start_tv );
3698+ #endif
3699+ if (p_vb
36893700#ifdef FEAT_GUI
3690- /* While the GUI is starting up the termcap is set for the
3691- * GUI but the output still goes to a terminal. */
3692- && !(gui .in_use && gui .starting )
3701+ /* While the GUI is starting up the termcap is set for
3702+ * the GUI but the output still goes to a terminal. */
3703+ && !(gui .in_use && gui .starting )
3704+ #endif
3705+ )
3706+ out_str_cf (T_VB );
3707+ else
3708+ out_char (BELL );
3709+ #ifdef ELAPSED_FUNC
3710+ }
36933711#endif
3694- )
3695- out_str (T_VB );
3696- else
3697- out_char (BELL );
36983712 }
36993713
37003714 /* When 'verbose' is set and we are sourcing a script or executing a
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ void out_flush_check(void);
1616void out_trash (void );
1717void out_char (unsigned c );
1818void out_str_nf (char_u * s );
19+ void out_str_cf (char_u * s );
1920void out_str (char_u * s );
2021void term_windgoto (int row , int col );
2122void term_cursor_right (int i );
Original file line number Diff line number Diff line change @@ -2513,6 +2513,75 @@ out_str_nf(char_u *s)
25132513}
25142514#endif
25152515
2516+ /*
2517+ * A conditional-flushing out_str, mainly for visualbell.
2518+ * Handles a delay internally, because termlib may not respect the delay or do
2519+ * it at the wrong time.
2520+ * Note: Only for terminal strings.
2521+ */
2522+ void
2523+ out_str_cf (char_u * s )
2524+ {
2525+ if (s != NULL && * s )
2526+ {
2527+ char_u * p ;
2528+
2529+ #ifdef FEAT_GUI
2530+ /* Don't use tputs() when GUI is used, ncurses crashes. */
2531+ if (gui .in_use )
2532+ {
2533+ out_str_nf (s );
2534+ return ;
2535+ }
2536+ #endif
2537+ if (out_pos > OUT_SIZE - 20 )
2538+ out_flush ();
2539+ #ifdef HAVE_TGETENT
2540+ for (p = s ; * s ; ++ s )
2541+ {
2542+ /* flush just before delay command */
2543+ if (* s == '$' && * (s + 1 ) == '<' )
2544+ {
2545+ char_u save_c = * s ;
2546+ int duration = atoi ((char * )s + 2 );
2547+
2548+ * s = NUL ;
2549+ tputs ((char * )p , 1 , TPUTSFUNCAST out_char_nf );
2550+ * s = save_c ;
2551+ out_flush ();
2552+ #ifdef ELAPSED_FUNC
2553+ /* Only sleep here if we can limit this happening in
2554+ * vim_beep(). */
2555+ p = vim_strchr (s , '>' );
2556+ if (p == NULL || duration <= 0 )
2557+ {
2558+ /* can't parse the time, don't sleep here */
2559+ p = s ;
2560+ }
2561+ else
2562+ {
2563+ ++ p ;
2564+ do_sleep (duration );
2565+ }
2566+ #else
2567+ /* Rely on the terminal library to sleep. */
2568+ p = s ;
2569+ #endif
2570+ break ;
2571+ }
2572+ }
2573+ tputs ((char * )p , 1 , TPUTSFUNCAST out_char_nf );
2574+ #else
2575+ while (* s )
2576+ out_char_nf (* s ++ );
2577+ #endif
2578+
2579+ /* For testing we write one string at a time. */
2580+ if (p_wd )
2581+ out_flush ();
2582+ }
2583+ }
2584+
25162585/*
25172586 * out_str(s): Put a character string a byte at a time into the output buffer.
25182587 * If HAVE_TGETENT is defined use the termcap parser. (jw)
Original file line number Diff line number Diff line change @@ -764,6 +764,8 @@ static char *(features[]) =
764764
765765static int included_patches [] =
766766{ /* Add new patch number below this line */
767+ /**/
768+ 683 ,
767769/**/
768770 682 ,
769771/**/
You can’t perform that action at this time.
0 commit comments