Put count and register normal mode params in the shell context

'10:echo %val{count}' will display 10
Fixes #10
This commit is contained in:
Maxime Coste 2015-11-17 23:47:59 +00:00
parent 6bd71c68e5
commit a37858ece7

View File

@ -334,7 +334,7 @@ void for_each_codepoint(Context& context, NormalParams)
selections.insert(strings, InsertMode::Replace); selections.insert(strings, InsertMode::Replace);
} }
void command(Context& context, NormalParams) void command(Context& context, NormalParams params)
{ {
if (not CommandManager::has_instance()) if (not CommandManager::has_instance())
return; return;
@ -345,7 +345,7 @@ void command(Context& context, NormalParams)
StringView cmd_line, ByteCount pos) { StringView cmd_line, ByteCount pos) {
return CommandManager::instance().complete(context, flags, cmd_line, pos); return CommandManager::instance().complete(context, flags, cmd_line, pos);
}, },
[](StringView cmdline, PromptEvent event, Context& context) { [params](StringView cmdline, PromptEvent event, Context& context) {
if (context.has_ui()) if (context.has_ui())
{ {
context.ui().info_hide(); context.ui().info_hide();
@ -362,7 +362,14 @@ void command(Context& context, NormalParams)
} }
} }
if (event == PromptEvent::Validate) if (event == PromptEvent::Validate)
CommandManager::instance().execute(cmdline, context); {
EnvVarMap env_vars = {
{ "count", to_string(params.count) },
{ "register", String{params.reg} }
};
CommandManager::instance().execute(
cmdline, context, { {}, env_vars });
}
}); });
} }