NCursesUI: Use only 3 line menu for MenuStyle::Search
This commit is contained in:
parent
2bdbf7e379
commit
310e5e3bcd
|
@ -727,6 +727,18 @@ void NCursesUI::draw_menu()
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LineCount height_limit(MenuStyle style)
|
||||||
|
{
|
||||||
|
switch (style)
|
||||||
|
{
|
||||||
|
case MenuStyle::Inline: return 10_line;
|
||||||
|
case MenuStyle::Prompt: return 10_line;
|
||||||
|
case MenuStyle::Search: return 3_line;
|
||||||
|
}
|
||||||
|
kak_assert(false);
|
||||||
|
return 0_line;
|
||||||
|
}
|
||||||
|
|
||||||
void NCursesUI::menu_show(ConstArrayView<DisplayLine> items,
|
void NCursesUI::menu_show(ConstArrayView<DisplayLine> items,
|
||||||
DisplayCoord anchor, Face fg, Face bg,
|
DisplayCoord anchor, Face fg, Face bg,
|
||||||
MenuStyle style)
|
MenuStyle style)
|
||||||
|
@ -757,9 +769,8 @@ void NCursesUI::menu_show(ConstArrayView<DisplayLine> items,
|
||||||
const bool is_inline = style == MenuStyle::Inline;
|
const bool is_inline = style == MenuStyle::Inline;
|
||||||
m_menu.columns = is_inline ? 1 : max((int)(max_width / (longest+1)), 1);
|
m_menu.columns = is_inline ? 1 : max((int)(max_width / (longest+1)), 1);
|
||||||
|
|
||||||
const LineCount max_height = std::max(anchor.line, m_dimensions.line - anchor.line - 1);
|
const LineCount max_height = min(height_limit(style), max(anchor.line, m_dimensions.line - anchor.line - 1));
|
||||||
const LineCount height = min<LineCount>(min(10_line, max_height),
|
const LineCount height = min<LineCount>(max_height, div_round_up(item_count, m_menu.columns));
|
||||||
div_round_up(item_count, m_menu.columns));
|
|
||||||
|
|
||||||
const ColumnCount maxlen = (m_menu.columns > 1 and item_count > 1) ?
|
const ColumnCount maxlen = (m_menu.columns > 1 and item_count > 1) ?
|
||||||
max_width / m_menu.columns - 1 : max_width;
|
max_width / m_menu.columns - 1 : max_width;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user