summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-06-03 12:15:02 +1000
committerMaxime Coste <mawww@kakoune.org>2018-06-03 12:17:38 +1000
commit310e5e3bcd906fe0089602209c8378eff8eda774 (patch)
tree091c371d9e8865d969b10f4132ea8e3c21583b5d /src
parent2bdbf7e379412ff4461871c1eb342948f90f51ca (diff)
NCursesUI: Use only 3 line menu for MenuStyle::Search
Diffstat (limited to 'src')
-rw-r--r--src/ncurses_ui.cc17
1 files 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<DisplayLine> items,
DisplayCoord anchor, Face fg, Face bg,
MenuStyle style)
@@ -757,9 +769,8 @@ void NCursesUI::menu_show(ConstArrayView<DisplayLine> 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<LineCount>(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<LineCount>(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;