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/os_unix.c b/src/os_unix.c
index 9162f5b..6c308af 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -215,7 +215,8 @@
static int dont_check_job_ended = 0;
#endif
-static int curr_tmode = TMODE_COOK; // contains current terminal mode
+// Current terminal mode from mch_settmode(). Can differ from cur_tmode.
+static tmode_T mch_cur_tmode = TMODE_COOK;
#ifdef USE_XSMP
typedef struct
@@ -581,7 +582,7 @@
void
mch_delay(long msec, int ignoreinput)
{
- int old_tmode;
+ tmode_T old_tmode;
#ifdef FEAT_MZSCHEME
long total = msec; // remember original value
#endif
@@ -591,9 +592,10 @@
// Go to cooked mode without echo, to allow SIGINT interrupting us
// here. But we don't want QUIT to kill us (CTRL-\ used in a
// shell may produce SIGQUIT).
+ // Only do this if sleeping for more than half a second.
in_mch_delay = TRUE;
- old_tmode = curr_tmode;
- if (curr_tmode == TMODE_RAW)
+ old_tmode = mch_cur_tmode;
+ if (mch_cur_tmode == TMODE_RAW && msec > 500)
settmode(TMODE_SLEEP);
/*
@@ -650,7 +652,8 @@
while (total > 0);
#endif
- settmode(old_tmode);
+ if (msec > 500)
+ settmode(old_tmode);
in_mch_delay = FALSE;
}
else
@@ -3461,7 +3464,7 @@
}
void
-mch_settmode(int tmode)
+mch_settmode(tmode_T tmode)
{
static int first = TRUE;
@@ -3558,7 +3561,7 @@
ttybnew.sg_flags &= ~(ECHO);
ioctl(read_cmd_fd, TIOCSETN, &ttybnew);
#endif
- curr_tmode = tmode;
+ mch_cur_tmode = tmode;
}
/*
@@ -4455,7 +4458,7 @@
char *ifn = NULL;
char *ofn = NULL;
#endif
- int tmode = cur_tmode;
+ tmode_T tmode = cur_tmode;
char_u *newcmd; // only needed for unix
int x;
@@ -4549,7 +4552,7 @@
char_u *cmd,
int options) // SHELL_*, see vim.h
{
- int tmode = cur_tmode;
+ tmode_T tmode = cur_tmode;
pid_t pid;
pid_t wpid = 0;
pid_t wait_pid = 0;
@@ -5939,7 +5942,7 @@
void
mch_breakcheck(int force)
{
- if ((curr_tmode == TMODE_RAW || force)
+ if ((mch_cur_tmode == TMODE_RAW || force)
&& RealWaitForChar(read_cmd_fd, 0L, NULL, NULL))
fill_input_buf(FALSE);
}