]> granicus.if.org Git - vim/commitdiff
patch 8.2.0774: t_TI and t_TE are output when using 'visualbell' v8.2.0774
authorBram Moolenaar <Bram@vim.org>
Sun, 17 May 2020 12:06:16 +0000 (14:06 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 May 2020 12:06:16 +0000 (14:06 +0200)
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.

14 files changed:
src/globals.h
src/os_amiga.c
src/os_mswin.c
src/os_unix.c
src/os_vms.c
src/os_win32.c
src/proto/os_amiga.pro
src/proto/os_mswin.pro
src/proto/os_unix.pro
src/proto/os_vms.pro
src/proto/os_win32.pro
src/term.c
src/term.h
src/version.c

index 11e06be7ee9032a9e605080bc85e59cf3d93b1f2..60c3c668b8da18bb83308acc0cdb50baf3fe9c55 100644 (file)
@@ -1171,7 +1171,7 @@ EXTERN volatile sig_atomic_t got_int INIT(= FALSE); // set to TRUE when interrup
 EXTERN int     term_console INIT(= FALSE); // set to TRUE when console used
 #endif
 EXTERN int     termcap_active INIT(= FALSE);   // set by starttermcap()
-EXTERN int     cur_tmode INIT(= TMODE_COOK);   // input terminal mode
+EXTERN tmode_T cur_tmode INIT(= TMODE_COOK);   // input terminal mode
 EXTERN int     bangredo INIT(= FALSE);     // set to TRUE with ! command
 EXTERN int     searchcmdlen;               // length of previous search cmd
 #ifdef FEAT_SYN_HL
index 58e462d5cbeaa2e4e2128c34d6a7948faa82e560..850c26acdab2e5ce5a00b5508fe423afaaabf0cc 100644 (file)
@@ -977,7 +977,7 @@ mch_exit(int r)
  *     it sends a 0 to the console to make it back into a CON: from a RAW:
  */
     void
-mch_settmode(int tmode)
+mch_settmode(tmode_T tmode)
 {
 #if defined(__AROS__) || defined(__amigaos4__)
     if (!SetMode(raw_in, tmode == TMODE_RAW ? 1 : 0))
index 1c987c2d62751f579815d776804b8617eb371cfd..80009533c63663d3b655c533f086c41d68f590ea 100644 (file)
@@ -553,7 +553,7 @@ vim_stat(const char *name, stat_T *stp)
 
 #if (defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)) || defined(PROTO)
     void
-mch_settmode(int tmode UNUSED)
+mch_settmode(tmode_T tmode UNUSED)
 {
     // nothing to do
 }
index 9162f5bf8a0810eb2bcb6cfd610625dc8ad694ad..6c308affbe8f07968a3e3e8eb6de1028ed07c230 100644 (file)
@@ -215,7 +215,8 @@ static volatile sig_atomic_t in_mch_delay = FALSE; // sleeping in mch_delay()
 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 @@ mch_total_mem(int special UNUSED)
     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 @@ mch_delay(long msec, int ignoreinput)
        // 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 @@ mch_delay(long msec, int ignoreinput)
        while (total > 0);
 #endif
 
-       settmode(old_tmode);
+       if (msec > 500)
+           settmode(old_tmode);
        in_mch_delay = FALSE;
     }
     else
@@ -3461,7 +3464,7 @@ mch_tcgetattr(int fd, void *term)
 }
 
     void
-mch_settmode(int tmode)
+mch_settmode(tmode_T tmode)
 {
     static int first = TRUE;
 
@@ -3558,7 +3561,7 @@ mch_settmode(int tmode)
        ttybnew.sg_flags &= ~(ECHO);
     ioctl(read_cmd_fd, TIOCSETN, &ttybnew);
 #endif
-    curr_tmode = tmode;
+    mch_cur_tmode = tmode;
 }
 
 /*
@@ -4455,7 +4458,7 @@ mch_call_shell_system(
     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 @@ mch_call_shell_fork(
     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 @@ mch_create_pty_channel(job_T *job, jobopt_T *options)
     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);
 }
index 96fbc172f90087f2db34ccfe2c691fa5f20283e2..b8ad78898725b3e6c971ee95209ae974fe1caef6 100644 (file)
@@ -112,7 +112,7 @@ vul_item(ITEM *itm, short len, short cod, char *adr, int *ret)
 }
 
     void
-mch_settmode(int tmode)
+mch_settmode(tmode_T tmode)
 {
     int        status;
 
index d77e2169168bd2ff3faab09a7d697edaa36ab3a6..edd5cdac4e716a70bcb899423aea38e0c5d2c602 100644 (file)
@@ -3600,7 +3600,7 @@ handler_routine(
  * set the tty in (raw) ? "raw" : "cooked" mode
  */
     void
