From a9d33a879696818b556fab00080fcabb8a120db9 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 27 Apr 2021 15:27:57 +0200 Subject: [PATCH] fix ncurses' padding option - Use less iterations when drawing padding fill with multiple characters. - Use column_length to handle null-width character as no character. --- src/ncurses_ui.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index d2d93b0e..86fcedec 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -477,8 +477,11 @@ void NCursesUI::draw(const DisplayBuffer& display_buffer, if (m_padding_fill) { ColumnCount column_index = 0; - while (column_index++ < dim.column) + while (column_index < dim.column) + { m_window.draw(m_palette, m_padding_char, face); + column_index += m_padding_char.length(); + } } else m_window.draw(m_palette, m_padding_char, face); @@ -1372,8 +1375,10 @@ void NCursesUI::set_ui_options(const Options& options) { auto it = options.find("ncurses_padding_char"_sv); if (it == options.end()) + // Defaults to tilde. m_padding_char = DisplayAtom("~"); - else if (it->value.length() < 1) + else if (it->value.column_length() < 1) + // Do not allow empty string, use space instead. m_padding_char = DisplayAtom(" "); else m_padding_char = DisplayAtom(it->value);