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()); Statusbar::msg(1, "Executing %s...", cmd_name.c_str());
bool res = cmd->binding().execute(); 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 else
Statusbar::msg("No command named \"%s\"", cmd_name.c_str()); Statusbar::msg("No command named \"%s\"", cmd_name.c_str());

View File

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

View File

@@ -265,8 +265,8 @@ struct Window
/// Run current GetString helper function (if defined). /// Run current GetString helper function (if defined).
/// @see getString() /// @see getString()
/// @return true if helper was run, false otherwise /// @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 /// Sets window's base color
/// @param fg foregound base color /// @param fg foregound base color
/// @param bg background base color /// @param bg background base color