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>::: *-anchor* <line>.<column>:::
print the text at the given coordinates print the text at the given coordinates
*-placement* <placement>::: *-style* <style>:::
set the placement and style of the message box. set the style and placement of the message box.
*menu*:::: *menu*::::
display the info next to the displayed menu, as documentation display the info next to the displayed menu, as documentation
@ -292,6 +292,12 @@ but not really useful in that context.
*below*:::: *below*::::
display the info below the given anchor 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>::: *-title* <text>:::
set the title of the message box set the title of the message box

View File

@ -105,7 +105,7 @@ define-command -hidden clang-show-completion-info %[ try %[
evaluate-commands %sh[ 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 }") 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 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 fi
] ] ] ]
] ] ] ]

View File

@ -67,7 +67,7 @@ define-command ctags-funcinfo -docstring "Display ctags information about a sele
csn='\t(class|struct|namespace):(\S+)' 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}]/") 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 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 fi
} }
} }

View File

@ -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 style (above, below, menu)" } }, { "style", { true, "set info style (above, below, menu, modal)" } },
{ "title", { true, "set info title" } } }, { "title", { true, "set info title" } } },
ParameterDesc::Flags::None, 0, 1 ParameterDesc::Flags::None, 0, 1
}, },
@ -2088,18 +2088,19 @@ const CommandDesc info_cmd = {
if (not context.has_client()) if (not context.has_client())
return; 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) if (parser.positional_count() == 0)
return; 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( const BufferCoord pos = parser.get_switch("anchor").map(
[](StringView anchor) { [](StringView anchor) {
auto dot = find(anchor, '.'); auto dot = find(anchor, '.');