From 2235944e60119795bfeb3bce57f393b60c185faf Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 29 Jan 2013 13:58:19 +0100 Subject: [PATCH] Add NormalIdle hook support --- src/input_handler.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/input_handler.cc b/src/input_handler.cc index ec75d899..a9f5d0a2 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -38,9 +38,11 @@ class Normal : public InputMode { public: Normal(InputHandler& input_handler) - : InputMode(input_handler) - { - } + : InputMode(input_handler), + m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) { + context().hooks().run_hook("NormalIdle", "", context()); + }} + {} void on_key(const Key& key) override { @@ -56,10 +58,12 @@ public: } m_count = 0; } + m_idle_timer.set_next_date(Clock::now() + idle_timeout); } private: int m_count = 0; + Timer m_idle_timer; }; class LineEditor