Tweak search style menu completion display

This commit is contained in:
Maxime Coste 2018-06-20 20:20:11 +10:00
parent b82d31016b
commit 3d4ee7d201

View File

@ -697,7 +697,7 @@ void NCursesUI::draw_menu()
const int item_count = (int)m_menu.items.size(); const int item_count = (int)m_menu.items.size();
if (m_menu.columns == 0) if (m_menu.columns == 0)
{ {
const auto win_width = m_menu.size.column - 3; const auto win_width = m_menu.size.column - 4;
kak_assert(m_menu.size.line == 1); kak_assert(m_menu.size.line == 1);
ColumnCount pos = 0; ColumnCount pos = 0;
@ -705,22 +705,26 @@ void NCursesUI::draw_menu()
add_str(m_menu.win, m_menu.first_item > 0 ? "< " : " "); add_str(m_menu.win, m_menu.first_item > 0 ? "< " : " ");
int i = m_menu.first_item; int i = m_menu.first_item;
for (; i < item_count; ++i) for (; i < item_count and pos < win_width; ++i)
{ {
const DisplayLine& item = m_menu.items[i]; const DisplayLine& item = m_menu.items[i];
const ColumnCount item_width = item.length() + 1 ; const ColumnCount item_width = item.length();
if (pos + item_width > win_width)
break;
draw_line(m_menu.win, item, 0, win_width - pos, draw_line(m_menu.win, item, 0, win_width - pos,
i == m_menu.selected_item ? m_menu.fg : m_menu.bg); i == m_menu.selected_item ? m_menu.fg : m_menu.bg);
wattron(m_menu.win, COLOR_PAIR(menu_bg));
add_str(m_menu.win, String{" "}); if (item_width > win_width - pos)
pos += item_width; add_str(m_menu.win, "");
else
{
wattron(m_menu.win, COLOR_PAIR(menu_bg));
add_str(m_menu.win, String{" "});
}
pos += item_width + 1;
} }
set_face(m_menu.win, m_menu.bg, m_menu.bg); set_face(m_menu.win, m_menu.bg, m_menu.bg);
add_str(m_menu.win, String{' ', win_width - pos}); if (pos <= win_width)
add_str(m_menu.win, String{' ', win_width - pos + 1});
add_str(m_menu.win, i == item_count ? " " : ">"); add_str(m_menu.win, i == item_count ? " " : ">");
m_dirty = true; m_dirty = true;
return; return;