To: vim_dev@googlegroups.com Subject: Patch 8.2.2754 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2754 Problem: :sleep! does not always hide the cursor. Solution: Add the cursor_is_asleep flag. (Jeremy Lerner, closes #8097, closes #7998) Files: src/drawscreen.c, src/ex_docmd.c, src/gui.c, src/proto/term.pro, src/term.c *** ../vim-8.2.2753/src/drawscreen.c 2021-04-01 16:15:59.184829183 +0200 --- src/drawscreen.c 2021-04-11 13:27:29.279166225 +0200 *************** *** 297,303 **** // 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) { gui_cursor_col = gui.cursor_col; gui_cursor_row = gui.cursor_row; --- 297,305 ---- // Remove the cursor before starting to do anything, because // scrolling may make it difficult to redraw the text under // it. ! // 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,312 **** } } #endif - win_update(wp); } --- 308,313 ---- *** ../vim-8.2.2753/src/ex_docmd.c 2021-04-05 22:27:33.402532604 +0200 --- src/ex_docmd.c 2021-04-11 13:22:59.912017670 +0200 *************** *** 7370,7376 **** # endif if (hide_cursor) ! cursor_off(); else cursor_on(); --- 7370,7376 ---- # endif if (hide_cursor) ! cursor_sleep(); else cursor_on(); *************** *** 7422,7427 **** --- 7422,7430 ---- // input buffer, otherwise a following call to input() fails. if (got_int) (void)vpeekc(); + + if (hide_cursor) + cursor_unsleep(); } /* *** ../vim-8.2.2753/src/gui.c 2020-11-25 15:52:28.297284647 +0100 --- src/gui.c 2021-04-11 13:27:19.183199131 +0200 *************** *** 1120,1125 **** --- 1120,1130 ---- || 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 *** ../vim-8.2.2753/src/proto/term.pro 2020-06-13 15:47:21.066282284 +0200 --- src/proto/term.pro 2021-04-11 13:27:38.587135850 +0200 *************** *** 56,61 **** --- 56,64 ---- 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); *** ../vim-8.2.2753/src/term.c 2021-03-26 14:14:14.618292981 +0100 --- src/term.c 2021-04-11 13:28:09.191035633 +0200 *************** *** 3932,3939 **** --- 3932,3943 ---- } } + // 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,3947 **** --- 3946,3952 ---- { out_str(T_VE); cursor_is_off = FALSE; + cursor_is_asleep = FALSE; } /* *************** *** 3950,3956 **** void cursor_on(void) { ! if (cursor_is_off) cursor_on_force(); } --- 3955,3961 ---- void cursor_on(void) { ! if (cursor_is_off && !cursor_is_asleep) cursor_on_force(); } *************** *** 3967,3972 **** --- 3972,4006 ---- } } + /* + * 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. *** ../vim-8.2.2753/src/version.c 2021-04-10 22:35:40.491360252 +0200 --- src/version.c 2021-04-11 13:25:16.431593386 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2754, /**/ -- From "know your smileys": (X0||) Double hamburger with lettuce and tomato /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///