summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-09-11 00:05:31 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-09-11 00:05:31 +0100
commit34d0f63fd9f3d4d57bb0c826aac3740dcd59ed52 (patch)
tree9d0c52b048413a175548ced74249073043516d7a /src
parent80726a789b811e4e122ffae5174b2e044b64caea (diff)
Use wgetch rather than getch to avoid unwanted redraws
Diffstat (limited to 'src')
-rw-r--r--src/ncurses_ui.cc31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc
index 9a39e65d..c1370a79 100644
--- a/src/ncurses_ui.cc
+++ b/src/ncurses_ui.cc
@@ -487,11 +487,11 @@ bool NCursesUI::is_key_available()
{
check_resize();
- timeout(0);
- const int c = getch();
+ wtimeout(m_window, 0);
+ const int c = wgetch(m_window);
if (c != ERR)
ungetch(c);
- timeout(-1);
+ wtimeout(m_window, -1);
return c != ERR;
}
@@ -499,7 +499,7 @@ Key NCursesUI::get_key()
{
check_resize();
- const int c = getch();
+ const int c = wgetch(m_window);
if (c == KEY_MOUSE)
{
@@ -519,7 +519,7 @@ Key NCursesUI::get_key()
{
if (c == CTRL('l'))
{
- redrawwin(m_window);
+ //redrawwin(m_window);
redraw();
}
if (c == CTRL('z'))
@@ -531,11 +531,11 @@ Key NCursesUI::get_key()
}
else if (c == 27)
{
- timeout(0);
- const Codepoint new_c = getch();
+ wtimeout(m_window, 0);
+ const Codepoint new_c = wgetch(m_window);
if (new_c == '[') // potential CSI
{
- const Codepoint csi_val = getch();
+ const Codepoint csi_val = wgetch(m_window);
switch (csi_val)
{
case 'I': return Key::FocusIn;
@@ -543,7 +543,7 @@ Key NCursesUI::get_key()
default: break; // nothing
}
}
- timeout(-1);
+ wtimeout(m_window, -1);
if (new_c != ERR)
{
if (new_c > 0 and new_c < 27)
@@ -580,12 +580,15 @@ Key NCursesUI::get_key()
ungetch(c);
struct getch_iterator
{
- int operator*() { return getch(); }
- getch_iterator& operator++() { return *this; }
- getch_iterator& operator++(int) { return *this; }
- bool operator== (const getch_iterator&) const { return false; }
+ getch_iterator(WINDOW* win) : window(win) {}
+ int operator*() { return wgetch(window); }
+ getch_iterator& operator++() { return *this; }
+ getch_iterator& operator++(int) { return *this; }
+ bool operator== (const getch_iterator&) const { return false; }
+
+ WINDOW* window;
};
- return utf8::codepoint(getch_iterator{}, getch_iterator{});
+ return utf8::codepoint(getch_iterator{m_window}, getch_iterator{m_window});
}
return Key::Invalid;
}