Improve ncurses redraw behaviour

This commit is contained in:
Maxime Coste 2015-06-21 19:47:47 +01:00
parent 2162157752
commit 7c22ff217d
2 changed files with 13 additions and 4 deletions

View File

@ -284,7 +284,6 @@ NCursesUI::~NCursesUI()
void NCursesUI::redraw() void NCursesUI::redraw()
{ {
redrawwin(m_window);
wnoutrefresh(m_window); wnoutrefresh(m_window);
if (m_menu_win) if (m_menu_win)
{ {
@ -616,9 +615,7 @@ void NCursesUI::menu_show(ConstArrayView<String> items,
CharCoord anchor, Face fg, Face bg, CharCoord anchor, Face fg, Face bg,
MenuStyle style) MenuStyle style)
{ {
if (m_menu_win) menu_hide();
delwin(m_menu_win);
m_items.clear();
m_menu_fg = fg; m_menu_fg = fg;
m_menu_bg = bg; m_menu_bg = bg;
@ -688,6 +685,7 @@ void NCursesUI::menu_hide()
if (not m_menu_win) if (not m_menu_win)
return; return;
m_items.clear(); m_items.clear();
mark_dirty(m_menu_win);
delwin(m_menu_win); delwin(m_menu_win);
m_menu_win = nullptr; m_menu_win = nullptr;
m_dirty = true; m_dirty = true;
@ -871,11 +869,20 @@ void NCursesUI::info_hide()
{ {
if (not m_info_win) if (not m_info_win)
return; return;
mark_dirty(m_info_win);
delwin(m_info_win); delwin(m_info_win);
m_info_win = nullptr; m_info_win = nullptr;
m_dirty = true; 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() CharCoord NCursesUI::dimensions()
{ {
return m_dimensions; return m_dimensions;

View File

@ -57,6 +57,8 @@ private:
void draw_line(const DisplayLine& line, CharCount col_index, void draw_line(const DisplayLine& line, CharCount col_index,
const Face& default_face) const; const Face& default_face) const;
void mark_dirty(NCursesWin* region);
NCursesWin* m_window = nullptr; NCursesWin* m_window = nullptr;
CharCoord m_dimensions; CharCoord m_dimensions;