Rename info -placement to info -style and support modal style

Fixes #1375
Closes #1380
This commit is contained in:
Maxime Coste 2019-04-17 08:31:06 +02:00
parent ace499ecb1
commit 02fc42a12a
4 changed files with 23 additions and 16 deletions

View File

@ -279,8 +279,8 @@ but not really useful in that context.
*-anchor* <line>.<column>:::
print the text at the given coordinates
*-placement* <placement>:::
set the placement and style of the message box.
*-style* <style>:::
set the style and placement of the message box.
*menu*::::
display the info next to the displayed menu, as documentation
@ -292,6 +292,12 @@ but not really useful in that context.
*below*::::
display the info below the given anchor
*modal*::::
display the info modally, and do not auto-close the
info or replace it with non modal info boxes. To hide
a modal info box, use `info -style modal` with no
arguments.
*-title* <text>:::
set the title of the message box

View File

@ -105,7 +105,7 @@ define-command -hidden clang-show-completion-info %[ try %[
evaluate-commands %sh[
desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -e "{ s/\([^\\]\):/\1\n/g }" | sed -ne "/^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; p }")
if [ -n "$desc" ]; then
printf %s\\n "evaluate-commands -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -placement above %{${desc}}}"
printf %s\\n "evaluate-commands -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -style above %{${desc}}}"
fi
] ]
] ]

View File

@ -67,7 +67,7 @@ define-command ctags-funcinfo -docstring "Display ctags information about a sele
csn='\t(class|struct|namespace):(\S+)'
sigs=$(readtags -e -Q '(eq? $kind "f")' "${f}" | sed -re "s/^.*${csn}.*${sig}$/\3 [\2::${f}]/ ;t ;s/^.*${sig}$/\1 [${f}]/")
if [ -n "$sigs" ]; then
printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -placement above '$sigs'}"
printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -style above '$sigs'}"
fi
}
}

View File

@ -2075,9 +2075,9 @@ const CommandDesc info_cmd = {
nullptr,
"info [<switches>] <text>: display an info box containing <text>",
ParameterDesc{
{ { "anchor", { true, "set info anchoring <line>.<column>" } },
{ "placement", { true, "set placement style (above, below, menu)" } },
{ "title", { true, "set info title" } } },
{ { "anchor", { true, "set info anchoring <line>.<column>" } },
{ "style", { true, "set info style (above, below, menu, modal)" } },
{ "title", { true, "set info title" } } },
ParameterDesc::Flags::None, 0, 1
},
CommandFlags::None,
@ -2088,18 +2088,19 @@ const CommandDesc info_cmd = {
if (not context.has_client())
return;
context.client().info_hide();
const InfoStyle style = parser.get_switch("style").map(
[](StringView style) -> Optional<InfoStyle> {
if (style == "above") return InfoStyle::InlineAbove;
if (style == "below") return InfoStyle::InlineBelow;
if (style == "menu") return InfoStyle::MenuDoc;
if (style == "modal") return InfoStyle::Modal;
throw runtime_error(format("invalid style: '{}'", style));
}).value_or(parser.get_switch("anchor") ? InfoStyle::Inline : InfoStyle::Prompt);
context.client().info_hide(style == InfoStyle::Modal);
if (parser.positional_count() == 0)
return;
const InfoStyle style = parser.get_switch("placement").map(
[](StringView placement) -> Optional<InfoStyle> {
if (placement == "above") return InfoStyle::InlineAbove;
if (placement == "below") return InfoStyle::InlineBelow;
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, '.');