window: fix exiting from getString if helper indicates so

This commit is contained in:
Andrzej Rybczak
2014-08-27 01:48:40 +02:00
parent a7f3992c97
commit 1fc2ce2d3c
3 changed files with 14 additions and 6 deletions

View File

@@ -827,7 +827,7 @@ void ExecuteCommand::run()
{
Statusbar::msg(1, "Executing %s...", cmd_name.c_str());
bool res = cmd->binding().execute();
Statusbar::msg("Execution %s.", res ? "successful" : "unsuccessful");
Statusbar::msg("Execution of command '%s' %s.", cmd_name.c_str(), res ? "successful" : "unsuccessful");
}
else
Statusbar::msg("No command named \"%s\"", cmd_name.c_str());

View File

@@ -49,12 +49,18 @@ const char *base;
int read_key(FILE *)
{
size_t x;
bool done;
int result;
do
{
x = w->getX();
if (w->runGetStringHelper(rl_line_buffer))
if (w->runGetStringHelper(rl_line_buffer, &done))
{
if (done)
{
rl_done = 1;
return 0;
}
w->goToXY(x, start_y);
w->refresh();
}
@@ -656,11 +662,13 @@ bool Window::hasCoords(int &x, int &y)
# endif
}
bool Window::runGetStringHelper(const char *arg) const
bool Window::runGetStringHelper(const char *arg, bool *done) const
{
if (m_get_string_helper)
{
m_get_string_helper(arg);
bool continue_ = m_get_string_helper(arg);
if (done != nullptr)
*done = !continue_;
return true;
}
else

View File

@@ -265,7 +265,7 @@ struct Window
/// Run current GetString helper function (if defined).
/// @see getString()
/// @return true if helper was run, false otherwise
bool runGetStringHelper(const char *arg) const;
bool runGetStringHelper(const char *arg, bool *done) const;
/// Sets window's base color
/// @param fg foregound base color