Add Modal
InfoStyle used for bufer reload info box
Modal info style wont be replaced by other info boxes. NCursesUI will center that info box. Fixes #1060
This commit is contained in:
parent
8f821f0fba
commit
b3674a2f03
|
@ -287,7 +287,7 @@ void Client::close_buffer_reload_dialog()
|
||||||
{
|
{
|
||||||
kak_assert(m_buffer_reload_dialog_opened);
|
kak_assert(m_buffer_reload_dialog_opened);
|
||||||
m_buffer_reload_dialog_opened = false;
|
m_buffer_reload_dialog_opened = false;
|
||||||
info_hide();
|
info_hide(true);
|
||||||
m_input_handler.reset_normal_mode();
|
m_input_handler.reset_normal_mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ void Client::check_if_buffer_needs_reloading()
|
||||||
info_show(format("reload '{}' ?", bufname),
|
info_show(format("reload '{}' ?", bufname),
|
||||||
format("'{}' was modified externally\n"
|
format("'{}' was modified externally\n"
|
||||||
"press <ret> or y to reload, <esc> or n to keep",
|
"press <ret> or y to reload, <esc> or n to keep",
|
||||||
bufname), {}, InfoStyle::Prompt);
|
bufname), {}, InfoStyle::Modal);
|
||||||
|
|
||||||
m_buffer_reload_dialog_opened = true;
|
m_buffer_reload_dialog_opened = true;
|
||||||
m_input_handler.on_next_key(KeymapMode::None, [this](Key key, Context&){ on_buffer_reload_key(key); });
|
m_input_handler.on_next_key(KeymapMode::None, [this](Key key, Context&){ on_buffer_reload_key(key); });
|
||||||
|
@ -360,13 +360,19 @@ void Client::menu_hide()
|
||||||
|
|
||||||
void Client::info_show(String title, String content, BufferCoord anchor, InfoStyle style)
|
void Client::info_show(String title, String content, BufferCoord anchor, InfoStyle style)
|
||||||
{
|
{
|
||||||
|
if (m_info.style == InfoStyle::Modal) // We already have a modal info opened, do not touch it.
|
||||||
|
return;
|
||||||
|
|
||||||
m_info = Info{ std::move(title), std::move(content), anchor, {}, style };
|
m_info = Info{ std::move(title), std::move(content), anchor, {}, style };
|
||||||
m_ui_pending |= InfoShow;
|
m_ui_pending |= InfoShow;
|
||||||
m_ui_pending &= ~InfoHide;
|
m_ui_pending &= ~InfoHide;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::info_hide()
|
void Client::info_hide(bool even_modal)
|
||||||
{
|
{
|
||||||
|
if (not even_modal and m_info.style == InfoStyle::Modal)
|
||||||
|
return;
|
||||||
|
|
||||||
m_info = Info{};
|
m_info = Info{};
|
||||||
m_ui_pending |= InfoHide;
|
m_ui_pending |= InfoHide;
|
||||||
m_ui_pending &= ~InfoShow;
|
m_ui_pending &= ~InfoShow;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
void menu_hide();
|
void menu_hide();
|
||||||
|
|
||||||
void info_show(String title, String content, BufferCoord anchor, InfoStyle style);
|
void info_show(String title, String content, BufferCoord anchor, InfoStyle style);
|
||||||
void info_hide();
|
void info_hide(bool even_modal = false);
|
||||||
|
|
||||||
void print_status(DisplayLine status_line, bool immediate = false);
|
void print_status(DisplayLine status_line, bool immediate = false);
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,7 @@ String to_json(InfoStyle style)
|
||||||
case InfoStyle::InlineAbove: return R"("inlineAbove")";
|
case InfoStyle::InlineAbove: return R"("inlineAbove")";
|
||||||
case InfoStyle::InlineBelow: return R"("inlineBelow")";
|
case InfoStyle::InlineBelow: return R"("inlineBelow")";
|
||||||
case InfoStyle::MenuDoc: return R"("menuDoc")";
|
case InfoStyle::MenuDoc: return R"("menuDoc")";
|
||||||
|
case InfoStyle::Modal: return R"("modal")";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -893,6 +893,9 @@ void NCursesUI::info_show(StringView title, StringView content,
|
||||||
anchor = DisplayCoord{m_status_on_top ? 0 : m_dimensions.line,
|
anchor = DisplayCoord{m_status_on_top ? 0 : m_dimensions.line,
|
||||||
m_dimensions.column-1};
|
m_dimensions.column-1};
|
||||||
}
|
}
|
||||||
|
else if (style == InfoStyle::Modal)
|
||||||
|
info_box = make_info_box(m_info.title, m_info.content,
|
||||||
|
m_dimensions.column, {});
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_status_on_top)
|
if (m_status_on_top)
|
||||||
|
@ -913,6 +916,11 @@ void NCursesUI::info_show(StringView title, StringView content,
|
||||||
const Rect rect = {m_status_on_top ? 1_line : 0_line, m_dimensions};
|
const Rect rect = {m_status_on_top ? 1_line : 0_line, m_dimensions};
|
||||||
if (style == InfoStyle::MenuDoc and m_menu)
|
if (style == InfoStyle::MenuDoc and m_menu)
|
||||||
pos = m_menu.pos + DisplayCoord{0_line, m_menu.size.column};
|
pos = m_menu.pos + DisplayCoord{0_line, m_menu.size.column};
|
||||||
|
else if (style == InfoStyle::Modal)
|
||||||
|
{
|
||||||
|
auto half = [](const DisplayCoord& c) { return DisplayCoord{c.line / 2, c.column / 2}; };
|
||||||
|
pos = rect.pos + half(rect.size) - half(size);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
pos = compute_pos(anchor, size, rect, m_menu, style == InfoStyle::InlineAbove);
|
pos = compute_pos(anchor, size, rect, m_menu, style == InfoStyle::InlineAbove);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ enum class InfoStyle
|
||||||
Inline,
|
Inline,
|
||||||
InlineAbove,
|
InlineAbove,
|
||||||
InlineBelow,
|
InlineBelow,
|
||||||
MenuDoc
|
MenuDoc,
|
||||||
|
Modal
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EventMode;
|
enum class EventMode;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user