Mercurial > vim
comparison src/testdir/test_terminal.vim @ 26462:3af56224dca6 v8.2.3761
patch 8.2.3761: focus change is not passed on to a terminal window
Commit: https://github.com/vim/vim/commit/a48d4e44a24191f5495e17d7616771c20ae3e3c1
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 8 22:13:38 2021 +0000
patch 8.2.3761: focus change is not passed on to a terminal window
Problem: Focus change is not passed on to a terminal window.
Solution: If the current window is a terminal and focus events are enabled
send a focus event escape sequence to the terminal.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 08 Dec 2021 23:15:04 +0100 |
parents | d25c0b0aad7d |
children | d413104a94c8 |
comparison
equal
deleted
inserted
replaced
26461:97613c2162af | 26462:3af56224dca6 |
---|---|
1120 call term_sendkeys(buf, "\<CR>\<C-D>") | 1120 call term_sendkeys(buf, "\<CR>\<C-D>") |
1121 | 1121 |
1122 call StopShellInTerminal(buf) | 1122 call StopShellInTerminal(buf) |
1123 exe buf . 'bwipe' | 1123 exe buf . 'bwipe' |
1124 unlet g:job | 1124 unlet g:job |
1125 endfunc | |
1126 | |
1127 func Test_terminal_focus_events() | |
1128 CheckNotGui | |
1129 CheckUnix | |
1130 CheckRunVimInTerminal | |
1131 | |
1132 let save_term = &term | |
1133 let save_ttymouse = &ttymouse | |
1134 set term=xterm ttymouse=xterm2 | |
1135 | |
1136 let lines =<< trim END | |
1137 set term=xterm ttymouse=xterm2 | |
1138 au FocusLost * echo 'I am lost' | |
1139 au FocusGained * echo 'I am back' | |
1140 " FIXME: sometimes this job hangs, exit after a couple of seconds | |
1141 call timer_start(2000, {id -> execute('qall')}) | |
1142 END | |
1143 call writefile(lines, 'XtermFocus') | |
1144 let buf = RunVimInTerminal('-S XtermFocus', #{rows: 6}) | |
1145 | |
1146 " Send a focus event to ourselves, it should be forwarded to the terminal | |
1147 call feedkeys("\<Esc>[O", "Lx!") | |
1148 call TermWait(buf) | |
1149 call VerifyScreenDump(buf, 'Test_terminal_focus_1', {}) | |
1150 | |
1151 call feedkeys("\<Esc>[I", "Lx!") | |
1152 call TermWait(buf) | |
1153 call VerifyScreenDump(buf, 'Test_terminal_focus_2', {}) | |
1154 | |
1155 call StopVimInTerminal(buf) | |
1156 call delete('XtermFocus') | |
1157 let &term = save_term | |
1158 let &ttymouse = save_ttymouse | |
1125 endfunc | 1159 endfunc |
1126 | 1160 |
1127 " Run Vim, start a terminal in that Vim with the kill argument, | 1161 " Run Vim, start a terminal in that Vim with the kill argument, |
1128 " :qall works. | 1162 " :qall works. |
1129 func Run_terminal_qall_kill(line1, line2) | 1163 func Run_terminal_qall_kill(line1, line2) |