call delete('Xtest.dump')
call assert_fails("call term_dumpwrite(buf, '')", 'E482:')
call assert_fails("call term_dumpwrite(buf, test_null_string())", 'E482:')
+ call test_garbagecollect_now()
call StopVimInTerminal(buf)
call term_wait(buf)
call assert_fails("call term_dumpwrite(buf, 'Xtest.dump')", 'E958:')
call assert_match('three four five', getline(3))
call assert_match('Undo', getline(45))
quit
+
+ " Diff two terminal dump files with different number of rows
+ " Swap the diffs
+ call term_dumpdiff('dumps/Test_popup_command_01.dump', 'dumps/Test_winline_rnu.dump')
+ call assert_match('Test_popup_command_01.dump', getline(21))
+ call assert_match('Test_winline_rnu.dump', getline(42))
+ normal s
+ call assert_match('Test_winline_rnu.dump', getline(6))
+ call assert_match('Test_popup_command_01.dump', getline(27))
+ quit
endfunc
func Test_terminal_dumpdiff_options()
call assert_equal(colors, term_getansicolors(buf))
call StopShellInTerminal(buf)
call TermWait(buf)
+ call assert_equal([], term_getansicolors(buf))
exe buf . 'bwipe'
endfunc
let colors[4] = 'Invalid'
call assert_fails('call term_setansicolors(buf, colors)', 'E474:')
+ call assert_fails('call term_setansicolors(buf, {})', 'E714:')
call StopShellInTerminal(buf)
call TermWait(buf)
+ call assert_equal(0, term_setansicolors(buf, []))
exe buf . 'bwipe'
endfunc
call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
call feedkeys("A", 'xt')
call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
- call feedkeys("\<C-W>N", 'xt')
+ call feedkeys("\<C-\>\<C-N>", 'xt')
call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))})
call feedkeys("I", 'xt')
call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))})
call term_sendkeys(buf, ":set culopt=line\r")
call VerifyScreenDump(buf, 'Test_terminal_normal_3', {})
+ call assert_fails('call term_sendkeys(buf, [])', 'E730:')
call term_sendkeys(buf, "a:q!\<CR>:q\<CR>:q\<CR>")
call StopVimInTerminal(buf)
call delete('XtermNormal')
call StopShellInTerminal(buf)
endfunc
+" Test for term_gettitle()
func Test_term_gettitle()
" term_gettitle() returns an empty string for a non-terminal buffer
" and for a non-existing buffer.
call assert_equal('', bufnr('%')->term_gettitle())
call assert_equal('', term_gettitle(bufnr('$') + 1))
- if !has('title') || &title == 0 || empty(&t_ts)
+ if !has('title') || empty(&t_ts)
throw "Skipped: can't get/set title"
endif
- let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'])
+ let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title'])
if has('autoservername')
call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d\+$', term_gettitle(term)) })
call term_sendkeys(term, ":e Xfoo\r")
call assert_equal(output[i], term_getline(buf, 1))
endfor
- "call term_sendkeys(buf, "\<K0>\<K1>\<K2>\<K3>\<K4>\<K5>\<K6>\<K7>\<K8>\<K9>")
- "call term_sendkeys(buf, "\<kEnter>\<kPoint>\<kPlus>")
- "call term_sendkeys(buf, "\<kMinus>\<kMultiply>\<kDivide>")
- "call term_sendkeys(buf, "\<Esc>")
- "call term_sendkeys(buf, "\<Home>\<Ins>\<Tab>\<S-Tab>")
- "call term_sendkeys(buf, "\<Esc>")
-
- "call term_sendkeys(buf, ":write Xkeycodes\<CR>")
-
let keypad_keys = ["\<k0>", "\<k1>", "\<k2>", "\<k3>", "\<k4>", "\<k5>",
\ "\<k6>", "\<k7>", "\<k8>", "\<k9>", "\<kPoint>", "\<kPlus>",
\ "\<kMinus>", "\<kMultiply>", "\<kDivide>"]
let save_term = &term
let save_ttymouse = &ttymouse
let save_clipboard = &clipboard
- call test_override('no_query_mouse', 1)
set mouse=a term=xterm ttymouse=sgr mousetime=200 clipboard=
let lines =<< trim END
END
call writefile(lines, 'Xtest_mouse')
+ " Create a terminal window running Vim for the test with mouse enabled
+ let prev_win = win_getid()
let buf = RunVimInTerminal('Xtest_mouse -n', {})
call term_sendkeys(buf, ":set nocompatible\<CR>")
call term_sendkeys(buf, ":set mouse=a term=xterm ttymouse=sgr\<CR>")
call term_wait(buf)
redraw!
+ " Use the mouse to enter the terminal window
+ call win_gotoid(prev_win)
+ call feedkeys(MouseLeftClickCode(1, 1), 'x')
+ call feedkeys(MouseLeftReleaseCode(1, 1), 'x')
+ call assert_equal(1, getwininfo(win_getid())[0].terminal)
+
" Test for <LeftMouse> click/release
call test_setmouse(2, 5)
call feedkeys("\<LeftMouse>\<LeftRelease>", 'xt')
let &ttymouse = save_ttymouse
let &clipboard = save_clipboard
set mousetime&
- call test_override('no_query_mouse', 0)
call delete('Xtest_mouse')
call delete('Xbuf')
endfunc
let save_mouse = &mouse
let save_term = &term
let save_ttymouse = &ttymouse
- call test_override('no_query_mouse', 1)
set mouse=a term=xterm ttymouse=sgr mousetime=200
set clipboard=autoselectml
END
call writefile(lines, 'Xtest_modeless')
+ " Create a terminal window running Vim for the test with mouse disabled
+ let prev_win = win_getid()
let buf = RunVimInTerminal('Xtest_modeless -n', {})
call term_sendkeys(buf, ":set nocompatible\<CR>")
call term_sendkeys(buf, ":set mouse=\<CR>")
call term_wait(buf)
redraw!
+ " Use the mouse to enter the terminal window
+ call win_gotoid(prev_win)
+ call feedkeys(MouseLeftClickCode(1, 1), 'x')
+ call feedkeys(MouseLeftReleaseCode(1, 1), 'x')
+ call term_wait(buf)
+ call assert_equal(1, getwininfo(win_getid())[0].terminal)
+
" Test for copying a modeless selection to clipboard
let @* = 'clean'
" communicating with X server may take a little time
let &term = save_term
let &ttymouse = save_ttymouse
set mousetime& clipboard&
- call test_override('no_query_mouse', 0)
call delete('Xtest_modeless')
+ new | only!
endfunc
" vim: shiftwidth=2 sts=2 expandtab