mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
Implement handling of terminal focus events
Two new keys have been added to key_name_entry in keymap.c: `FocusGained` and `FocusLost`. Two cases have been added to the key handing switch in edit.c each applying their respective autocmds. In normal.c two functions have been added alongside nv_cursorhold doing a similar job of applying the autocmd for the appropriate key. tui/input.c has a new function `handle_focus_event` which eats either of the control sequences for focus gained or lost. This function is checked before handle_bracketed_paste and handle_forced_escape. tui.c registers neovim as able to receive these control sequences in terminfo_start and undoes that in terminfo_stop. Closes #2302
This commit is contained in:
@@ -349,6 +349,8 @@ static const struct nv_cmd {
|
||||
{K_F8, farsi_fkey, 0, 0},
|
||||
{K_F9, farsi_fkey, 0, 0},
|
||||
{K_EVENT, nv_event, NV_KEEPREG, 0},
|
||||
{K_FOCUSGAINED, nv_focusgained, NV_KEEPREG, 0},
|
||||
{K_FOCUSLOST, nv_focuslost, NV_KEEPREG, 0},
|
||||
};
|
||||
|
||||
/* Number of commands in nv_cmds[]. */
|
||||
@@ -7715,6 +7717,18 @@ static void nv_event(cmdarg_T *cap)
|
||||
cap->retval |= CA_COMMAND_BUSY; // don't call edit() now
|
||||
}
|
||||
|
||||
/// Trigger FocusGained event.
|
||||
static void nv_focusgained(cmdarg_T *cap)
|
||||
{
|
||||
apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf);
|
||||
}
|
||||
|
||||
/// Trigger FocusLost event.
|
||||
static void nv_focuslost(cmdarg_T *cap)
|
||||
{
|
||||
apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos".
|
||||
*/
|
||||
|
Reference in New Issue
Block a user