From 310e5e3bcd906fe0089602209c8378eff8eda774 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 3 Jun 2018 12:15:02 +1000 Subject: [PATCH] NCursesUI: Use only 3 line menu for MenuStyle::Search --- src/ncurses_ui.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 66203f54..3f8f6845 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -727,6 +727,18 @@ void NCursesUI::draw_menu() 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 items, DisplayCoord anchor, Face fg, Face bg, MenuStyle style) @@ -757,9 +769,8 @@ void NCursesUI::menu_show(ConstArrayView items, const bool is_inline = style == MenuStyle::Inline; 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 height = min(min(10_line, max_height), - div_round_up(item_count, m_menu.columns)); + const LineCount max_height = min(height_limit(style), max(anchor.line, m_dimensions.line - anchor.line - 1)); + const LineCount height = min(max_height, div_round_up(item_count, m_menu.columns)); const ColumnCount maxlen = (m_menu.columns > 1 and item_count > 1) ? max_width / m_menu.columns - 1 : max_width;