Change :info -anchor option, take directly a buffer coordinate
Fix ctags funcinfo feature using that
This commit is contained in:
parent
2c2d57f671
commit
9a2822e329
|
@ -35,11 +35,11 @@ def tag-complete %{ eval -draft %{
|
||||||
|
|
||||||
def funcinfo %{
|
def funcinfo %{
|
||||||
eval -draft %{
|
eval -draft %{
|
||||||
exec [(<space>B<a-k>[a-zA-Z_]+\(<ret>
|
exec '[(;B<a-k>[a-zA-Z_]+\(<ret><a-;>'
|
||||||
%sh{
|
%sh{
|
||||||
sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*(class|struct|namespace):(\S+).*signature:(.*)$/\4 [\3::\1]/')
|
sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*((class|struct|namespace):(\S+))?.*signature:(.*)$/\5 [\4::\1]/')
|
||||||
if [ -n "$sigs" ]; then
|
if [ -n "$sigs" ]; then
|
||||||
echo "eval -client ${kak_client} %{info -anchor right '$sigs'}"
|
echo "eval -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column '$sigs'}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,6 @@ def funcinfo %{
|
||||||
|
|
||||||
def ctags-enable-autoinfo %{
|
def ctags-enable-autoinfo %{
|
||||||
hook window -group ctags-autoinfo NormalIdle .* funcinfo
|
hook window -group ctags-autoinfo NormalIdle .* funcinfo
|
||||||
hook window -group ctags-autoinfo NormalEnd .* info
|
|
||||||
hook window -group ctags-autoinfo NormalKey .* info
|
|
||||||
hook window -group ctags-autoinfo InsertIdle .* funcinfo
|
hook window -group ctags-autoinfo InsertIdle .* funcinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1225,7 +1225,7 @@ const CommandDesc info_cmd = {
|
||||||
nullptr,
|
nullptr,
|
||||||
"info <switches> <params>...: display an info box with the params as content",
|
"info <switches> <params>...: display an info box with the params as content",
|
||||||
ParameterDesc{
|
ParameterDesc{
|
||||||
SwitchMap{ { "anchor", { true, "set info anchoring (left, right, or cursor)" } },
|
SwitchMap{ { "anchor", { true, "set info anchoring <line>.<column>" } },
|
||||||
{ "title", { true, "set info title" } } },
|
{ "title", { true, "set info title" } } },
|
||||||
ParameterDesc::Flags::None, 0, 1
|
ParameterDesc::Flags::None, 0, 1
|
||||||
},
|
},
|
||||||
|
@ -1241,17 +1241,15 @@ const CommandDesc info_cmd = {
|
||||||
pos.column -= 1;
|
pos.column -= 1;
|
||||||
if (parser.has_option("anchor"))
|
if (parser.has_option("anchor"))
|
||||||
{
|
{
|
||||||
|
auto anchor = parser.option_value("anchor");
|
||||||
|
size_t dot = anchor.find_first_of('.');
|
||||||
|
if (dot == String::npos)
|
||||||
|
throw runtime_error("expected <line>.<column> for anchor");
|
||||||
|
ByteCount dotb = (int)dot;
|
||||||
|
ByteCoord coord{str_to_int(anchor.substr(0, dotb))-1,
|
||||||
|
str_to_int(anchor.substr(dotb+1))-1};
|
||||||
|
pos = context.window().display_position(coord);
|
||||||
style = MenuStyle::Inline;
|
style = MenuStyle::Inline;
|
||||||
const auto& sel = context.selections().main();
|
|
||||||
auto it = sel.cursor();
|
|
||||||
String anchor = parser.option_value("anchor");
|
|
||||||
if (anchor == "left")
|
|
||||||
it = sel.min();
|
|
||||||
else if (anchor == "right")
|
|
||||||
it = sel.max();
|
|
||||||
else if (anchor != "cursor")
|
|
||||||
throw runtime_error("anchor param must be one of [left, right, cursor]");
|
|
||||||
pos = context.window().display_position(it);
|
|
||||||
}
|
}
|
||||||
const String& title = parser.has_option("title") ? parser.option_value("title") : "";
|
const String& title = parser.has_option("title") ? parser.option_value("title") : "";
|
||||||
context.ui().info_show(title, parser[0], pos, get_face("Information"), style);
|
context.ui().info_show(title, parser[0], pos, get_face("Information"), style);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user