diff src/term.c @ 24428:9299d21d1d5d v8.2.2754

patch 8.2.2754: :sleep! does not always hide the cursor Commit: https://github.com/vim/vim/commit/09f067fca38c9f89ad088e8c096c4df3998575e2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 11 13:29:18 2021 +0200 patch 8.2.2754: :sleep! does not always hide the cursor Problem: :sleep! does not always hide the cursor. Solution: Add the cursor_is_asleep flag. (Jeremy Lerner, closes https://github.com/vim/vim/issues/8097, closes #7998)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Apr 2021 13:30:06 +0200
parents 1e85e76f9e76
children e97a14604f65
line wrap: on
line diff
--- a/src/term.c
+++ b/src/term.c
@@ -3932,8 +3932,12 @@ scroll_start(void)
     }
 }
 
+// True if cursor is not visible
 static int cursor_is_off = FALSE;
 
+// True if cursor is not visible due to an ongoing cursor-less sleep
+static int cursor_is_asleep = FALSE;
+
 /*
  * Enable the cursor without checking if it's already enabled.
  */
@@ -3942,6 +3946,7 @@ cursor_on_force(void)
 {
     out_str(T_VE);
     cursor_is_off = FALSE;
+    cursor_is_asleep = FALSE;
 }
 
 /*
@@ -3950,7 +3955,7 @@ cursor_on_force(void)
     void
 cursor_on(void)
 {
-    if (cursor_is_off)
+    if (cursor_is_off && !cursor_is_asleep)
 	cursor_on_force();
 }
 
@@ -3967,6 +3972,35 @@ cursor_off(void)
     }
 }
 
+/*
+ * Check whether the cursor is invisible due to an ongoing cursor-less sleep
+ */
+    int
+cursor_is_sleeping(void)
+{
+    return cursor_is_asleep;
+}
+
+/*
+ * Disable the cursor and mark it disabled by cursor-less sleep
+ */
+    void
+cursor_sleep(void)
+{
+    cursor_is_asleep = TRUE;
+    cursor_off();
+}
+
+/*
+ * Enable the cursor and mark it not disabled by cursor-less sleep
+ */
+    void
+cursor_unsleep(void)
+{
+    cursor_is_asleep = FALSE;
+    cursor_on();
+}
+
 #if defined(CURSOR_SHAPE) || defined(PROTO)
 /*
  * Set cursor shape to match Insert or Replace mode.