diff --git a/src/main.cc b/src/main.cc index e8e5564f..6fda5da6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -396,7 +396,6 @@ void register_options() "The ncurses ui supports the following options:\n" " : :\n" " ncurses_assistant clippy|cat|dilbert|none|off\n" - " ncurses_menu_layout horizontal|vertical\n" " ncurses_status_on_top bool\n" " ncurses_set_title bool\n" " ncurses_enable_mouse bool\n" diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index bf4517aa..aa6b9d7d 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -740,32 +740,20 @@ void NCursesUI::draw_menu() const LineCount mark_height = min(div_round_up(sq(win_height), menu_lines), win_height); - const LineCount top_line = m_menu.first_item / m_menu.columns; const int menu_cols = div_round_up(item_count, (int)m_menu.size.line); const int first_col = m_menu.first_item / (int)m_menu.size.line; - const LineCount mark_line = m_menu_vertical ? (win_height - mark_height) * first_col / max(1, menu_cols - m_menu.columns) : - (win_height - mark_height) * top_line / max(1_line, menu_lines - win_height); + const LineCount mark_line = (win_height - mark_height) * first_col / max(1, menu_cols - m_menu.columns); for (auto line = 0_line; line < win_height; ++line) { wmove(m_menu.win, (int)line, 0); for (int col = 0; col < m_menu.columns; ++col) { - int item_idx; - if (m_menu_vertical) - { - item_idx = (first_col + col) * (int)m_menu.size.line + (int)line; - if (item_idx >= item_count) - continue; - } - else - { - item_idx = (int)(top_line + line) * m_menu.columns + col; - if (item_idx >= item_count) - break; - } + int item_idx = (first_col + col) * (int)m_menu.size.line + (int)line; + if (item_idx >= item_count) + continue; const DisplayLine& item = m_menu.items[item_idx]; draw_line(m_menu.win, item, 0, column_width, @@ -898,28 +886,13 @@ void NCursesUI::menu_select(int selected) else { m_menu.selected_item = selected; - if (m_menu_vertical) - { - const int menu_cols = div_round_up(item_count, (int)m_menu.size.line); - const int first_col = m_menu.first_item / (int)m_menu.size.line; - const int selected_col = m_menu.selected_item / (int)m_menu.size.line; - if (selected_col < first_col) - m_menu.first_item = selected_col * (int)m_menu.size.line; - if (selected_col >= first_col + m_menu.columns) - m_menu.first_item = min(selected_col, menu_cols - m_menu.columns) * (int)m_menu.size.line; - } - else - { - const LineCount menu_lines = div_round_up(item_count, m_menu.columns); - const LineCount win_height = m_menu.size.line; - const LineCount top_line = m_menu.first_item / m_menu.columns; - const LineCount selected_line = m_menu.selected_item / m_menu.columns; - kak_assert(menu_lines >= win_height); - if (selected_line < top_line) - m_menu.first_item = (int)selected_line * m_menu.columns; - if (selected_line >= top_line + win_height) - m_menu.first_item = (int)min(selected_line, menu_lines - win_height) * m_menu.columns; - } + const int menu_cols = div_round_up(item_count, (int)m_menu.size.line); + const int first_col = m_menu.first_item / (int)m_menu.size.line; + const int selected_col = m_menu.selected_item / (int)m_menu.size.line; + if (selected_col < first_col) + m_menu.first_item = selected_col * (int)m_menu.size.line; + if (selected_col >= first_col + m_menu.columns) + m_menu.first_item = min(selected_col, menu_cols - m_menu.columns) * (int)m_menu.size.line; } draw_menu(); } @@ -1257,11 +1230,6 @@ void NCursesUI::set_ui_options(const Options& options) m_wheel_down_button = wheel_down_it != options.end() ? str_to_int_ifp(wheel_down_it->value).value_or(5) : 5; } - - { - auto it = options.find("ncurses_menu_layout"_sv); - m_menu_vertical = it != options.end() and it->value == "vertical"; - } } } diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index 76b70c5b..69eee61c 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -147,8 +147,6 @@ private: bool m_set_title = true; bool m_change_colors = true; - bool m_menu_vertical = false; - bool m_dirty = false; bool m_resize_pending = false;