Additional NCursesUI code cleanups
This commit is contained in:
parent
2eccbbbe6f
commit
7f141e83ce
|
@ -38,11 +38,6 @@ void NCursesUI::Window::create(const DisplayCoord& p, const DisplayCoord& s)
|
||||||
void NCursesUI::Window::destroy()
|
void NCursesUI::Window::destroy()
|
||||||
{
|
{
|
||||||
delwin(win);
|
delwin(win);
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NCursesUI::Window::invalidate()
|
|
||||||
{
|
|
||||||
win = nullptr;
|
win = nullptr;
|
||||||
pos = DisplayCoord{};
|
pos = DisplayCoord{};
|
||||||
size = DisplayCoord{};
|
size = DisplayCoord{};
|
||||||
|
@ -101,25 +96,19 @@ void NCursesUI::Window::draw(Palette& palette, ConstArrayView<DisplayAtom> atoms
|
||||||
ColumnCount column = 0;
|
ColumnCount column = 0;
|
||||||
for (const DisplayAtom& atom : atoms)
|
for (const DisplayAtom& atom : atoms)
|
||||||
{
|
{
|
||||||
set_face(atom.face);
|
StringView content = atom.content().substr(0_col, max_width - column);
|
||||||
|
|
||||||
StringView content = atom.content();
|
|
||||||
if (content.empty())
|
if (content.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto remaining_columns = max_width - column;
|
set_face(atom.face);
|
||||||
if (content.back() == '\n' and
|
if (content.back() == '\n')
|
||||||
content.column_length() - 1 < remaining_columns)
|
|
||||||
{
|
{
|
||||||
add_str(content.substr(0, content.length()-1));
|
add_str(content.substr(0, content.length()-1));
|
||||||
waddch(win, ' ');
|
waddch(win, ' ');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
content = content.substr(0_col, remaining_columns);
|
|
||||||
add_str(content);
|
add_str(content);
|
||||||
column += content.column_length();
|
column += content.column_length();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (column < max_width)
|
if (column < max_width)
|
||||||
wclrtoeol(win);
|
wclrtoeol(win);
|
||||||
|
@ -579,7 +568,8 @@ Optional<Key> NCursesUI::get_next_key()
|
||||||
{
|
{
|
||||||
set_signal_handler(SIGWINCH, SIG_DFL);
|
set_signal_handler(SIGWINCH, SIG_DFL);
|
||||||
set_signal_handler(SIGCONT, SIG_DFL);
|
set_signal_handler(SIGCONT, SIG_DFL);
|
||||||
m_window.invalidate();
|
if (m_window)
|
||||||
|
m_window.destroy();
|
||||||
m_stdin_watcher.disable();
|
m_stdin_watcher.disable();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,6 @@ private:
|
||||||
{
|
{
|
||||||
void create(const DisplayCoord& pos, const DisplayCoord& size);
|
void create(const DisplayCoord& pos, const DisplayCoord& size);
|
||||||
void destroy();
|
void destroy();
|
||||||
void invalidate();
|
|
||||||
void refresh(bool force);
|
void refresh(bool force);
|
||||||
void move_cursor(DisplayCoord coord);
|
void move_cursor(DisplayCoord coord);
|
||||||
void mark_dirty(LineCount pos, LineCount count);
|
void mark_dirty(LineCount pos, LineCount count);
|
||||||
|
@ -119,8 +118,6 @@ private:
|
||||||
|
|
||||||
void set_raw_mode() const;
|
void set_raw_mode() const;
|
||||||
|
|
||||||
void mark_dirty(const Window& win);
|
|
||||||
|
|
||||||
struct Menu : Window
|
struct Menu : Window
|
||||||
{
|
{
|
||||||
Vector<DisplayLine, MemoryDomain::Display> items;
|
Vector<DisplayLine, MemoryDomain::Display> items;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user