NCursesUI::get_key returns the codepoint

This commit is contained in:
Maxime Coste 2012-10-09 14:30:35 +02:00
parent ba50d853b3
commit c0db3b81be

View File

@ -180,10 +180,16 @@ void NCursesUI::draw_window(Window& window)
redraw(m_menu_win);
}
struct getch_iterator
{
int operator*() { return getch(); }
getch_iterator& operator++() { return *this; }
getch_iterator& operator++(int) { return *this; }
};
Key NCursesUI::get_key()
{
const utf8::Codepoint c = getch();
const unsigned c = getch();
if (c > 0 and c < 27)
{
return {Key::Modifiers::Control, c - 1 + 'a'};
@ -209,7 +215,9 @@ Key NCursesUI::get_key()
case KEY_NPAGE: return Key::PageDown;
case KEY_BTAB: return Key::BackTab;
}
return c;
ungetch(c);
return utf8::codepoint(getch_iterator{});
}
void NCursesUI::print_status(const String& status, CharCount cursor_pos)