From 7c22ff217d5d02bb926202e48dc35ba7a19c6f66 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 21 Jun 2015 19:47:47 +0100 Subject: [PATCH] Improve ncurses redraw behaviour --- src/ncurses_ui.cc | 15 +++++++++++---- src/ncurses_ui.hh | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 7f7dbcba..aee5b89c 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -284,7 +284,6 @@ NCursesUI::~NCursesUI() void NCursesUI::redraw() { - redrawwin(m_window); wnoutrefresh(m_window); if (m_menu_win) { @@ -616,9 +615,7 @@ void NCursesUI::menu_show(ConstArrayView items, CharCoord anchor, Face fg, Face bg, MenuStyle style) { - if (m_menu_win) - delwin(m_menu_win); - m_items.clear(); + menu_hide(); m_menu_fg = fg; m_menu_bg = bg; @@ -688,6 +685,7 @@ void NCursesUI::menu_hide() if (not m_menu_win) return; m_items.clear(); + mark_dirty(m_menu_win); delwin(m_menu_win); m_menu_win = nullptr; m_dirty = true; @@ -871,11 +869,20 @@ void NCursesUI::info_hide() { if (not m_info_win) return; + mark_dirty(m_info_win); delwin(m_info_win); m_info_win = nullptr; m_dirty = true; } +void NCursesUI::mark_dirty(NCursesWin* region) +{ + auto pos = window_pos(region); + auto size = window_size(region); + + wredrawln(m_window, (int)pos.line, (int)size.line); +} + CharCoord NCursesUI::dimensions() { return m_dimensions; diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index a98550c6..ac73332d 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -57,6 +57,8 @@ private: void draw_line(const DisplayLine& line, CharCount col_index, const Face& default_face) const; + void mark_dirty(NCursesWin* region); + NCursesWin* m_window = nullptr; CharCoord m_dimensions;