summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-05-16 21:46:15 +0200
committerMaxime Coste <frrrwww@gmail.com>2013-05-16 21:46:15 +0200
commit23f43376dfc821c186bb57a48af3ef7ac10265f4 (patch)
treeb65b9077657ff9b760c32bf064bc5a10cbd92666 /src
parentb2dffbabb64a045ab01907bbbb9e621787201efe (diff)
fix NCurses info box, avoid trailing space on each lines
Diffstat (limited to 'src')
-rw-r--r--src/ncurses.cc16
1 files 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();
}