1
0
forked from aniani/vim

updated for version 7.4.389

Problem:    Still sometimes Vim enters Replace mode when starting up.
Solution:   Use a different solution in detecting the termresponse and
            location response. (Hayaki Saito)
This commit is contained in:
Bram Moolenaar 2014-07-30 17:21:58 +02:00
parent b81c85d8f3
commit 4e067c898e
5 changed files with 66 additions and 113 deletions

View File

@ -1336,9 +1336,6 @@ EXTERN HWND clientWindow INIT(= 0);
#if defined(UNIX) || defined(VMS) #if defined(UNIX) || defined(VMS)
EXTERN int term_is_xterm INIT(= FALSE); /* xterm-like 'term' */ EXTERN int term_is_xterm INIT(= FALSE); /* xterm-like 'term' */
#endif #endif
#if defined(UNIX)
EXTERN int xterm_conflict_mouse INIT(= FALSE);
#endif
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
EXTERN char psepc INIT(= '\\'); /* normal path separator character */ EXTERN char psepc INIT(= '\\'); /* normal path separator character */

View File

@ -3667,8 +3667,6 @@ mch_setmouse(on)
void void
check_mouse_termcode() check_mouse_termcode()
{ {
xterm_conflict_mouse = FALSE;
# ifdef FEAT_MOUSE_XTERM # ifdef FEAT_MOUSE_XTERM
if (use_xterm_mouse() if (use_xterm_mouse()
# ifdef FEAT_MOUSE_URXVT # ifdef FEAT_MOUSE_URXVT
@ -3713,7 +3711,7 @@ check_mouse_termcode()
# endif # endif
# ifdef FEAT_MOUSE_JSB # ifdef FEAT_MOUSE_JSB
/* There is no conflict, but it was disabled for xterm before. */ /* Conflicts with xterm mouse: "\033[" and "\033[M" ??? */
if (!use_xterm_mouse() if (!use_xterm_mouse()
# ifdef FEAT_GUI # ifdef FEAT_GUI
&& !gui.in_use && !gui.in_use
@ -3740,45 +3738,31 @@ check_mouse_termcode()
# endif # endif
# ifdef FEAT_MOUSE_DEC # ifdef FEAT_MOUSE_DEC
/* Conflicts with xterm mouse: "\033[" and "\033[M". /* Conflicts with xterm mouse: "\033[" and "\033[M" */
* Also conflicts with the xterm termresponse, skip this if it was
* requested already. */
if (!use_xterm_mouse() if (!use_xterm_mouse()
# ifdef FEAT_TERMRESPONSE
&& !did_request_esc_sequence()
# endif
# ifdef FEAT_GUI # ifdef FEAT_GUI
&& !gui.in_use && !gui.in_use
# endif # endif
) )
{
set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME) set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "["))); ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
xterm_conflict_mouse = TRUE;
}
else else
del_mouse_termcode(KS_DEC_MOUSE); del_mouse_termcode(KS_DEC_MOUSE);
# endif # endif
# ifdef FEAT_MOUSE_PTERM # ifdef FEAT_MOUSE_PTERM
/* same as the dec mouse */ /* same conflict as the dec mouse */
if (!use_xterm_mouse() if (!use_xterm_mouse()
# ifdef FEAT_TERMRESPONSE
&& !did_request_esc_sequence()
# endif
# ifdef FEAT_GUI # ifdef FEAT_GUI
&& !gui.in_use && !gui.in_use
# endif # endif
) )
{
set_mouse_termcode(KS_PTERM_MOUSE, set_mouse_termcode(KS_PTERM_MOUSE,
(char_u *) IF_EB("\033[", ESC_STR "[")); (char_u *) IF_EB("\033[", ESC_STR "["));
xterm_conflict_mouse = TRUE;
}
else else
del_mouse_termcode(KS_PTERM_MOUSE); del_mouse_termcode(KS_PTERM_MOUSE);
# endif # endif
# ifdef FEAT_MOUSE_URXVT # ifdef FEAT_MOUSE_URXVT
/* same as the dec mouse */ /* same conflict as the dec mouse */
if (use_xterm_mouse() == 3 if (use_xterm_mouse() == 3
# ifdef FEAT_GUI # ifdef FEAT_GUI
&& !gui.in_use && !gui.in_use
@ -3794,8 +3778,6 @@ check_mouse_termcode()
mch_setmouse(FALSE); mch_setmouse(FALSE);
setmouse(); setmouse();
} }
/* It's OK to request the xterm version for uxterm. */
resume_get_esc_sequence();
} }
else else
del_mouse_termcode(KS_URXVT_MOUSE); del_mouse_termcode(KS_URXVT_MOUSE);

View File

@ -34,8 +34,6 @@ void set_shellsize __ARGS((int width, int height, int mustset));
void settmode __ARGS((int tmode)); void settmode __ARGS((int tmode));
void starttermcap __ARGS((void)); void starttermcap __ARGS((void));
void stoptermcap __ARGS((void)); void stoptermcap __ARGS((void));
int did_request_esc_sequence __ARGS((void));
void resume_get_esc_sequence __ARGS((void));
void may_req_termresponse __ARGS((void)); void may_req_termresponse __ARGS((void));
void may_req_ambiguous_char_width __ARGS((void)); void may_req_ambiguous_char_width __ARGS((void));
int swapping_screen __ARGS((void)); int swapping_screen __ARGS((void));

