From 23f43376dfc821c186bb57a48af3ef7ac10265f4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 16 May 2013 21:46:15 +0200 Subject: [PATCH] fix NCurses info box, avoid trailing space on each lines --- src/ncurses.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ncurses.cc b/src/ncurses.cc index 54600c09..83961e95 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -492,7 +492,7 @@ static DisplayCoord compute_needed_size(const String& str) if (begin+1 == end) break; - res.column = std::max(res.column, line_len+1); + res.column = std::max(res.column, line_len); line_len = 0; ++res.line; } @@ -550,9 +550,17 @@ void NCursesUI::info_show(const String& content, DisplayCoord anchor, (int)pos.line, (int)pos.column); wbkgd(m_info_win, COLOR_PAIR(get_color_pair(colors))); - wmove(m_info_win, 0, 0); - addutf8str(m_info_win, Utf8Iterator(content.begin()), - Utf8Iterator(content.end())); + int line = 0; + auto it = content.begin(), end = content.end(); + while (true) + { + wmove(m_info_win, line++, 0); + auto eol = std::find_if(it, end, [](char c) { return c == '\n'; }); + addutf8str(m_info_win, Utf8Iterator(it), Utf8Iterator(eol)); + if (eol == end) + break; + it = eol + 1; + } redraw(); }