diff --git a/src/client.cc b/src/client.cc index daa89f6f..3bb6efc7 100644 --- a/src/client.cc +++ b/src/client.cc @@ -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) { diff --git a/src/commands.cc b/src/commands.cc index 25060d18..7106df89 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -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"); diff --git a/src/input_handler.cc b/src/input_handler.cc index 5db479f1..630bc2f1 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -114,12 +114,8 @@ public: if (it != keymap.end()) { if (context().options()["autoinfo"].get() >= 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&) {} } diff --git a/src/ncurses.cc b/src/ncurses.cc index 03e44cb1..88a4a93b 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -547,6 +547,9 @@ void NCursesUI::menu_show(memoryview 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); diff --git a/src/normal.cc b/src/normal.cc index 5d258e59..18c2fe8b 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -114,9 +114,7 @@ bool show_auto_info_ifn(StringView title, StringView info, if (context.options()["autoinfo"].get() < 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); } } }