From a10bfed9e5a96b164489b781f2b3a1bdbbe25d8f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 6 Mar 2013 19:03:58 +0100 Subject: [PATCH] ncurses: fix unicode handling in status line --- src/ncurses.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ncurses.cc b/src/ncurses.cc index d35be0f5..66f58612 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -297,15 +297,20 @@ void NCursesUI::draw_status() addutf8str(stdscr, m_status_line.begin(), m_status_line.end()); else { - auto cursor_it = utf8::advance(m_status_line.begin(), m_status_line.end(), - (int)m_status_cursor); - auto end = m_status_line.end(); + Utf8Iterator begin{m_status_line.begin()}; + Utf8Iterator end{m_status_line.end()}; + Utf8Iterator cursor_it{begin}; + cursor_it.advance(m_status_cursor, end); + addutf8str(stdscr, m_status_line.begin(), cursor_it); set_attribute(A_REVERSE, 1); - addch((cursor_it == end) ? ' ' : utf8::codepoint(cursor_it)); + if (cursor_it == end) + addch(' '); + else + addutf8str(stdscr, cursor_it, cursor_it+1); set_attribute(A_REVERSE, 0); if (cursor_it != end) - addutf8str(stdscr, utf8::next(cursor_it), end); + addutf8str(stdscr, cursor_it+1, end); } }