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 #8097,
            closes #7998)
diff --git a/src/term.c b/src/term.c
index ad52d1b..0a4e5b7 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3932,8 +3932,12 @@
     }
 }
 
+// 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 @@
 {
     out_str(T_VE);
     cursor_is_off = FALSE;
+    cursor_is_asleep = FALSE;
 }
 
 /*
@@ -3950,7 +3955,7 @@
     void
 cursor_on(void)
 {
-    if (cursor_is_off)
+    if (cursor_is_off && !cursor_is_asleep)
 	cursor_on_force();
 }
 
@@ -3967,6 +3972,35 @@
     }
 }
 
+/*
+ * 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.