To: vim_dev@googlegroups.com Subject: Patch 8.2.0774 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0774 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. Files: src/os_unix.c, src/proto/os_unix.pro, src/os_amiga.c, src/proto/os_amiga.pro, src/os_mswin.c, src/proto/os_mswin.pro, src/os_vms.c, src/proto/os_vms.pro, src/os_win32.c, src/proto/os_win32.pro, src/term.c, src/term.h, src/globals.h *** ../vim-8.2.0773/src/os_unix.c 2020-05-16 23:15:03.326276750 +0200 --- src/os_unix.c 2020-05-17 13:47:37.156583009 +0200 *************** *** 215,221 **** static int dont_check_job_ended = 0; #endif ! static int curr_tmode = TMODE_COOK; // contains current terminal mode #ifdef USE_XSMP typedef struct --- 215,222 ---- static int dont_check_job_ended = 0; #endif ! // 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,587 **** void mch_delay(long msec, int ignoreinput) { ! int old_tmode; #ifdef FEAT_MZSCHEME long total = msec; // remember original value #endif --- 582,588 ---- void mch_delay(long msec, int ignoreinput) { ! tmode_T old_tmode; #ifdef FEAT_MZSCHEME long total = msec; // remember original value #endif *************** *** 591,599 **** // 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). in_mch_delay = TRUE; ! old_tmode = curr_tmode; ! if (curr_tmode == TMODE_RAW) settmode(TMODE_SLEEP); /* --- 592,601 ---- // 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 = mch_cur_tmode; ! if (mch_cur_tmode == TMODE_RAW && msec > 500) settmode(TMODE_SLEEP); /* *************** *** 650,656 **** while (total > 0); #endif ! settmode(old_tmode); in_mch_delay = FALSE; } else --- 652,659 ---- while (total > 0); #endif ! if (msec > 500) ! settmode(old_tmode); in_mch_delay = FALSE; } else *************** *** 3461,3467 **** } void ! mch_settmode(int tmode) { static int first = TRUE; --- 3464,3470 ---- } void ! mch_settmode(tmode_T tmode) { static int first = TRUE; *************** *** 3558,3564 **** ttybnew.sg_flags &= ~(ECHO); ioctl(read_cmd_fd, TIOCSETN, &ttybnew); #endif ! curr_tmode = tmode; } /* --- 3564,3570 ---- ttybnew.sg_flags &= ~(ECHO); ioctl(read_cmd_fd, TIOCSETN, &ttybnew); #endif ! mch_cur_tmode = tmode; } /* *************** *** 4455,4461 **** char *ifn = NULL; char *ofn = NULL; #endif ! int tmode = cur_tmode; char_u *newcmd; // only needed for unix int x; --- 4461,4467 ---- char *ifn = NULL; char *ofn = NULL; #endif ! tmode_T tmode = cur_tmode; char_u *newcmd; // only needed for unix int x; *************** *** 4549,4555 **** char_u *cmd, int options) // SHELL_*, see vim.h { ! int tmode = cur_tmode; pid_t pid; pid_t wpid = 0; pid_t wait_pid = 0; --- 4555,4561 ---- char_u *cmd, int options) // SHELL_*, see vim.h { ! tmode_T tmode = cur_tmode; pid_t pid; pid_t wpid = 0; pid_t wait_pid = 0; *************** *** 5939,5945 **** void mch_breakcheck(int force) { ! if ((curr_tmode == TMODE_RAW || force) && RealWaitForChar(read_cmd_fd, 0L, NULL, NULL)) fill_input_buf(FALSE); } --- 5945,5951 ---- void mch_breakcheck(int force) { ! if ((mch_cur_tmode == TMODE_RAW || force) && RealWaitForChar(read_cmd_fd, 0L, NULL, NULL)) fill_input_buf(FALSE); } *** ../vim-8.2.0773/src/proto/os_unix.pro 2020-01-17 19:32:14.747571995 +0100 --- src/proto/os_unix.pro 2020-05-17 13:49:00.148344186 +0200 *************** *** 48,54 **** void mch_early_init(void); void mch_free_mem(void); void mch_exit(int r); ! void mch_settmode(int tmode); void get_stty(void); int get_tty_info(int fd, ttyinfo_T *info); void mch_setmouse(int on); --- 48,54 ---- void mch_early_init(void); void mch_free_mem(void); void mch_exit(int r); ! void mch_settmode(tmode_T tmode); void get_stty(void); int get_tty_info(int fd, ttyinfo_T *info); void mch_setmouse(int on); *** ../vim-8.2.0773/src/os_amiga.c 2020-05-16 23:15:03.330276741 +0200 --- src/os_amiga.c 2020-05-17 13:49:32.568249911 +0200 *************** *** 977,983 **** * it sends a 0 to the console to make it back into a CON: from a RAW: */ void ! mch_settmode(int tmode) { #if defined(__AROS__) || defined(__amigaos4__) if (!SetMode(raw_in, tmode == TMODE_RAW ? 1 : 0)) --- 977,983 ---- * it sends a 0 to the console to make it back into a CON: from a RAW: */ void ! mch_settmode(tmode_T tmode) { #if defined(__AROS__) || defined(__amigaos4__) if (!SetMode(raw_in, tmode == TMODE_RAW ? 1 : 0)) *** ../vim-8.2.0773/src/proto/os_amiga.pro 2020-01-17 19:32:14.743572013 +0100 --- src/proto/os_amiga.pro 2020-05-17 13:49:51.676194095 +0200 *************** *** 31,37 **** int mch_nodetype(char_u *name); void mch_early_init(void); void mch_exit(int r); ! void mch_settmode(int tmode); int mch_get_shellsize(void); void mch_set_shellsize(void); void mch_new_shellsize(void); --- 31,37 ---- int mch_nodetype(char_u *name); void mch_early_init(void); void mch_exit(int r); ! void mch_settmode(tmode_T tmode); int mch_get_shellsize(void); void mch_set_shellsize(void); void mch_new_shellsize(void); *** ../vim-8.2.0773/src/os_mswin.c 2020-04-12 19:37:13.518297259 +0200 --- src/os_mswin.c 2020-05-17 13:52:15.271769419 +0200 *************** *** 553,559 **** #if (defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)) || defined(PROTO) void ! mch_settmode(int tmode UNUSED) { // nothing to do } --- 553,559 ---- #if (defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)) || defined(PROTO) void ! mch_settmode(tmode_T tmode UNUSED) { // nothing to do } *** ../vim-8.2.0773/src/proto/os_mswin.pro 2020-01-17 19:32:14.743572013 +0100 --- src/proto/os_mswin.pro 2020-05-17 13:52:48.255670683 +0200 *************** *** 10,16 **** 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); int mch_get_shellsize(void); void mch_set_shellsize(void); void mch_new_shellsize(void); --- 10,16 ---- int mch_isFullName(char_u *fname); void slash_adjust(char_u *p); int vim_stat(const char *name, stat_T *stp); ! void mch_settmode(tmode_T tmode); int mch_get_shellsize(void); void mch_set_shellsize(void); void mch_new_shellsize(void); *** ../vim-8.2.0773/src/os_vms.c 2019-12-05 20:25:16.000000000 +0100 --- src/os_vms.c 2020-05-17 13:53:17.971581384 +0200 *************** *** 112,118 **** } void ! mch_settmode(int tmode) { int status; --- 112,118 ---- } void ! mch_settmode(tmode_T tmode) { int status; *** ../vim-8.2.0773/src/proto/os_vms.pro 2019-12-12 12:55:42.000000000 +0100 --- src/proto/os_vms.pro 2020-05-17 13:53:42.255508172 +0200 *************** *** 1,5 **** /* os_vms.c */ ! void mch_settmode(int tmode); int mch_get_shellsize(void); void mch_set_shellsize(void); char_u *mch_getenv(char_u *lognam); --- 1,5 ---- /* os_vms.c */ ! void mch_settmode(tmode_T tmode); int mch_get_shellsize(void); void mch_set_shellsize(void); char_u *mch_getenv(char_u *lognam); *** ../vim-8.2.0773/src/os_win32.c 2020-05-16 23:15:03.330276741 +0200 --- src/os_win32.c 2020-05-17 13:56:05.223073768 +0200 *************** *** 3600,3606 **** * set the tty in (raw) ? "raw" : "cooked" mode */ void ! mch_settmode(int tmode) { DWORD cmodein; DWORD cmodeout; --- 3600,3606 ---- * set the tty in (raw) ? "raw" : "cooked" mode */ void ! mch_settmode(tmode_T tmode) { DWORD cmodein; DWORD cmodeout; *** ../vim-8.2.0773/src/proto/os_win32.pro 2020-04-28 20:44:38.872258441 +0200 --- src/proto/os_win32.pro 2020-05-17 13:56:35.794980197 +0200 *************** *** 39,45 **** 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); int mch_get_shellsize(void); void mch_set_shellsize(void); void mch_new_shellsize(void); --- 39,45 ---- 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(tmode_T tmode); int mch_get_shellsize(void); void mch_set_shellsize(void); void mch_new_shellsize(void); *** ../vim-8.2.0773/src/term.c 2020-05-16 23:15:03.326276750 +0200 --- src/term.c 2020-05-17 13:31:57.150961821 +0200 *************** *** 3471,3477 **** #endif if (tmode != TMODE_RAW) mch_setmouse(FALSE); // switch mouse off ! if (termcap_active) { if (tmode != TMODE_RAW) { --- 3471,3482 ---- #endif if (tmode != TMODE_RAW) mch_setmouse(FALSE); // switch mouse off ! ! // 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) { *** ../vim-8.2.0773/src/term.h 2020-05-16 23:15:03.326276750 +0200 --- src/term.h 2020-05-17 13:40:38.249701846 +0200 *************** *** 209,215 **** #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 --- 209,217 ---- #define T_SSI (TERM_STR(KS_SSI)) // save icon text #define T_SRI (TERM_STR(KS_SRI)) // restore icon text ! 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; *** ../vim-8.2.0773/src/globals.h 2020-05-10 19:10:27.968996544 +0200 --- src/globals.h 2020-05-17 13:40:58.937651194 +0200 *************** *** 1171,1177 **** 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 int bangredo INIT(= FALSE); // set to TRUE with ! command EXTERN int searchcmdlen; // length of previous search cmd #ifdef FEAT_SYN_HL --- 1171,1177 ---- EXTERN int term_console INIT(= FALSE); // set to TRUE when console used #endif EXTERN int termcap_active INIT(= FALSE); // set by starttermcap() ! 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 *** ../vim-8.2.0773/src/version.c 2020-05-16 23:15:03.330276741 +0200 --- src/version.c 2020-05-17 14:04:52.173437623 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 774, /**/ -- hundred-and-one symptoms of being an internet addict: 113. You are asked about a bus schedule, you wonder if it is 16 or 32 bits. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///