Merge remote-tracking branch 'inahga/aghani-info-width'

This commit is contained in:
Maxime Coste 2023-03-01 19:50:53 +11:00
commit 1479bf6f08
4 changed files with 12 additions and 2 deletions

View File

@ -377,6 +377,10 @@ are exclusively available to built-in options.
reduce terminal output with sequences that could trigger flickering reduce terminal output with sequences that could trigger flickering
if unsynchronized (defaults to *false*) if unsynchronized (defaults to *false*)
*terminal_info_max_width*:::
set the maximum allowable width of an info box. set to zero for
no limit.
[[startup-info]] [[startup-info]]
*startup_info_version* `int`:: *startup_info_version* `int`::
_default_ 0 + _default_ 0 +

View File

@ -567,7 +567,8 @@ void register_options()
" terminal_wheel_scroll_amount int\n" " terminal_wheel_scroll_amount int\n"
" terminal_shift_function_key int\n" " terminal_shift_function_key int\n"
" terminal_padding_char codepoint\n" " terminal_padding_char codepoint\n"
" terminal_padding_fill bool\n", " terminal_padding_fill bool\n"
" terminal_info_max_width int\n",
UserInterface::Options{}); UserInterface::Options{});
reg.declare_option("modelinefmt", "format string used to generate the modeline", reg.declare_option("modelinefmt", "format string used to generate the modeline",
"%val{bufname} %val{cursor_line}:%val{cursor_char_column} {{context_info}} {{mode_info}} - %val{client}@[%val{session}]"_str); "%val{bufname} %val{cursor_line}:%val{cursor_char_column} {{context_info}} {{mode_info}} - %val{client}@[%val{session}]"_str);

View File

@ -1264,7 +1264,9 @@ void TerminalUI::info_show(const DisplayLine& title, const DisplayLineList& cont
else if (style != InfoStyle::Modal) else if (style != InfoStyle::Modal)
max_size.line -= m_menu.size.line; max_size.line -= m_menu.size.line;
const auto max_content_width = max_size.column - (framed ? 4 : 2) - (assisted ? m_assistant[0].column_length() : 0); const auto max_content_width = (m_info_max_width > 0 ? std::min(max_size.column, m_info_max_width) : max_size.column) -
(framed ? 4 : 2) -
(assisted ? m_assistant[0].column_length() : 0);
if (max_content_width <= 0) if (max_content_width <= 0)
return; return;
@ -1495,6 +1497,8 @@ void TerminalUI::set_ui_options(const Options& options)
m_padding_char = find("terminal_padding_char").map([](StringView s) { return s.column_length() < 1 ? ' ' : s[0_char]; }).value_or(Codepoint{'~'}); m_padding_char = find("terminal_padding_char").map([](StringView s) { return s.column_length() < 1 ? ' ' : s[0_char]; }).value_or(Codepoint{'~'});
m_padding_fill = find("terminal_padding_fill").map(to_bool).value_or(false); m_padding_fill = find("terminal_padding_fill").map(to_bool).value_or(false);
m_info_max_width = find("terminal_info_max_width").map(str_to_int_ifp).value_or(0);
} }
} }

View File

@ -170,6 +170,7 @@ private:
void set_resize_pending(); void set_resize_pending();
ColumnCount m_status_len = 0; ColumnCount m_status_len = 0;
ColumnCount m_info_max_width = 0;
}; };
} }