From 53b65401f8c4f03265b7d97240600b121dcc2aef Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 7 Sep 2015 23:15:21 +0100 Subject: [PATCH] Small info box handling in cleanup in ncurses --- src/ncurses_ui.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 19f5a3fd..0a5f807b 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -825,13 +825,11 @@ void NCursesUI::info_show(StringView title, StringView content, { info_hide(); - StringView info_box = content; - String fancy_info_box; + String info_box; if (style == InfoStyle::Prompt) { - fancy_info_box = make_info_box(title, content, m_dimensions.column, - m_assistant); - info_box = fancy_info_box; + info_box = make_info_box(title, content, m_dimensions.column, + m_assistant); anchor = CharCoord{m_status_on_top ? 0 : m_dimensions.line, m_dimensions.column-1}; } @@ -843,9 +841,12 @@ void NCursesUI::info_show(StringView title, StringView content, if (style == InfoStyle::MenuDoc and m_menu_win) col = window_pos(m_menu_win).column + window_size(m_menu_win).column; - for (auto& line : wrap_lines(content, m_dimensions.column - col)) - fancy_info_box += line + "\n"; - info_box = fancy_info_box; + const CharCount max_width = m_dimensions.column - col; + if (max_width < 4) + return; + + for (auto& line : wrap_lines(content, max_width)) + info_box += line + "\n"; } CharCoord size = compute_needed_size(info_box);