" By default uses a size of 20 lines and 75 columns.
" Returns the buffer number of the terminal.
"
-" Options is a dictionary (not used yet).
+" Options is a dictionary, these items are recognized:
+" "rows" - height of the terminal window (max. 20)
+" "cols" - width of the terminal window (max. 78)
func RunVimInTerminal(arguments, options)
" If Vim doesn't exit a swap file remains, causing other tests to fail.
" Remove it here.
set t_Co=256 background=light
hi Normal ctermfg=NONE ctermbg=NONE
- " Make the window 20 lines high, unless told otherwise.
- let rows = 20
- if has_key(a:options, 'rows')
- let rows = a:options['rows']
- endif
+ " Make the window 20 lines high and 75 columns, unless told otherwise.
+ let rows = get(a:options, 'rows', 20)
+ let cols = get(a:options, 'cols', 75)
let cmd = GetVimCommandClean()
" Add -v to have gvim run in the terminal (if possible)
let cmd .= ' -v ' . a:arguments
- let buf = term_start(cmd, {'curwin': 1, 'term_rows': rows, 'term_cols': 75})
- call assert_equal([rows, 75], term_getsize(buf))
+ let buf = term_start(cmd, {'curwin': 1, 'term_rows': rows, 'term_cols': cols})
+ call assert_equal([rows, cols], term_getsize(buf))
return buf
endfunc
return
endif
call assert_equal(1, winnr('$'))
- set title
" Use the title termcap entries to output the escape sequence.
call writefile([
+ \ 'set title',
\ 'exe "set t_ts=\<Esc>]51; t_fs=\x07"',
\ 'let &titlestring = ''["drop","Xtextfile"]''',
\ 'redraw',
call StopVimInTerminal(buf)
call delete('Xscript')
bwipe Xtextfile
- set title&
endfunc
func Test_terminal_api_drop_oldwin()
let textfile_winid = win_getid()
call assert_equal(2, winnr('$'))
call win_gotoid(firstwinid)
- set title
" Use the title termcap entries to output the escape sequence.
call writefile([
+ \ 'set title',
\ 'exe "set t_ts=\<Esc>]51; t_fs=\x07"',
\ 'let &titlestring = ''["drop","Xtextfile"]''',
\ 'redraw',
call StopVimInTerminal(buf)
call delete('Xscript')
bwipe Xtextfile
- set title&
endfunc
func TryThis(bufnum, arg)
if !CanRunVimInTerminal()
return
endif
- set title
" Use the title termcap entries to output the escape sequence.
call writefile([
+ \ 'set title',
\ 'exe "set t_ts=\<Esc>]51; t_fs=\x07"',
\ 'let &titlestring = ''["call","TryThis",["hello",123]]''',
\ 'redraw',
call delete('Xscript')
unlet g:called_bufnum
unlet g:called_arg
- set title&
endfunc