0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 9.0.0318: clearing screen causes flicker

Problem:    Clearing screen causes flicker.
Solution:   Do not clear but redraw in more cases.  Add () to "wait_return".
This commit is contained in:
Bram Moolenaar 2022-08-29 15:06:50 +01:00
parent b13d3405ff
commit 13608d851a
14 changed files with 39 additions and 37 deletions

View File

@ -1930,24 +1930,9 @@ win_update(win_T *wp)
} }
} }
// When starting redraw in the first line, redraw all lines. When // When starting redraw in the first line, redraw all lines.
// there is only one window it's probably faster to clear the screen
// first.
if (mid_start == 0) if (mid_start == 0)
{
mid_end = wp->w_height; mid_end = wp->w_height;
if (ONE_WINDOW && !WIN_IS_POPUP(wp))
{
// Clear the screen when it was not done by win_del_lines() or
// win_ins_lines() above, "screen_cleared" is FALSE or MAYBE
// then.
if (screen_cleared != TRUE)
screenclear();
// The screen was cleared, redraw the tab pages line.
if (redraw_tabline)
draw_tabline();
}
}
// When win_del_lines() or win_ins_lines() caused the screen to be // When win_del_lines() or win_ins_lines() caused the screen to be
// cleared (only happens for the first window) or when screenclear() // cleared (only happens for the first window) or when screenclear()
@ -3183,7 +3168,7 @@ redraw_later_clear(void)
} }
/* /*
* Mark all windows to be redrawn later. * Mark all windows to be redrawn later. Except popup windows.
*/ */
void void
redraw_all_later(int type) redraw_all_later(int type)
@ -3196,6 +3181,20 @@ redraw_all_later(int type)
set_must_redraw(type); set_must_redraw(type);
} }
#if 0 // not actually used yet, it probably should
/*
* Mark all windows, including popup windows, to be redrawn.
*/
void
redraw_all_windows_later(int type)
{
redraw_all_later(type);
#ifdef FEAT_PROP_POPUP
popup_redraw_all(); // redraw all popup windows
#endif
}
#endif
/* /*
* Set "must_redraw" to "type" unless it already has a higher value * Set "must_redraw" to "type" unless it already has a higher value
* or it is currently not allowed. * or it is currently not allowed.

View File

@ -1151,7 +1151,8 @@ do_filter(
#if defined(FEAT_EVAL) #if defined(FEAT_EVAL)
if (!aborting()) if (!aborting())
#endif #endif
(void)semsg(_(e_cant_create_file_str), itmp); // will call wait_return // will call wait_return()
(void)semsg(_(e_cant_create_file_str), itmp);
goto filterend; goto filterend;
} }
if (curbuf != old_curbuf) if (curbuf != old_curbuf)
@ -4331,7 +4332,7 @@ ex_substitute(exarg_T *eap)
// needed // needed
msg_no_more = TRUE; msg_no_more = TRUE;
// write message same highlighting as for // write message same highlighting as for
// wait_return // wait_return()
smsg_attr(HL_ATTR(HLF_R), smsg_attr(HL_ATTR(HLF_R),
_("replace with %s (y/n/a/q/l/^E/^Y)?"), sub); _("replace with %s (y/n/a/q/l/^E/^Y)?"), sub);
msg_no_more = FALSE; msg_no_more = FALSE;

View File

@ -348,7 +348,7 @@ check_changed_any(
if (!(p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))) if (!(p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)))
#endif #endif
{ {
// There must be a wait_return for this message, do_buffer() // There must be a wait_return() for this message, do_buffer()
// may cause a redraw. But wait_return() is a no-op when vgetc() // may cause a redraw. But wait_return() is a no-op when vgetc()
// is busy (Quit used from window menu), then make sure we don't // is busy (Quit used from window menu), then make sure we don't
// cause a scroll up. // cause a scroll up.

View File

@ -879,7 +879,7 @@ do_cmdline(
, in_vim9script() ? GETLINE_CONCAT_CONTBAR , in_vim9script() ? GETLINE_CONCAT_CONTBAR
: GETLINE_CONCAT_CONT)) == NULL) : GETLINE_CONCAT_CONT)) == NULL)
{ {
// Don't call wait_return for aborted command line. The NULL // Don't call wait_return() for aborted command line. The NULL
// returned for the end of a sourced file or executed function // returned for the end of a sourced file or executed function
// doesn't do this. // doesn't do this.
if (KeyTyped && !(flags & DOCMD_REPEAT)) if (KeyTyped && !(flags & DOCMD_REPEAT))
@ -1355,7 +1355,7 @@ do_cmdline(
else if (need_wait_return) else if (need_wait_return)
{ {
/* /*
* The msg_start() above clears msg_didout. The wait_return we do * The msg_start() above clears msg_didout. The wait_return() we do
* here should not overwrite the command that may be shown before * here should not overwrite the command that may be shown before
* doing that. * doing that.
*/ */

