patch 8.2.0774: t_TI and t_TE are output when using 'visualbell'

Problem:    t_TI and t_TE are output when using 'visualbell'. (Dominique
            Pelle)
Solution:   Do not change the terminal mode for a short sleep.  Do not output
            t_TI and t_TE when switching to/from TMODE_SLEEP. Make tmode an
            enum.
diff --git a/src/term.c b/src/term.c
index 1260c9a..a575227 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3471,7 +3471,12 @@
 #endif
 	    if (tmode != TMODE_RAW)
 		mch_setmouse(FALSE);	// switch mouse off
-	    if (termcap_active)
+
+	    // Disable bracketed paste and modifyOtherKeys in cooked mode.
+	    // Avoid doing this too often, on some terminals the codes are not
+	    // handled properly.
+	    if (termcap_active && tmode != TMODE_SLEEP
+						   && cur_tmode != TMODE_SLEEP)
 	    {
 		if (tmode != TMODE_RAW)
 		{