diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 7196f344..0fc4642b 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -38,11 +38,6 @@ void NCursesUI::Window::create(const DisplayCoord& p, const DisplayCoord& s) void NCursesUI::Window::destroy() { delwin(win); - invalidate(); -} - -void NCursesUI::Window::invalidate() -{ win = nullptr; pos = DisplayCoord{}; size = DisplayCoord{}; @@ -101,25 +96,19 @@ void NCursesUI::Window::draw(Palette& palette, ConstArrayView atoms ColumnCount column = 0; for (const DisplayAtom& atom : atoms) { - set_face(atom.face); - - StringView content = atom.content(); + StringView content = atom.content().substr(0_col, max_width - column); if (content.empty()) continue; - const auto remaining_columns = max_width - column; - if (content.back() == '\n' and - content.column_length() - 1 < remaining_columns) + set_face(atom.face); + if (content.back() == '\n') { add_str(content.substr(0, content.length()-1)); waddch(win, ' '); } else - { - content = content.substr(0_col, remaining_columns); add_str(content); - column += content.column_length(); - } + column += content.column_length(); } if (column < max_width) wclrtoeol(win); @@ -579,7 +568,8 @@ Optional NCursesUI::get_next_key() { set_signal_handler(SIGWINCH, SIG_DFL); set_signal_handler(SIGCONT, SIG_DFL); - m_window.invalidate(); + if (m_window) + m_window.destroy(); m_stdin_watcher.disable(); return {}; } diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index ee695fc3..9f2e9752 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -99,7 +99,6 @@ private: { void create(const DisplayCoord& pos, const DisplayCoord& size); void destroy(); - void invalidate(); void refresh(bool force); void move_cursor(DisplayCoord coord); void mark_dirty(LineCount pos, LineCount count); @@ -119,8 +118,6 @@ private: void set_raw_mode() const; - void mark_dirty(const Window& win); - struct Menu : Window { Vector items;