View File

@ -153,11 +153,6 @@ char *UP, *BC, PC;
static char_u *vim_tgetstr __ARGS((char *s, char_u **pp)); static char_u *vim_tgetstr __ARGS((char *s, char_u **pp));
#endif /* HAVE_TGETENT */ #endif /* HAVE_TGETENT */
#if defined(FEAT_TERMRESPONSE)
static int xt_index_in = 0;
static int xt_index_out = 0;
#endif
static int detected_8bit = FALSE; /* detected 8-bit terminal */ static int detected_8bit = FALSE; /* detected 8-bit terminal */
static struct builtin_term builtin_termcaps[] = static struct builtin_term builtin_termcaps[] =
@ -3312,40 +3307,6 @@ stoptermcap()
} }
#if defined(FEAT_TERMRESPONSE) || defined(PROTO) #if defined(FEAT_TERMRESPONSE) || defined(PROTO)
# if defined(UNIX) || defined(PROTO)
/*
* Return TRUE when the xterm version was requested or anything else that
* would send an ESC sequence back to Vim.
* If not sent yet, prevent it from being sent soon.
* Used to check whether it is OK to enable checking for DEC mouse codes,
* which conflict with may xterm ESC sequences.
*/
int
did_request_esc_sequence()
{
if (crv_status == CRV_GET)
crv_status = 0;
if (u7_status == U7_GET)
u7_status = 0;
return crv_status == CRV_SENT || u7_status == U7_SENT
|| xt_index_out > xt_index_in;
}
/*
* If requesting the version was disabled in did_request_esc_sequence(),
* enable it again.
*/
void
resume_get_esc_sequence()
{
if (crv_status == 0)
crv_status = CRV_GET;
if (u7_status == 0)
u7_status = U7_GET;
}
# endif
/* /*
* Request version string (for xterm) when needed. * Request version string (for xterm) when needed.
* Only do this after switching to raw mode, otherwise the result will be * Only do this after switching to raw mode, otherwise the result will be
@ -3358,8 +3319,6 @@ resume_get_esc_sequence()
* Insert mode. * Insert mode.
* On Unix only do it when both output and input are a tty (avoid writing * On Unix only do it when both output and input are a tty (avoid writing
* request to terminal while reading from a file). * request to terminal while reading from a file).
* Do not do this when a mouse is being detected that starts with the same ESC
* sequence as the termresponse.
* The result is caught in check_termcode(). * The result is caught in check_termcode().
*/ */
void void
@ -3373,7 +3332,6 @@ may_req_termresponse()
# ifdef UNIX # ifdef UNIX
&& isatty(1) && isatty(1)
&& isatty(read_cmd_fd) && isatty(read_cmd_fd)
&& !xterm_conflict_mouse
# endif # endif
&& *T_CRV != NUL) && *T_CRV != NUL)
{ {
@ -3742,8 +3700,8 @@ add_termcode(name, string, flags)
#if defined(WIN3264) && !defined(FEAT_GUI) #if defined(WIN3264) && !defined(FEAT_GUI)
if (s[0] == K_NUL) if (s[0] == K_NUL)
{ {
STRMOVE(s + 1, s); STRMOVE(s + 1, s);
s[1] = 3; s[1] = 3;
} }
#endif #endif
@ -4212,24 +4170,31 @@ check_termcode(max_offset, buf, bufsize, buflen)
#ifdef FEAT_TERMRESPONSE #ifdef FEAT_TERMRESPONSE
if (key_name[0] == NUL if (key_name[0] == NUL
/* URXVT mouse uses <ESC>[#;#;#M, but we are matching <ESC>[ */ /* Mouse codes of DEC, pterm, and URXVT start with <ESC>[. When
|| key_name[0] == KS_URXVT_MOUSE * detecting the start of these mouse codes they might as well be
# ifdef FEAT_MBYTE * another key code or terminal response. */
|| u7_status == U7_SENT # ifdef FEAT_MOUSE_DEC
|| key_name[0] == KS_DEC_MOUSE
# endif # endif
) # ifdef FEAT_MOUSE_PTERM
|| key_name[0] == KS_PTERM_MOUSE
# endif
# ifdef FEAT_MOUSE_URXVT
|| key_name[0] == KS_URXVT_MOUSE
# endif
)
{ {
/* Check for some responses from terminal start with "<Esc>[" or /* Check for some responses from the terminal starting with
* CSI. * "<Esc>[" or CSI:
* *
* - xterm version string: <Esc>[>{x};{vers};{y}c * - Xterm version string: <Esc>[>{x};{vers};{y}c
* Also eat other possible responses to t_RV, rxvt returns * Also eat other possible responses to t_RV, rxvt returns
* "<Esc>[?1;2c". Also accept CSI instead of <Esc>[. * "<Esc>[?1;2c". Also accept CSI instead of <Esc>[.
* mrxvt has been reported to have "+" in the version. Assume * mrxvt has been reported to have "+" in the version. Assume
* the escape sequence ends with a letter or one of "{|}~". * the escape sequence ends with a letter or one of "{|}~".
* *
* - cursor position report: <Esc>[{row};{col}R * - Cursor position report: <Esc>[{row};{col}R
* The final byte is 'R'. now it is only used for checking for * The final byte must be 'R'. It is used for checking the
* ambiguous-width character state. * ambiguous-width character state.
*/ */
p = tp[0] == CSI ? tp + 1 : tp + 2; p = tp[0] == CSI ? tp + 1 : tp + 2;
@ -4269,36 +4234,42 @@ check_termcode(max_offset, buf, bufsize, buflen)
* u7_status is not "sent", it may be from a previous Vim that * u7_status is not "sent", it may be from a previous Vim that
* just exited. But not for <S-F3>, it sends something * just exited. But not for <S-F3>, it sends something
* similar, check for row and column to make sense. */ * similar, check for row and column to make sense. */
if (j == 1 && tp[i] == 'R' && row_char == '2' && col >= 2) if (j == 1 && tp[i] == 'R')
{ {
char *aw = NULL; if (row_char == '2' && col >= 2)
LOG_TR("Received U7 status");
u7_status = U7_GOT;
# ifdef FEAT_AUTOCMD
did_cursorhold = TRUE;
# endif
if (col == 2)
aw = "single";
else if (col == 3)
aw = "double";
if (aw != NULL && STRCMP(aw, p_ambw) != 0)
{ {
/* Setting the option causes a screen redraw. Do that char *aw = NULL;
* right away if possible, keeping any messages. */
set_option_value((char_u *)"ambw", 0L, (char_u *)aw, 0);
# ifdef DEBUG_TERMRESPONSE
{
char buf[100];
int r = redraw_asap(CLEAR);
sprintf(buf, "set 'ambiwidth', redraw_asap(): %d", LOG_TR("Received U7 status");
r); u7_status = U7_GOT;
log_tr(buf); # ifdef FEAT_AUTOCMD
} did_cursorhold = TRUE;
# else
redraw_asap(CLEAR);
# endif # endif
if (col == 2)
aw = "single";
else if (col == 3)
aw = "double";
if (aw != NULL && STRCMP(aw, p_ambw) != 0)
{
/* Setting the option causes a screen redraw. Do
* that right away if possible, keeping any
* messages. */
set_option_value((char_u *)"ambw", 0L,
(char_u *)aw, 0);
# ifdef DEBUG_TERMRESPONSE
{
char buf[100];
int r = redraw_asap(CLEAR);
sprintf(buf,
"set 'ambiwidth', redraw_asap(): %d",
r);
log_tr(buf);
}
# else
redraw_asap(CLEAR);
# endif
}
} }
key_name[0] = (int)KS_EXTRA; key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE; key_name[1] = (int)KE_IGNORE;
@ -4563,19 +4534,19 @@ check_termcode(max_offset, buf, bufsize, buflen)
return -1; return -1;
/* when mouse reporting is SGR, add 32 to mouse code */ /* when mouse reporting is SGR, add 32 to mouse code */
if (key_name[0] == KS_SGR_MOUSE) if (key_name[0] == KS_SGR_MOUSE)
mouse_code += 32; mouse_code += 32;
mouse_col = getdigits(&p) - 1; mouse_col = getdigits(&p) - 1;
if (*p++ != ';') if (*p++ != ';')
return -1; return -1;
mouse_row = getdigits(&p) - 1; mouse_row = getdigits(&p) - 1;
if (key_name[0] == KS_SGR_MOUSE && *p == 'm') if (key_name[0] == KS_SGR_MOUSE && *p == 'm')
mouse_code |= MOUSE_RELEASE; mouse_code |= MOUSE_RELEASE;
else if (*p != 'M') else if (*p != 'M')
return -1; return -1;
p++; p++;
slen += (int)(p - (tp + slen)); slen += (int)(p - (tp + slen));
@ -4592,7 +4563,7 @@ check_termcode(max_offset, buf, bufsize, buflen)
for (slen2 = slen; slen2 < len; slen2++) for (slen2 = slen; slen2 < len; slen2++)
{ {
if (tp[slen2] == 'M' if (tp[slen2] == 'M'
|| (key_name[0] == KS_SGR_MOUSE || (key_name[0] == KS_SGR_MOUSE
&& tp[slen2] == 'm')) && tp[slen2] == 'm'))
{ {
cmd_complete = 1; cmd_complete = 1;
@ -5769,6 +5740,9 @@ show_one_termcode(name, code, printit)
* termcap codes from the terminal itself. * termcap codes from the terminal itself.
* We get them one by one to avoid a very long response string. * We get them one by one to avoid a very long response string.
*/ */
static int xt_index_in = 0;
static int xt_index_out = 0;
static void static void
req_codes_from_term() req_codes_from_term()
{ {

View File

@ -734,6 +734,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 */
/**/
389,
/**/ /**/
388, 388,
/**/ /**/