]> granicus.if.org Git - vim/commitdiff
patch 8.2.2754: :sleep! does not always hide the cursor v8.2.2754
authorBram Moolenaar <Bram@vim.org>
Sun, 11 Apr 2021 11:29:18 +0000 (13:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 11 Apr 2021 11:29:18 +0000 (13:29 +0200)
Problem:    :sleep! does not always hide the cursor.
Solution:   Add the cursor_is_asleep flag. (Jeremy Lerner, closes #8097,
            closes #7998)

src/drawscreen.c
src/ex_docmd.c
src/gui.c
src/proto/term.pro
src/term.c
src/version.c

index 0e36e7917357e116f71b6d2db6b8485e0c567665..7df4a96f0e593e5f9d8b6654ace114ad5c6cea0c 100644 (file)
@@ -297,7 +297,9 @@ update_screen(int type_arg)
                // Remove the cursor before starting to do anything, because
                // scrolling may make it difficult to redraw the text under
                // it.
-               if (gui.in_use && wp == curwin)
+               // Also remove the cursor if it needs to be hidden due to an
+               // ongoing cursor-less sleep.
+               if (gui.in_use && (wp == curwin || cursor_is_sleeping()))
                {
                    gui_cursor_col = gui.cursor_col;
                    gui_cursor_row = gui.cursor_row;
@@ -306,7 +308,6 @@ update_screen(int type_arg)
                }
            }
 #endif
-
            win_update(wp);
        }
 
index c8cb11ba7538b2f2990a6cf5c2d70da982ff7b45..7c1c448551182789c6cbe118f543aa7e1f00c899 100644 (file)
@@ -7370,7 +7370,7 @@ do_sleep(long msec, int hide_cursor)
 # endif
 
     if (hide_cursor)
-        cursor_off();
+        cursor_sleep();
     else
         cursor_on();
 
@@ -7422,6 +7422,9 @@ do_sleep(long msec, int hide_cursor)
     // input buffer, otherwise a following call to input() fails.
     if (got_int)
        (void)vpeekc();
+
+    if (hide_cursor)
+        cursor_unsleep();
 }
 
 /*
index 0265f7c964d8b3f1468f3f55dbe48c6a4e04a57d..c0374c561dad1c1214562ef28370735caae144a7 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -1120,6 +1120,11 @@ gui_update_cursor(
                    || gui.row != gui.cursor_row || gui.col != gui.cursor_col)
     {
        gui_undraw_cursor();
+
+       // If a cursor-less sleep is ongoing, leave the cursor invisible
+       if (cursor_is_sleeping())
+           return;
+
        if (gui.row < 0)
            return;
 #ifdef HAVE_INPUT_METHOD
index 1b3780204be77377bf0463d3851d63626e9cd51d..efb25553433f30c8ff2cb658d2960e4856e6da63 100644 (file)
@@ -56,6 +56,9 @@ void scroll_start(void);
 void cursor_on_force(void);
 void cursor_on(void);
 void cursor_off(void);
+int cursor_is_sleeping(void);
+void cursor_sleep(void);
+void cursor_unsleep(void);
 void term_cursor_mode(int forced);
 void term_cursor_color(char_u *color);
 int blink_state_is_inverted(void);
index ad52d1b315c0def92d26aa3edbbe2df9b66d8708..0a4e5b758a2b4eef944123e6eca7f4679dd210b6 100644 (file)
@@ -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.
index c760738bea6f85dbacf2891542e9659b7e5942d7..d18c0f821610da83ee583783c608170d1456c18c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2754,
 /**/
     2753,
 /**/