removed option and horizontal layout

This commit is contained in:
Justin Frank 2018-08-10 10:14:48 -07:00
parent a1e3fa02e6
commit c5a1225638
3 changed files with 11 additions and 46 deletions

View File

@ -396,7 +396,6 @@ void register_options()
"The ncurses ui supports the following options:\n"
" <key>: <value>:\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"

View File

@ -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;
int 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;
}
const DisplayLine& item = m_menu.items[item_idx];
draw_line(m_menu.win, item, 0, column_width,
@ -898,8 +886,6 @@ 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;
@ -908,19 +894,6 @@ void NCursesUI::menu_select(int selected)
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;
}
}
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";
}
}
}

View File

@ -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;