summaryrefslogtreecommitdiff
path: root/src/curses
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2017-02-13 10:55:46 +0100
committerAndrzej Rybczak <electricityispower@gmail.com>2017-02-13 10:55:46 +0100
commit0ab5fbb8094770667030f28b45aa46d381d66563 (patch)
treefa218bd8d52e7e54c4e97ee88b56bb443c5e5a7a /src/curses
parent05bf53d0abda580039445e1e69fe066a3446a4fd (diff)
Use scoped window timeout
Diffstat (limited to 'src/curses')
-rw-r--r--src/curses/window.h19
1 files changed, 19 insertions, 0 deletions
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