From 2aa5d3b016503827ecba43023270bd1a31a7d2be Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Tue, 14 Mar 2017 19:06:09 +0300 Subject: [PATCH] src: Align the assistant in the middle of the popup --- src/ncurses_ui.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index e33abd79..e457be5e 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -859,11 +859,17 @@ String make_info_box(StringView title, StringView message, ColumnCount max_width auto line_count = max(assistant_size.line-1, LineCount{(int)lines.size()} + 2); + const int assistant_top_margin = ((int)line_count - (int)assistant_size.line+1) / 2; for (LineCount i = 0; i < line_count; ++i) { constexpr Codepoint dash{L'─'}; if (not assistant.empty()) - result += assistant[min((int)i, (int)assistant_size.line-1)]; + { + if (i >= assistant_top_margin) + result += assistant[min((int)i - assistant_top_margin, (int)assistant_size.line-1)]; + else + result += assistant[(int)assistant_size.line-1]; + } if (i == 0) { if (title.empty())