Compare commits

..

3 Commits

Author SHA1 Message Date
Bram Moolenaar
dde6034111 patch 8.0.1017: test for MS-Windows $HOME always passes
Problem:    Test for MS-Windows $HOME always passes.
Solution:   Rename the test function.  Make the test pass.
2017-08-30 14:55:42 +02:00
Bram Moolenaar
f3af54eeb1 patch 8.0.1016: gnome terminal echoes t_RC
Problem:    Gnome terminal echoes t_RC.
Solution:   Detect Gnome terminal by the version string.  Add v: variables for
            all the term responses.
2017-08-30 14:53:06 +02:00
Bram Moolenaar
97a80e440a patch 8.0.1015: missing update to terminal test
Problem:    Missing update to terminal test.
Solution:   Add the changes to the test.
2017-08-30 13:31:49 +02:00
7 changed files with 121 additions and 76 deletions

View File

@@ -1902,6 +1902,26 @@ v:termresponse The escape sequence returned by the terminal for the |t_RV|
always 95 or bigger). Pc is always zero.
{only when compiled with |+termresponse| feature}
*v:termblinkresp*
v:termblinkresp The escape sequence returned by the terminal for the |t_RC|
termcap entry. This is used to find out whether the terminal
cursor is blinking. This is used by |term_getcursor()|.
*v:termstyleresp*
v:termstyleresp The escape sequence returned by the terminal for the |t_RS|
termcap entry. This is used to find out what the shape of the
cursor is. This is used by |term_getcursor()|.
*v:termrgbresp*
v:termrgbresp The escape sequence returned by the terminal for the |t_RB|
termcap entry. This is used to find out what the terminal
background color is, see 'background'.
*v:termu7resp*
v:termu7resp The escape sequence returned by the terminal for the |t_u7|
termcap entry. This is used to find out what the terminal
does with ambiguous width characters, see 'ambiwidth'.
*v:testing* *testing-variable*
v:testing Must be set before using `test_garbagecollect_now()`.
Also, when set certain error messages won't be shown for 2

View File

@@ -187,6 +187,10 @@ static struct vimvar
{VV_NAME("t_none", VAR_NUMBER), VV_RO},
{VV_NAME("t_job", VAR_NUMBER), VV_RO},
{VV_NAME("t_channel", VAR_NUMBER), VV_RO},
{VV_NAME("termrgbresp", VAR_STRING), VV_RO},
{VV_NAME("termu7resp", VAR_STRING), VV_RO},
{VV_NAME("termstyleresp", VAR_STRING), VV_RO},
{VV_NAME("termblinkresp", VAR_STRING), VV_RO},
};
/* shorthand */

View File

