From 1fc2ce2d3cb1c9e31e2c1e2ac4f41b3e454d8c38 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 27 Aug 2014 01:48:40 +0200 Subject: [PATCH] window: fix exiting from getString if helper indicates so --- src/actions.cpp | 2 +- src/window.cpp | 14 +++++++++++--- src/window.h | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index b9719d13..9c58534c 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -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()); diff --git a/src/window.cpp b/src/window.cpp index 7121dd66..c226d3f9 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -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 diff --git a/src/window.h b/src/window.h index 2fa62d77..a8273bd9 100644 --- a/src/window.h +++ b/src/window.h @@ -265,8 +265,8 @@ 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 /// @param bg background base color