From 3184159572e2d336d5a61393f9fb939f684678af Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 14 Dec 2012 19:25:27 +0100 Subject: [PATCH] info: support a -inline option By default display info box above command line, full width (like menu), in inline mode, display the info box close to cursor, using only needed width. --- src/commands.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index f47c1574..cbf37143 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -604,14 +604,23 @@ void menu(const CommandParameters& params, Context& context) void info(const CommandParameters& params, Context& context) { - ParametersParser parser(params, { }); + ParametersParser parser(params, { { "inline", false } }); if (parser.positional_count() > 1) throw wrong_argument_count(); context.ui().info_hide(); if (parser.positional_count() > 0) - context.ui().info_show(parser[0], {0,0}, MenuStyle::Inline); + { + 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; + context.ui().info_show(parser[0], pos, style); + } } void try_catch(const CommandParameters& params, Context& context)