From 9a2822e329c7ae448d82734078e38df4ac757655 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 31 Oct 2014 21:49:36 +0000 Subject: [PATCH] Change :info -anchor option, take directly a buffer coordinate Fix ctags funcinfo feature using that --- rc/ctags.kak | 8 +++----- src/commands.cc | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/rc/ctags.kak b/rc/ctags.kak index a307efdb..e521372d 100644 --- a/rc/ctags.kak +++ b/rc/ctags.kak @@ -35,11 +35,11 @@ def tag-complete %{ eval -draft %{ def funcinfo %{ eval -draft %{ - exec [(B[a-zA-Z_]+\( + exec '[(;B[a-zA-Z_]+\(' %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 - echo "eval -client ${kak_client} %{info -anchor right '$sigs'}" + echo "eval -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column '$sigs'}" fi } } @@ -47,8 +47,6 @@ def funcinfo %{ def ctags-enable-autoinfo %{ 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 } diff --git a/src/commands.cc b/src/commands.cc index 240daea1..a7d56c07 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1225,7 +1225,7 @@ const CommandDesc info_cmd = { nullptr, "info ...: display an info box with the params as content", ParameterDesc{ - SwitchMap{ { "anchor", { true, "set info anchoring (left, right, or cursor)" } }, + SwitchMap{ { "anchor", { true, "set info anchoring ." } }, { "title", { true, "set info title" } } }, ParameterDesc::Flags::None, 0, 1 }, @@ -1241,17 +1241,15 @@ const CommandDesc info_cmd = { pos.column -= 1; if (parser.has_option("anchor")) { - 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); + auto anchor = parser.option_value("anchor"); + size_t dot = anchor.find_first_of('.'); + if (dot == String::npos) + throw runtime_error("expected . 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; } const String& title = parser.has_option("title") ? parser.option_value("title") : ""; context.ui().info_show(title, parser[0], pos, get_face("Information"), style);