From 0ab5fbb8094770667030f28b45aa46d381d66563 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 13 Feb 2017 10:55:46 +0100 Subject: Use scoped window timeout --- src/curses/window.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/curses') diff --git a/src/curses/window.h b/src/curses/window.h index 413e563a..686961fd 100644 --- a/src/curses/window.h +++ b/src/curses/window.h @@ -254,6 +254,25 @@ struct Window PromptHook m_hook; }; + struct ScopedTimeout + { + ScopedTimeout(Window &w, int new_timeout) + : m_w(w) + { + m_timeout = w.getTimeout(); + w.setTimeout(new_timeout); + } + + ~ScopedTimeout() + { + m_w.setTimeout(m_timeout); + } + + private: + Window &m_w; + int m_timeout; + }; + Window() : m_window(nullptr) { } /// Constructs an empty window with given parameters -- cgit v1.2.3