View File

@ -1666,7 +1666,7 @@ getcmdline_int(
if (!cmd_silent) if (!cmd_silent)
{ {
i = msg_scrolled; i = msg_scrolled;
msg_scrolled = 0; // avoid wait_return message msg_scrolled = 0; // avoid wait_return() message
gotocmdline(TRUE); gotocmdline(TRUE);
msg_scrolled += i; msg_scrolled += i;
redrawcmdprompt(); // draw prompt or indent redrawcmdprompt(); // draw prompt or indent

View File

@ -2098,7 +2098,7 @@ getchar_common(typval_T *argvars, typval_T *rettv)
// redraw the screen after getchar() // redraw the screen after getchar()
if (p_ch == 0) if (p_ch == 0)
update_screen(UPD_CLEAR); update_screen(UPD_NOT_VALID);
set_vim_var_nr(VV_MOUSE_WIN, 0); set_vim_var_nr(VV_MOUSE_WIN, 0);
set_vim_var_nr(VV_MOUSE_WINID, 0); set_vim_var_nr(VV_MOUSE_WINID, 0);

View File

@ -2474,7 +2474,7 @@ cs_show(exarg_T *eap UNUSED)
} }
} }
wait_return(TRUE); wait_return(FALSE);
return CSCOPE_SUCCESS; return CSCOPE_SUCCESS;
} }

View File

