InputHandler: add some new hooks

This commit is contained in:
Maxime Coste 2013-01-30 19:04:03 +01:00
parent de0f765498
commit c9b113fd5f

View File

@ -42,7 +42,14 @@ public:
m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) { m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) {
context().hooks().run_hook("NormalIdle", "", context()); context().hooks().run_hook("NormalIdle", "", context());
}} }}
{} {
context().hooks().run_hook("NormalBegin", "", context());
}
~Normal()
{
context().hooks().run_hook("NormalEnd", "", context());
}
void on_key(const Key& key) override void on_key(const Key& key) override
{ {
@ -58,6 +65,7 @@ public:
} }
m_count = 0; m_count = 0;
} }
context().hooks().run_hook("NormalKey", key_to_str(key), context());
m_idle_timer.set_next_date(Clock::now() + idle_timeout); m_idle_timer.set_next_date(Clock::now() + idle_timeout);
} }
@ -573,7 +581,10 @@ public:
moved = true; moved = true;
} }
else if (key.modifiers == Key::Modifiers::None) else if (key.modifiers == Key::Modifiers::None)
{
m_inserter.insert(codepoint_to_str(key.key)); m_inserter.insert(codepoint_to_str(key.key));
context().hooks().run_hook("InsertKey", key_to_str(key), context());
}
else if (key == Key{ Key::Modifiers::Control, 'r' }) else if (key == Key{ Key::Modifiers::Control, 'r' })
m_insert_reg = true; m_insert_reg = true;
else if ( key == Key{ Key::Modifiers::Control, 'm' }) else if ( key == Key{ Key::Modifiers::Control, 'm' })
@ -594,7 +605,7 @@ public:
if (update_completions) if (update_completions)
m_idle_timer.set_next_date(Clock::now() + idle_timeout); m_idle_timer.set_next_date(Clock::now() + idle_timeout);
if (moved) if (moved)
context().hooks().run_hook("InsertMove", "", context()); context().hooks().run_hook("InsertMove", key_to_str(key), context());
} }
private: private:
bool m_insert_reg = false; bool m_insert_reg = false;