本文整理汇总了C++中iface::displayer::show_comment方法的典型用法代码示例。如果您正苦于以下问题:C++ displayer::show_comment方法的具体用法?C++ displayer::show_comment怎么用?C++ displayer::show_comment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iface::displayer
的用法示例。
在下文中一共展示了displayer::show_comment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void pragma_environment_add::run(
const data::command::iterator& args_begin_,
const data::command::iterator& args_end_,
iface::displayer& displayer_
) const
{
const std::string cmd = tokens_to_string(args_begin_, args_end_);
_shell.store_in_buffer(cmd, displayer_);
if (is_environment_setup_command(args_begin_, args_end_))
{
displayer_.show_comment(
data::text(
"You don't need the environment add pragma to add this to the"
" environment. The following command does this as well:"
)
);
displayer_.show_cpp_code(cmd);
}
else
{
displayer_.show_comment(
data::text(
"Metashell (incorrectly) thinks that this command should execute a"
" metaprogram and would not add it to the environment without using"
" the \"environment add\" pragma. Please file a bug report containing"
" this command (" + cmd + ") at"
" https://github.com/sabel83/metashell/issues. Thank you."
)
);
}
}
示例2: run
void pragma_switch::run(const data::command::iterator&,
const data::command::iterator&,
const data::command::iterator& args_begin_,
const data::command::iterator& args_end_,
iface::displayer& displayer_) const
{
auto i = args_begin_;
if (i != args_end_)
{
const std::string v = i->value().value();
if (valid_argument(v))
{
++i;
if (i == args_end_)
{
_update(element_of(true_values, v));
}
else
{
displayer_.show_error("Invalid arguments after " + v + ": " +
tokens_to_string(i, args_end_).value());
}
}
else
{
displayer_.show_error("Invalid argument " + v + ". Valid values are: " +
valid_arguments());
}
}
displayer_.show_comment(
data::text(_name + " is " + (_query() ? "on" : "off")));
}
示例3: run
void pragma_config_load::run(const data::command::iterator&,
const data::command::iterator&,
const data::command::iterator& args_begin_,
const data::command::iterator& args_end_,
iface::displayer& displayer_) const
{
const data::shell_config_name name = data::shell_config_name(
tokens_to_string(args_begin_, args_end_).value());
const auto& configs = _shell.get_config().shell_configs();
const auto cfg = std::find_if(
configs.begin(), configs.end(),
[&name](const data::shell_config& cfg_) { return cfg_.name == name; });
if (cfg == configs.end())
{
throw exception("Config " + name + " not found.");
}
else
{
const auto old_config = _shell.get_config().active_shell_config().name;
_shell.get_config().activate(name);
try
{
_shell.rebuild_environment();
displayer_.show_comment(data::text("Switched to config " + name));
}
catch (const std::exception& e)
{
displayer_.show_error("Error loading config " + name + ": " + e.what());
restore_config(old_config, _shell);
}
catch (...)
{
displayer_.show_error("Error loading config " + name +
": unknown exception");
restore_config(old_config, _shell);
}
}
}
示例4: run
void pragma_help::run(const data::command::iterator&,
const data::command::iterator&,
const data::command::iterator& args_begin_,
const data::command::iterator& args_end_,
iface::displayer& displayer_) const
{
using boost::algorithm::join;
if (args_begin_ == args_end_)
{
display_all(displayer_, _pragma_handlers);
}
else
{
std::vector<std::string> args;
for (auto i = args_begin_; i != args_end_; ++i)
{
switch (i->category())
{
case data::token_category::whitespace:
case data::token_category::comment:
// skip token
break;
default:
args.push_back(i->value().value());
}
}
data::text help_text;
bool was_pragma = false;
for (const auto& h : _pragma_handlers)
{
if (prefix_of(args.begin(), args.end(), h.first.begin(), h.first.end()))
{
if (was_pragma)
{
help_text.paragraphs.push_back(data::paragraph(""));
}
else
{
was_pragma = true;
}
const std::string p_args = h.second.arguments();
help_text.paragraphs.push_back(
data::paragraph("#msh " + join(h.first, " ") +
(p_args.empty() ? std::string() : " " + p_args)));
help_text.paragraphs.push_back(
data::paragraph(h.second.description(), " "));
}
}
if (was_pragma)
{
displayer_.show_comment(help_text);
}
else
{
displayer_.show_error("Pragma " + join(args, " ") + " not found.");
}
}
}