Support '-placement menu' switch in the info command
Expose insert completion menu documentation via the info command.
This commit is contained in:
parent
6d83828dab
commit
0bff4851d9
|
@ -279,8 +279,18 @@ but not really useful in that context.
|
||||||
*-anchor* <line>.<column>:::
|
*-anchor* <line>.<column>:::
|
||||||
print the text at the given coordinates
|
print the text at the given coordinates
|
||||||
|
|
||||||
*-placement* {above,below}:::
|
*-placement* <placement>:::
|
||||||
set the placement relative to the anchor
|
set the placement and style of the message box.
|
||||||
|
|
||||||
|
*menu*::::
|
||||||
|
display the info next to the displayed menu, as documentation
|
||||||
|
for the currently selected entry.
|
||||||
|
|
||||||
|
*above*::::
|
||||||
|
display the info above the given anchor
|
||||||
|
|
||||||
|
*below*::::
|
||||||
|
display the info below the given anchor
|
||||||
|
|
||||||
*-title* <text>:::
|
*-title* <text>:::
|
||||||
set the title of the message box
|
set the title of the message box
|
||||||
|
|
|
@ -2076,7 +2076,7 @@ const CommandDesc info_cmd = {
|
||||||
"info [<switches>] <text>: display an info box containing <text>",
|
"info [<switches>] <text>: display an info box containing <text>",
|
||||||
ParameterDesc{
|
ParameterDesc{
|
||||||
{ { "anchor", { true, "set info anchoring <line>.<column>" } },
|
{ { "anchor", { true, "set info anchoring <line>.<column>" } },
|
||||||
{ "placement", { true, "set placement relative to anchor (above, below)" } },
|
{ "placement", { true, "set placement style (above, below, menu)" } },
|
||||||
{ "title", { true, "set info title" } } },
|
{ "title", { true, "set info title" } } },
|
||||||
ParameterDesc::Flags::None, 0, 1
|
ParameterDesc::Flags::None, 0, 1
|
||||||
},
|
},
|
||||||
|
@ -2089,33 +2089,29 @@ const CommandDesc info_cmd = {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context.client().info_hide();
|
context.client().info_hide();
|
||||||
if (parser.positional_count() > 0)
|
if (parser.positional_count() == 0)
|
||||||
{
|
return;
|
||||||
InfoStyle style = InfoStyle::Prompt;
|
|
||||||
BufferCoord pos;
|
const InfoStyle style = parser.get_switch("placement").map(
|
||||||
if (auto anchor = parser.get_switch("anchor"))
|
[](StringView placement) -> Optional<InfoStyle> {
|
||||||
{
|
if (placement == "above") return InfoStyle::InlineAbove;
|
||||||
auto dot = find(*anchor, '.');
|
if (placement == "below") return InfoStyle::InlineBelow;
|
||||||
if (dot == anchor->end())
|
if (placement == "menu") return InfoStyle::MenuDoc;
|
||||||
|
throw runtime_error(format("invalid placement: '{}'", placement));
|
||||||
|
}).value_or(parser.get_switch("anchor") ? InfoStyle::Inline : InfoStyle::Prompt);
|
||||||
|
|
||||||
|
const BufferCoord pos = parser.get_switch("anchor").map(
|
||||||
|
[](StringView anchor) {
|
||||||
|
auto dot = find(anchor, '.');
|
||||||
|
if (dot == anchor.end())
|
||||||
throw runtime_error("expected <line>.<column> for anchor");
|
throw runtime_error("expected <line>.<column> for anchor");
|
||||||
|
|
||||||
pos = BufferCoord{str_to_int({anchor->begin(), dot})-1,
|
return BufferCoord{str_to_int({anchor.begin(), dot})-1,
|
||||||
str_to_int({dot+1, anchor->end()})-1};
|
str_to_int({dot+1, anchor.end()})-1};
|
||||||
style = InfoStyle::Inline;
|
}).value_or(BufferCoord{});
|
||||||
|
|
||||||
if (auto placement = parser.get_switch("placement"))
|
auto title = parser.get_switch("title").value_or(StringView{});
|
||||||
{
|
context.client().info_show(title.str(), parser[0], pos, style);
|
||||||
if (*placement == "above")
|
|
||||||
style = InfoStyle::InlineAbove;
|
|
||||||
else if (*placement == "below")
|
|
||||||
style = InfoStyle::InlineBelow;
|
|
||||||
else
|
|
||||||
throw runtime_error(format("invalid placement: '{}'", *placement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto title = parser.get_switch("title").value_or(StringView{});
|
|
||||||
context.client().info_show(title.str(), parser[0], pos, style);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user