Mercurial > vim
comparison src/terminal.c @ 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 | f93337ae0612 |
children | d413104a94c8 |
comparison
equal
deleted
inserted
replaced
26461:97613c2162af | 26462:3af56224dca6 |
---|---|
1126 #endif | 1126 #endif |
1127 return PART_IN; | 1127 return PART_IN; |
1128 } | 1128 } |
1129 | 1129 |
1130 /* | 1130 /* |
1131 * Read any vterm output and send it on the channel. | |
1132 */ | |
1133 static void | |
1134 term_forward_output(term_T *term) | |
1135 { | |
1136 VTerm *vterm = term->tl_vterm; | |
1137 char buf[KEY_BUF_LEN]; | |
1138 size_t curlen = vterm_output_read(vterm, buf, KEY_BUF_LEN); | |
1139 | |
1140 if (curlen > 0) | |
1141 channel_send(term->tl_job->jv_channel, get_tty_part(term), | |
1142 (char_u *)buf, (int)curlen, NULL); | |
1143 } | |
1144 | |
1145 /* | |
1131 * Write job output "msg[len]" to the vterm. | 1146 * Write job output "msg[len]" to the vterm. |
1132 */ | 1147 */ |
1133 static void | 1148 static void |
1134 term_write_job_output(term_T *term, char_u *msg_arg, size_t len_arg) | 1149 term_write_job_output(term_T *term, char_u *msg_arg, size_t len_arg) |
1135 { | 1150 { |
1152 | 1167 |
1153 vterm_input_write(vterm, (char *)msg, len); | 1168 vterm_input_write(vterm, (char *)msg, len); |
1154 | 1169 |
1155 // flush vterm buffer when vterm responded to control sequence | 1170 // flush vterm buffer when vterm responded to control sequence |
1156 if (prevlen != vterm_output_get_buffer_current(vterm)) | 1171 if (prevlen != vterm_output_get_buffer_current(vterm)) |
1157 { | 1172 term_forward_output(term); |
1158 char buf[KEY_BUF_LEN]; | |
1159 size_t curlen = vterm_output_read(vterm, buf, KEY_BUF_LEN); | |
1160 | |
1161 if (curlen > 0) | |
1162 channel_send(term->tl_job->jv_channel, get_tty_part(term), | |
1163 (char_u *)buf, (int)curlen, NULL); | |
1164 } | |
1165 | 1173 |
1166 // this invokes the damage callbacks | 1174 // this invokes the damage callbacks |
1167 vterm_screen_flush_damage(vterm_obtain_screen(vterm)); | 1175 vterm_screen_flush_damage(vterm_obtain_screen(vterm)); |
1168 } | 1176 } |
1169 | 1177 |
2488 enter_mouse_col = mouse_col; | 2496 enter_mouse_col = mouse_col; |
2489 enter_mouse_row = mouse_row; | 2497 enter_mouse_row = mouse_row; |
2490 } | 2498 } |
2491 } | 2499 } |
2492 | 2500 |
2501 void | |
2502 term_focus_change(int in_focus) | |
2503 { | |
2504 term_T *term = curbuf->b_term; | |
2505 | |
2506 if (term != NULL && term->tl_vterm != NULL) | |
2507 { | |
2508 VTermState *state = vterm_obtain_state(term->tl_vterm); | |
2509 | |
2510 if (in_focus) | |
2511 vterm_state_focus_in(state); | |
2512 else | |
2513 vterm_state_focus_out(state); | |
2514 term_forward_output(term); | |
2515 } | |
2516 } | |
2517 | |
2493 /* | 2518 /* |
2494 * vgetc() may not include CTRL in the key when modify_other_keys is set. | 2519 * vgetc() may not include CTRL in the key when modify_other_keys is set. |
2495 * Return the Ctrl-key value in that case. | 2520 * Return the Ctrl-key value in that case. |
2496 */ | 2521 */ |
2497 static int | 2522 static int |