@ -651,7 +651,7 @@ vim_main2(void)
/* /*
* When done something that is not allowed or given an error message call * When done something that is not allowed or given an error message call
* wait_return. This must be done before starttermcap(), because it may * wait_return(). This must be done before starttermcap(), because it may
* switch to another screen. It must be done after settmode(TMODE_RAW), * switch to another screen. It must be done after settmode(TMODE_RAW),
* because we want to react on a single key stroke. * because we want to react on a single key stroke.
* Call settmode and starttermcap here, so the T_KS and T_TI may be * Call settmode and starttermcap here, so the T_KS and T_TI may be
@ -1226,7 +1226,7 @@ main_loop(
did_check_timestamps = FALSE; did_check_timestamps = FALSE;
if (need_check_timestamps) if (need_check_timestamps)
check_timestamps(FALSE); check_timestamps(FALSE);
if (need_wait_return) // if wait_return still needed ... if (need_wait_return) // if wait_return() still needed ...
wait_return(FALSE); // ... call it now wait_return(FALSE); // ... call it now
if (need_start_insertmode && goto_im() && !VIsual_active) if (need_start_insertmode && goto_im() && !VIsual_active)
{ {

View File

@ -822,7 +822,7 @@ ml_open_file(buf_T *buf)
if (*p_dir != NUL && mfp->mf_fname == NULL) if (*p_dir != NUL && mfp->mf_fname == NULL)
{ {
need_wait_return = TRUE; // call wait_return later need_wait_return = TRUE; // call wait_return() later
++no_wait_return; ++no_wait_return;
(void)semsg(_(e_unable_to_open_swap_file_for_str_recovery_impossible), (void)semsg(_(e_unable_to_open_swap_file_for_str_recovery_impossible),
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);

View File

@ -94,7 +94,7 @@ static int verbose_did_open = FALSE;
/* /*
* msg(s) - displays the string 's' on the status line * msg(s) - displays the string 's' on the status line
* When terminal not initialized (yet) mch_errmsg(..) is used. * When terminal not initialized (yet) mch_errmsg(..) is used.
* return TRUE if wait_return not called * return TRUE if wait_return() not called
*/ */
int int
msg(char *s) msg(char *s)
@ -631,7 +631,7 @@ do_perror(char *msg)
* Rings the bell, if appropriate, and calls message() to do the real work * Rings the bell, if appropriate, and calls message() to do the real work
* When terminal not initialized (yet) mch_errmsg(..) is used. * When terminal not initialized (yet) mch_errmsg(..) is used.
* *
* Return TRUE if wait_return not called. * Return TRUE if wait_return() not called.
* Note: caller must check 'emsg_not_now()' before calling this. * Note: caller must check 'emsg_not_now()' before calling this.
*/ */
static int static int
@ -758,7 +758,7 @@ emsg_core(char_u *s)
attr = HL_ATTR(HLF_E); // set highlight mode for error messages attr = HL_ATTR(HLF_E); // set highlight mode for error messages
if (msg_scrolled != 0) if (msg_scrolled != 0)
need_wait_return = TRUE; // needed in case emsg() is called after need_wait_return = TRUE; // needed in case emsg() is called after
// wait_return has reset need_wait_return // wait_return() has reset need_wait_return
// and a redraw is expected because // and a redraw is expected because
// msg_scrolled is non-zero // msg_scrolled is non-zero
@ -2456,7 +2456,7 @@ msg_puts_display(
{ {
#endif #endif
inc_msg_scrolled(); inc_msg_scrolled();
need_wait_return = TRUE; // may need wait_return in main() need_wait_return = TRUE; // may need wait_return() in main()
redraw_cmdline = TRUE; redraw_cmdline = TRUE;
if (cmdline_row > 0 && !exmode_active) if (cmdline_row > 0 && !exmode_active)
--cmdline_row; --cmdline_row;
@ -3716,8 +3716,8 @@ msg_clr_cmdline(void)
/* /*
* end putting a message on the screen * end putting a message on the screen
* call wait_return if the message does not fit in the available space * call wait_return() if the message does not fit in the available space
* return TRUE if wait_return not called. * return TRUE if wait_return() not called.
*/ */
int int
msg_end(void) msg_end(void)

View File

@ -616,7 +616,7 @@ ask_yesno(char_u *str, int direct)
while (r != 'y' && r != 'n') while (r != 'y' && r != 'n')
{ {
// same highlighting as for wait_return // same highlighting as for wait_return()
smsg_attr(HL_ATTR(HLF_R), "%s (y/n)?", str); smsg_attr(HL_ATTR(HLF_R), "%s (y/n)?", str);
if (direct) if (direct)
r = get_keystroke(); r = get_keystroke();

View File

@ -2184,7 +2184,7 @@ skip:
// make sure all characters are printable // make sure all characters are printable
trans_characters(IObuff, IOSIZE); trans_characters(IObuff, IOSIZE);
++no_wait_return; // wait_return done later ++no_wait_return; // wait_return() done later
emsg((char *)IObuff); // show error highlighted emsg((char *)IObuff); // show error highlighted
--no_wait_return; --no_wait_return;

View File

@ -707,6 +707,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
318,
/**/ /**/
317, 317,
/**/ /**/

View File

@ -3095,7 +3095,7 @@ write_viminfo(char_u *file, int forceit)
{ {
int tt = msg_didany; int tt = msg_didany;
// avoid a wait_return for this message, it's annoying // avoid a wait_return() for this message, it's annoying
semsg(_(e_viminfo_file_is_not_writable_str), fname); semsg(_(e_viminfo_file_is_not_writable_str), fname);
msg_didany = tt; msg_didany = tt;
fclose(fp_in); fclose(fp_in);