diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-08 22:13:38 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-08 22:13:38 +0000 |
commit | a48d4e44a24191f5495e17d7616771c20ae3e3c1 (patch) | |
tree | 276dd6e4c575048f0502ec6ee0f9b84bdf0b8a44 /src/terminal.c | |
parent | 48873aebc05608e9e5e56b8628ae6d2789ab7c48 (diff) | |
download | vim-git-a48d4e44a24191f5495e17d7616771c20ae3e3c1.tar.gz |
patch 8.2.3761: focus change is not passed on to a terminal windowv8.2.3761
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.
Diffstat (limited to 'src/terminal.c')
-rw-r--r-- | src/terminal.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/terminal.c b/src/terminal.c index 4a95a3e3d..c3ce11644 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1128,6 +1128,21 @@ get_tty_part(term_T *term UNUSED) } /* + * Read any vterm output and send it on the channel. + */ + static void +term_forward_output(term_T *term) +{ + VTerm *vterm = term->tl_vterm; + char buf[KEY_BUF_LEN]; + size_t curlen = vterm_output_read(vterm, buf, KEY_BUF_LEN); + + if (curlen > 0) + channel_send(term->tl_job->jv_channel, get_tty_part(term), + (char_u *)buf, (int)curlen, NULL); +} + +/* * Write job output "msg[len]" to the vterm. */ static void @@ -1154,14 +1169,7 @@ term_write_job_output(term_T *term, char_u *msg_arg, size_t len_arg) // flush vterm buffer when vterm responded to control sequence if (prevlen != vterm_output_get_buffer_current(vterm)) - { - char buf[KEY_BUF_LEN]; - size_t curlen = vterm_output_read(vterm, buf, KEY_BUF_LEN); - - if (curlen > 0) - channel_send(term->tl_job->jv_channel, get_tty_part(term), - (char_u *)buf, (int)curlen, NULL); - } + term_forward_output(term); // this invokes the damage callbacks vterm_screen_flush_damage(vterm_obtain_screen(vterm)); @@ -2490,6 +2498,23 @@ term_win_entered() } } + void +term_focus_change(int in_focus) +{ + term_T *term = curbuf->b_term; + + if (term != NULL && term->tl_vterm != NULL) + { + VTermState *state = vterm_obtain_state(term->tl_vterm); + + if (in_focus) + vterm_state_focus_in(state); + else + vterm_state_focus_out(state); + term_forward_output(term); + } +} + /* * vgetc() may not include CTRL in the key when modify_other_keys is set. * Return the Ctrl-key value in that case. |