Ensure all available input is handled before going back to main loop
We were not handling keys that could have been generated while handling other keys (like during a shell evaluation).
This commit is contained in:
parent
3a81260917
commit
540e504e68
|
@ -55,15 +55,14 @@ Client::~Client()
|
||||||
m_window->set_client(nullptr);
|
m_window->set_client(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::process_pending_inputs()
|
bool Client::process_pending_inputs()
|
||||||
{
|
{
|
||||||
try
|
const bool debug_keys = (bool)(context().options()["debug"].get<DebugFlags>() & DebugFlags::Keys);
|
||||||
|
// steal keys as we might receive new keys while handling them.
|
||||||
|
Vector<Key, MemoryDomain::Client> keys = std::move(m_pending_keys);
|
||||||
|
for (auto& key : keys)
|
||||||
{
|
{
|
||||||
const bool debug_keys = (bool)(context().options()["debug"].get<DebugFlags>() & DebugFlags::Keys);
|
try
|
||||||
|
|
||||||
// steal keys as we might receive new keys while handling them.
|
|
||||||
Vector<Key, MemoryDomain::Client> keys = std::move(m_pending_keys);
|
|
||||||
for (auto& key : keys)
|
|
||||||
{
|
{
|
||||||
if (debug_keys)
|
if (debug_keys)
|
||||||
write_to_debug_buffer(format("Client '{}' got key '{}'",
|
write_to_debug_buffer(format("Client '{}' got key '{}'",
|
||||||
|
@ -81,12 +80,13 @@ void Client::process_pending_inputs()
|
||||||
else
|
else
|
||||||
m_input_handler.handle_key(key);
|
m_input_handler.handle_key(key);
|
||||||
}
|
}
|
||||||
|
catch (Kakoune::runtime_error& error)
|
||||||
|
{
|
||||||
|
context().print_status({ error.what().str(), get_face("Error") });
|
||||||
|
context().hooks().run_hook("RuntimeError", error.what(), context());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Kakoune::runtime_error& error)
|
return not keys.empty();
|
||||||
{
|
|
||||||
context().print_status({ error.what().str(), get_face("Error") });
|
|
||||||
context().hooks().run_hook("RuntimeError", error.what(), context());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::print_status(DisplayLine status_line, bool immediate)
|
void Client::print_status(DisplayLine status_line, bool immediate)
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
Client(Client&&) = delete;
|
Client(Client&&) = delete;
|
||||||
|
|
||||||
void process_pending_inputs();
|
bool process_pending_inputs();
|
||||||
|
|
||||||
void menu_show(Vector<DisplayLine> choices, BufferCoord anchor, MenuStyle style);
|
void menu_show(Vector<DisplayLine> choices, BufferCoord anchor, MenuStyle style);
|
||||||
void menu_select(int selected);
|
void menu_select(int selected);
|
||||||
|
|
|
@ -63,8 +63,15 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
|
||||||
|
|
||||||
void ClientManager::process_pending_inputs() const
|
void ClientManager::process_pending_inputs() const
|
||||||
{
|
{
|
||||||
for (auto& client : m_clients)
|
while (true)
|
||||||
client->process_pending_inputs();
|
{
|
||||||
|
bool had_input = false;
|
||||||
|
for (auto& client : m_clients)
|
||||||
|
had_input = client->process_pending_inputs() or had_input;
|
||||||
|
|
||||||
|
if (not had_input)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientManager::remove_client(Client& client, bool graceful)
|
void ClientManager::remove_client(Client& client, bool graceful)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user