mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-26 04:52:53 +03:00
Add support for FocusIn/FocusOut events from UI
This commit is contained in:
parent
f8e4bb09f2
commit
10f4bb5872
@ -69,6 +69,10 @@ void Client::handle_available_input(EventMode mode)
|
||||
{
|
||||
if (*key == ctrl('c'))
|
||||
killpg(getpgrp(), SIGINT);
|
||||
else if (*key == Key::FocusIn)
|
||||
context().hooks().run_hook("FocusIn", context().name(), context());
|
||||
else if (*key == Key::FocusOut)
|
||||
context().hooks().run_hook("FocusOut", context().name(), context());
|
||||
else
|
||||
m_input_handler.handle_key(*key);
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ struct Key
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
FocusIn,
|
||||
FocusOut,
|
||||
Invalid,
|
||||
};
|
||||
|
||||
|
@ -261,6 +261,8 @@ NCursesUI::NCursesUI()
|
||||
mouseinterval(0);
|
||||
// force enable report mouse position
|
||||
puts("\033[?1002h");
|
||||
// force enable report focus events
|
||||
puts("\033[?1004h");
|
||||
|
||||
signal(SIGWINCH, on_term_resize);
|
||||
signal(SIGINT, [](int){});
|
||||
@ -272,6 +274,7 @@ NCursesUI::NCursesUI()
|
||||
|
||||
NCursesUI::~NCursesUI()
|
||||
{
|
||||
puts("\033[?1004l");
|
||||
puts("\033[?1002l");
|
||||
endwin();
|
||||
signal(SIGWINCH, SIG_DFL);
|
||||
@ -509,6 +512,16 @@ Key NCursesUI::get_key()
|
||||
{
|
||||
timeout(0);
|
||||
const Codepoint new_c = getch();
|
||||
if (new_c == '[') // potential CSI
|
||||
{
|
||||
const Codepoint csi_val = getch();
|
||||
switch (csi_val)
|
||||
{
|
||||
case 'I': return Key::FocusIn;
|
||||
case 'O': return Key::FocusOut;
|
||||
default: break; // nothing
|
||||
}
|
||||
}
|
||||
timeout(-1);
|
||||
if (new_c != ERR)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user