For {Menu,Info}Style::Prompt, choose the anchor directly in ncurses code
This commit is contained in:
parent
e1fc2677e3
commit
88aa707b9c
|
@ -138,13 +138,11 @@ void Client::check_buffer_fs_timestamp()
|
|||
return;
|
||||
if (reload == Ask)
|
||||
{
|
||||
CharCoord pos = context().window().dimensions();
|
||||
pos.column -= 1;
|
||||
m_ui->info_show(
|
||||
"reload '" + buffer.display_name() + "' ?",
|
||||
"'" + buffer.display_name() + "' was modified externally\n"
|
||||
"press r or y to reload, k or n to keep",
|
||||
pos, get_face("Information"), InfoStyle::Prompt);
|
||||
CharCoord{}, get_face("Information"), InfoStyle::Prompt);
|
||||
|
||||
m_input_handler.on_next_key(KeymapMode::None,
|
||||
[this, filename](Key key, Context& context) {
|
||||
|
|
|
@ -1235,8 +1235,7 @@ const CommandDesc info_cmd = {
|
|||
if (parser.positional_count() > 0)
|
||||
{
|
||||
InfoStyle style = InfoStyle::Prompt;
|
||||
CharCoord pos = context.ui().dimensions();
|
||||
pos.column -= 1;
|
||||
CharCoord pos;
|
||||
if (parser.has_option("anchor"))
|
||||
{
|
||||
auto anchor = parser.option_value("anchor");
|
||||
|
|
|
@ -114,12 +114,8 @@ public:
|
|||
if (it != keymap.end())
|
||||
{
|
||||
if (context().options()["autoinfo"].get<int>() >= 2 and context().has_ui())
|
||||
{
|
||||
Face col = get_face("Information");
|
||||
CharCoord pos = context().window().dimensions();
|
||||
pos.column -= 1;
|
||||
context().ui().info_show(key_to_str(key), it->second.docstring, pos, col, InfoStyle::Prompt);
|
||||
}
|
||||
context().ui().info_show(key_to_str(key), it->second.docstring, CharCoord{},
|
||||
get_face("Information"), InfoStyle::Prompt);
|
||||
it->second.func(context(), m_count);
|
||||
}
|
||||
m_count = 0;
|
||||
|
@ -330,8 +326,7 @@ public:
|
|||
{
|
||||
if (not context().has_ui())
|
||||
return;
|
||||
CharCoord menu_pos{ context().ui().dimensions().line, 0_char };
|
||||
context().ui().menu_show(choices, menu_pos, get_face("MenuForeground"),
|
||||
context().ui().menu_show(choices, CharCoord{}, get_face("MenuForeground"),
|
||||
get_face("MenuBackground"), MenuStyle::Prompt);
|
||||
context().ui().menu_select(0);
|
||||
}
|
||||
|
@ -683,11 +678,8 @@ private:
|
|||
line.byte_count_to(m_line_editor.cursor_pos()));
|
||||
CandidateList& candidates = m_completions.candidates;
|
||||
if (context().has_ui() and not candidates.empty())
|
||||
{
|
||||
CharCoord menu_pos{ context().ui().dimensions().line, 0_char };
|
||||
context().ui().menu_show(candidates, menu_pos, get_face("MenuForeground"),
|
||||
context().ui().menu_show(candidates, CharCoord{}, get_face("MenuForeground"),
|
||||
get_face("MenuBackground"), MenuStyle::Prompt);
|
||||
}
|
||||
} catch (runtime_error&) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -547,6 +547,9 @@ void NCursesUI::menu_show(memoryview<String> items,
|
|||
m_menu_fg = fg;
|
||||
m_menu_bg = bg;
|
||||
|
||||
if (style == MenuStyle::Prompt)
|
||||
anchor = CharCoord{m_dimensions.line, 0};
|
||||
|
||||
CharCoord maxsize = window_size(stdscr);
|
||||
maxsize.column -= anchor.column;
|
||||
if (maxsize.column <= 2)
|
||||
|
@ -778,6 +781,7 @@ void NCursesUI::info_show(StringView title, StringView content,
|
|||
{
|
||||
fancy_info_box = make_info_box(title, content, m_dimensions.column);
|
||||
info_box = fancy_info_box;
|
||||
anchor = CharCoord{m_dimensions.line, m_dimensions.column-1};
|
||||
}
|
||||
|
||||
CharCoord size = compute_needed_size(info_box);
|
||||
|
|
|
@ -114,9 +114,7 @@ bool show_auto_info_ifn(StringView title, StringView info,
|
|||
if (context.options()["autoinfo"].get<int>() < 1 or not context.has_ui())
|
||||
return false;
|
||||
Face face = get_face("Information");
|
||||
CharCoord pos = context.window().dimensions();
|
||||
pos.column -= 1;
|
||||
context.ui().info_show(title, info, pos, face, InfoStyle::Prompt);
|
||||
context.ui().info_show(title, info, CharCoord{}, face, InfoStyle::Prompt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -363,10 +361,8 @@ void command(Context& context, int)
|
|||
{
|
||||
auto info = CommandManager::instance().command_info(context, cmdline);
|
||||
Face col = get_face("Information");
|
||||
CharCoord pos = context.window().dimensions();
|
||||
pos.column -= 1;
|
||||
if (not info.first.empty() and not info.second.empty())
|
||||
context.ui().info_show(info.first, info.second, pos , col, InfoStyle::Prompt);
|
||||
context.ui().info_show(info.first, info.second, CharCoord{}, col, InfoStyle::Prompt);
|
||||
}
|
||||
}
|
||||
if (event == PromptEvent::Validate)
|
||||
|
@ -567,9 +563,7 @@ void regex_prompt(Context& context, const String prompt, T func)
|
|||
if (context.has_ui())
|
||||
{
|
||||
Face face = get_face("Information");
|
||||
CharCoord pos = context.window().dimensions();
|
||||
pos.column -= 1;
|
||||
context.ui().info_show("regex error", err.what(), pos, face, InfoStyle::Prompt);
|
||||
context.ui().info_show("regex error", err.what(), CharCoord{}, face, InfoStyle::Prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user