summaryrefslogtreecommitdiff
path: root/src/misc1.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-27 17:09:37 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-27 17:09:37 +0200
commit2e147caa14f622dfd1c1def8e07c113b9b85d4b2 (patch)
tree53c69cc89daa1da1462c061da18e104ae3972f7e /src/misc1.c
parent0b2eef24bcbe2c85c90bbde914a1782cbedc5c72 (diff)
downloadvim-git-2e147caa14f622dfd1c1def8e07c113b9b85d4b2.tar.gz
patch 8.0.0683: visual bell flashes too quicklyv8.0.0683
Problem: When using a visual bell there is no delay, causing the flash to be very short, possibly unnoticeable. Also, the flash and the beep can lockup the UI when repeated often. Solution: Do the delay in Vim or flush the output before the delay. Limit the bell to once per half a second. (Ozaki Kiichi, closes #1789)
Diffstat (limited to 'src/misc1.c')
-rw-r--r--src/misc1.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/misc1.c b/src/misc1.c
index bc927b162..7c2f26cfe 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3685,16 +3685,30 @@ vim_beep(
{
if (!((bo_flags & val) || (bo_flags & BO_ALL)))
{
- if (p_vb
+#ifdef ELAPSED_FUNC
+ static int did_init = FALSE;
+ static ELAPSED_TYPE start_tv;
+
+ /* Only beep once per half a second, otherwise a sequence of beeps
+ * would freeze Vim. */
+ if (!did_init || ELAPSED_FUNC(start_tv) > 500)
+ {
+ did_init = TRUE;
+ ELAPSED_INIT(start_tv);
+#endif
+ if (p_vb
#ifdef FEAT_GUI
- /* While the GUI is starting up the termcap is set for the
- * GUI but the output still goes to a terminal. */
- && !(gui.in_use && gui.starting)
+ /* While the GUI is starting up the termcap is set for
+ * the GUI but the output still goes to a terminal. */
+ && !(gui.in_use && gui.starting)
+#endif
+ )
+ out_str_cf(T_VB);
+ else
+ out_char(BELL);
+#ifdef ELAPSED_FUNC
+ }
#endif
- )
- out_str(T_VB);
- else
- out_char(BELL);
}
/* When 'verbose' is set and we are sourcing a script or executing a