@@ -1369,9 +1369,7 @@ static int need_gather = FALSE; /* need to fill termleader[] */
static char_u termleader[256 + 1]; /* for check_termcode() */
#ifdef FEAT_TERMRESPONSE
static int check_for_codes = FALSE; /* check for key code response */
# ifdef MACOS
static int is_terminal_app = FALSE; /* recognized Terminal.app */
# endif
static int is_not_xterm = FALSE; /* recognized not-really-xterm */
#endif
static struct builtin_term *
@@ -3506,13 +3504,10 @@ may_req_ambiguous_char_width(void)
/*
* Similar to requesting the version string: Request the terminal background
* color when it is the right moment.
* Also request the cursor shape, if possible.
*/
void
may_req_bg_color(void)
{
int did_one = FALSE;
if (can_get_termresponse() && starting == 0)
{
/* Only request background if t_RB is set and 'background' wasn't
@@ -3524,20 +3519,7 @@ may_req_bg_color(void)
LOG_TR("Sending BG request");
out_str(T_RBG);
rbg_status = STATUS_SENT;
did_one = TRUE;
}
/* Only request cursor blinking mode if t_RC is set. */
if (rbm_status == STATUS_GET && *T_CRC != NUL)
{
LOG_TR("Sending BC request");
out_str(T_CRC);
rbm_status = STATUS_SENT;
did_one = TRUE;
}
if (did_one)
{
/* check for the characters now, otherwise they might be eaten by
* get_keystroke() */
out_flush();
@@ -4505,6 +4487,9 @@ check_termcode(
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
slen = i + 1;
# ifdef FEAT_EVAL
set_vim_var_string(VV_TERMU7RESP, tp, slen);
# endif
}
else
#endif
@@ -4530,6 +4515,8 @@ check_termcode(
if (tp[1 + (tp[0] != CSI)] == '>' && semicols == 2)
{
int need_flush = FALSE;
/* Only set 'ttymouse' automatically if it was not set
* by the user already. */
if (!option_was_set((char_u *)"ttym"))
@@ -4566,35 +4553,53 @@ check_termcode(
may_adjust_color_count(256);
}
/* Detect terminals that set $TERM to something like
* "xterm-256colors" but are not fully xterm
* compatible. */
# ifdef MACOS
/* Mac Terminal.app sends 1;95;0 */
if (col == 95
&& STRNCMP(tp + extra - 2, "1;95;0c", 7) == 0)
{
/* Terminal.app sets $TERM to "xterm-256colors",
* but it's not fully xterm compatible. */
is_terminal_app = TRUE;
}
is_not_xterm = TRUE;
# endif
/* Gnome Terminal.app sends 1;4402;0, assuming any
* version number over 4000 is not an xterm. */
if (col >= 4000)
is_not_xterm = TRUE;
/* Only request the cursor style if t_SH and t_RS are
* set. Not for Terminal.app, it can't handle t_RS, it
* echoes the characters to the screen. */
if (rcs_status == STATUS_GET
# ifdef MACOS
&& !is_terminal_app
# endif
&& !is_not_xterm
&& *T_CSH != NUL
&& *T_CRS != NUL)
{
LOG_TR("Sending cursor style request");
out_str(T_CRS);
rcs_status = STATUS_SENT;
out_flush();
need_flush = TRUE;
}
/* Only request the cursor blink mode if t_RC set. Not
* for Gnome terminal, it can't handle t_RC, it
* echoes the characters to the screen. */
if (rbm_status == STATUS_GET
&& !is_not_xterm
&& *T_CRC != NUL)
{
LOG_TR("Sending cursor blink mode request");
out_str(T_CRC);
rbm_status = STATUS_SENT;
need_flush = TRUE;
}
if (need_flush)
out_flush();
}
slen = i + 1;
# ifdef FEAT_EVAL
set_vim_var_string(VV_TERMRESPONSE, tp, i + 1);
set_vim_var_string(VV_TERMRESPONSE, tp, slen);
# endif
# ifdef FEAT_AUTOCMD
apply_autocmds(EVENT_TERMRESPONSE,
@@ -4602,7 +4607,6 @@ check_termcode(
# endif
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
slen = i + 1;
}
/* Check blinking cursor from xterm:
@@ -4626,6 +4630,9 @@ check_termcode(
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
slen = i + 1;
# ifdef FEAT_EVAL
set_vim_var_string(VV_TERMBLINKRESP, tp, slen);
# endif
}
/*
@@ -4714,6 +4721,9 @@ check_termcode(
/* Sometimes the 0x07 is followed by 0x18, unclear
* when this happens. */
++slen;
# ifdef FEAT_EVAL
set_vim_var_string(VV_TERMRGBRESP, tp, slen);
# endif
break;
}
if (i == len)
@@ -4788,6 +4798,9 @@ check_termcode(
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
slen = i + 1 + (tp[i] == ESC);
# ifdef FEAT_EVAL
set_vim_var_string(VV_TERMSTYLERESP, tp, slen);
# endif
}
}

View File

@@ -84,6 +84,7 @@ endfunc
func Test_terminal_hide_buffer()
let buf = Run_shell_in_terminal({})
setlocal bufhidden=hide
quit
for nr in range(1, winnr('$'))
call assert_notequal(winbufnr(nr), buf)
@@ -356,13 +357,13 @@ func Test_finish_open_close()
call assert_equal(1, winnr('$'))
exe 'terminal ++open ' . cmd
close
close!
call WaitFor("winnr('$') == 2", waittime)
call assert_equal(2, winnr('$'))
bwipe
call term_start(cmd, {'term_finish': 'open'})
close
close!
call WaitFor("winnr('$') == 2", waittime)
call assert_equal(2, winnr('$'))
bwipe
@@ -385,7 +386,7 @@ func Test_finish_open_close()
call assert_fails("call term_start(cmd, {'term_opencmd': 'split % and %d'})", 'E475:')
call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d'})
close
close!
call WaitFor("winnr('$') == 2", waittime)
call assert_equal(2, winnr('$'))
call assert_equal(4, winheight(0))

View File

@@ -38,76 +38,73 @@ func CheckHomeIsInSubprocessEnvironment(exp)
endfunc
func CheckHome(exp, ...)
"call assert_equal(a:exp, $HOME)
"call assert_equal(a:exp, expand('~', ':p'))
call assert_equal(a:exp, $HOME)
call assert_equal(a:exp, expand('~', ':p'))
if !a:0
call CheckHomeIsMissingFromSubprocessEnvironment()
else
call CheckHomeIsInSubprocessEnvironment(a:exp)
call CheckHomeIsInSubprocessEnvironment(a:1)
endif
endfunc
func TestWindowsHome()
func Test_WindowsHome()
command! -nargs=* SaveEnv call <SID>save_env(<f-args>)
command! -nargs=* RestoreEnv call <SID>restore_env()
command! -nargs=* UnletEnv call <SID>unlet_env(<f-args>)
set noshellslash
SaveEnv $HOME $USERPROFILE $HOMEDRIVE $HOMEPATH
let save_home = $HOME
SaveEnv $USERPROFILE $HOMEDRIVE $HOMEPATH
try
RestoreEnv
UnletEnv $HOME $USERPROFILE $HOMEPATH
let $HOMEDRIVE = 'C:'
call CheckHome('C:\')
RestoreEnv
UnletEnv $HOME $USERPROFILE
" Normal behavior: use $HOMEDRIVE and $HOMEPATH, ignore $USERPROFILE
let $USERPROFILE = 'unused'
let $HOMEDRIVE = 'C:'
let $HOMEPATH = '\foobar'
let $HOME = '' " Force recomputing "homedir"
call CheckHome('C:\foobar')
RestoreEnv
UnletEnv $HOME $HOMEDRIVE $HOMEPATH
" Same, but with $HOMEPATH not set
UnletEnv $HOMEPATH
let $HOME = '' " Force recomputing "homedir"
call CheckHome('C:\')
" Use $USERPROFILE if $HOMEPATH and $HOMEDRIVE are empty
UnletEnv $HOMEDRIVE $HOMEPATH
let $USERPROFILE = 'C:\foo'
let $HOME = '' " Force recomputing "homedir"
call CheckHome('C:\foo')
RestoreEnv
UnletEnv $HOME
let $USERPROFILE = 'C:\foo'
let $HOMEDRIVE = 'C:'
let $HOMEPATH = '\baz'
call CheckHome('C:\foo')
RestoreEnv
" If $HOME is set the others don't matter
let $HOME = 'C:\bar'
let $USERPROFILE = 'C:\foo'
let $HOMEDRIVE = 'C:'
let $HOMEPATH = '\baz'
call CheckHome('C:\bar', 1)
let $USERPROFILE = 'unused'
let $HOMEDRIVE = 'unused'
let $HOMEPATH = 'unused'
call CheckHome('C:\bar', 'C:\bar')
RestoreEnv
" If $HOME contains %USERPROFILE% it is expanded
let $USERPROFILE = 'C:\foo'
let $HOME = '%USERPROFILE%\bar'
let $USERPROFILE = 'C:\foo'
let $HOMEDRIVE = 'C:'
let $HOMEPATH = '\baz'
call CheckHome('%USERPROFILE%\bar', 1)
let $HOMEDRIVE = 'unused'
let $HOMEPATH = 'unused'
call CheckHome('C:\foo\bar', '%USERPROFILE%\bar')
RestoreEnv
" Invalid $HOME is kept
let $USERPROFILE = 'C:\foo'
let $HOME = '%USERPROFILE'
let $USERPROFILE = 'C:\foo'
let $HOMEDRIVE = 'C:'
let $HOMEPATH = '\baz'
call CheckHome('%USERPROFILE', 1)
let $HOMEDRIVE = 'unused'
let $HOMEPATH = 'unused'
call CheckHome('%USERPROFILE', '%USERPROFILE')
RestoreEnv
" %USERPROFILE% not at start of $HOME is not expanded
let $USERPROFILE = 'unused'
let $HOME = 'C:\%USERPROFILE%'
let $USERPROFILE = 'C:\foo'
let $HOMEDRIVE = 'C:'
let $HOMEPATH = '\baz'
call CheckHome('C:\%USERPROFILE%', 1)
let $HOMEDRIVE = 'unused'
let $HOMEPATH = 'unused'
call CheckHome('C:\%USERPROFILE%', 'C:\%USERPROFILE%')
if has('channel')
RestoreEnv
UnletEnv $HOME
let $HOME = save_home
let env = ''
let job = job_start('cmd /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}})
sleep 1

View File

@@ -769,6 +769,12 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1017,
/**/
1016,
/**/
1015,
/**/
1014,
/**/

View File

@@ -2012,7 +2012,11 @@ typedef int sock_T;
#define VV_TYPE_NONE 78
#define VV_TYPE_JOB 79
#define VV_TYPE_CHANNEL 80
#define VV_LEN 81 /* number of v: vars */
#define VV_TERMRGBRESP 81
#define VV_TERMU7RESP 82
#define VV_TERMSTYLERESP 83
#define VV_TERMBLINKRESP 84
#define VV_LEN 85 /* number of v: vars */
/* used for v_number in VAR_SPECIAL */
#define VVAL_FALSE 0L