-mch_settmode(int tmode)
+mch_settmode(tmode_T tmode)
 {
     DWORD cmodein;
     DWORD cmodeout;
index 8e12f4da2892e50f116823b6a82f0f35ac9c61bb..b2ad9c3b556b24a0d2732f597501d2cfddfd0f8c 100644 (file)
@@ -31,7 +31,7 @@ int mch_can_exe(char_u *name, char_u **path, int use_path);
 int mch_nodetype(char_u *name);
 void mch_early_init(void);
 void mch_exit(int r);
-void mch_settmode(int tmode);
+void mch_settmode(tmode_T tmode);
 int mch_get_shellsize(void);
 void mch_set_shellsize(void);
 void mch_new_shellsize(void);
index ade7cc25560d3000c262c3de47c95e5ec57cdb7d..e8a6cb9f15fcd0e2b542b3b080dfa8b813441d05 100644 (file)
@@ -10,7 +10,7 @@ int mch_FullName(char_u *fname, char_u *buf, int len, int force);
 int mch_isFullName(char_u *fname);
 void slash_adjust(char_u *p);
 int vim_stat(const char *name, stat_T *stp);
-void mch_settmode(int tmode);
+void mch_settmode(tmode_T tmode);
 int mch_get_shellsize(void);
 void mch_set_shellsize(void);
 void mch_new_shellsize(void);
index b9db0fc56f63600d56368149a07354a75a68b131..cb84994429bff77a49ddd30440aa0df3843609a0 100644 (file)
@@ -48,7 +48,7 @@ int mch_nodetype(char_u *name);
 void mch_early_init(void);
 void mch_free_mem(void);
 void mch_exit(int r);
-void mch_settmode(int tmode);
+void mch_settmode(tmode_T tmode);
 void get_stty(void);
 int get_tty_info(int fd, ttyinfo_T *info);
 void mch_setmouse(int on);
index c1cfd4442af6a0b9ef6e995d525e4406e92c57e4..b58118d88ea2db52a652b4948abf93b308135560 100644 (file)
@@ -1,5 +1,5 @@
 /* os_vms.c */
-void mch_settmode(int tmode);
+void mch_settmode(tmode_T tmode);
 int mch_get_shellsize(void);
 void mch_set_shellsize(void);
 char_u *mch_getenv(char_u *lognam);
index 15c13231578d1ec558e5142fae52c35d3e34cae2..d8f9ac36b219227149d8e0fef497de605c47e793 100644 (file)
@@ -39,7 +39,7 @@ int mch_nodetype(char_u *name);
 vim_acl_T mch_get_acl(char_u *fname);
 void mch_set_acl(char_u *fname, vim_acl_T acl);
 void mch_free_acl(vim_acl_T acl);
-void mch_settmode(int tmode);
+void mch_settmode(tmode_T tmode);
 int mch_get_shellsize(void);
 void mch_set_shellsize(void);
 void mch_new_shellsize(void);
index 1260c9a37da9aad62d2206e26f793ac9438701c0..a575227072519dab440ec54424d75987340e44ab 100644 (file)
@@ -3471,7 +3471,12 @@ settmode(int tmode)
 #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)
                {
index b9535ee1de2610087751cb243e8ac9c5f6fffced..dca48d1ad53606103c92d98b33477f4a8f75a9b9 100644 (file)
@@ -209,7 +209,9 @@ extern char_u *(term_strings[]);    // current terminal strings
 #define T_SSI  (TERM_STR(KS_SSI))      // save icon text
 #define T_SRI  (TERM_STR(KS_SRI))      // restore icon text
 
-#define TMODE_COOK     0   // terminal mode for external cmds and Ex mode
-#define TMODE_SLEEP    1   // terminal mode for sleeping (cooked but no echo)
-#define TMODE_RAW      2   // terminal mode for Normal and Insert mode
-#define TMODE_UNKNOWN   9   // after executing a shell
+typedef enum {
+    TMODE_COOK,            // terminal mode for external cmds and Ex mode
+    TMODE_SLEEP,    // terminal mode for sleeping (cooked but no echo)
+    TMODE_RAW,     // terminal mode for Normal and Insert mode
+    TMODE_UNKNOWN   // after executing a shell
+} tmode_T;
index 6a28ae35f89a4ea40e359f883914e18b0619c8fd..951137912b9d7017ab9acd00f4d4fdd2c957db50 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    774,
 /**/
     773,
 /**/