From db2fa6f5cbe170f8f8889724d97c502fe10a3cad Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 5 Oct 2015 13:51:13 +0100 Subject: [PATCH] Support markup in menu command --- src/commands.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 08af1efd..034dd483 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1386,7 +1386,8 @@ const CommandDesc menu_cmd = { "menu and execute commands for the selected item", ParameterDesc{ { { "auto-single", { false, "instantly validate if only one item is available" } }, - { "select-cmds", { false, "each item specify an additional command to run when selected" } } } + { "select-cmds", { false, "each item specify an additional command to run when selected" } }, + { "markup", { false, "parse menu entries as markup text" } } } }, CommandFlags::None, CommandHelper{}, @@ -1394,6 +1395,7 @@ const CommandDesc menu_cmd = { [](const ParametersParser& parser, Context& context) { const bool with_select_cmds = (bool)parser.get_switch("select-cmds"); + const bool markup = (bool)parser.get_switch("markup"); const size_t modulo = with_select_cmds ? 3 : 2; const size_t count = parser.positional_count(); @@ -1411,7 +1413,8 @@ const CommandDesc menu_cmd = { Vector select_cmds; for (int i = 0; i < count; i += modulo) { - choices.push_back({ parser[i], {} }); + choices.push_back(markup ? parse_display_line(parser[i]) + : DisplayLine{ parser[i], {} }); commands.push_back(parser[i+1]); if (with_select_cmds) select_cmds.push_back(parser[i+2]);