summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-01-29 18:56:14 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-01-29 18:56:14 +0100
commit84ea452ed21dcd6a79cb30d9a6f67bce91a02c1b (patch)
tree963b240608ea1acbcc41ab164a8668912a2fd7af /src
parentf8209e3b5211ad852c1d61a90eab09f5b4db6ab1 (diff)
info command take a -anchor <pos> instead of -inline params
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 7805f67f..084b6601 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -623,7 +623,7 @@ void menu(const CommandParameters& params, Context& context)
void info(const CommandParameters& params, Context& context)
{
- ParametersParser parser(params, { { "inline", false } });
+ ParametersParser parser(params, { { "anchor", true } });
if (parser.positional_count() > 1)
throw wrong_argument_count();
@@ -631,13 +631,22 @@ void info(const CommandParameters& params, Context& context)
context.ui().info_hide();
if (parser.positional_count() > 0)
{
- MenuStyle style = parser.has_option("inline") ?
- MenuStyle::Inline : MenuStyle::Prompt;
- DisplayCoord pos;
- if (style == MenuStyle::Inline)
- pos = context.window().display_position(context.editor().selections().back().last());
- else
- pos.line = context.ui().dimensions().line;
+ MenuStyle style = MenuStyle::Prompt;
+ DisplayCoord pos = { context.ui().dimensions().line, 0 };
+ if (parser.has_option("anchor"))
+ {
+ style = MenuStyle::Inline;
+ const auto& sel = context.editor().selections().back();
+ auto it = sel.last();
+ String anchor = parser.option_value("anchor");
+ if (anchor == "left")
+ it = sel.begin();
+ else if (anchor == "right")
+ it = sel.end() - 1;
+ else if (anchor != "cursor")
+ throw runtime_error("anchor param must be one of [left, right, cursor]");
+ pos = context.window().display_position(it);
+ }
context.ui().info_show(parser[0], pos, style);
}
}