diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-11-30 00:19:44 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-11-30 00:19:47 +0200 |
commit | bc1bc4adb246b08adee2144ce2c7e3784f7899f1 (patch) | |
tree | 297f1fde9102ffe8a76f84a9e4e4bdd181224f27 /contrib/epee/include | |
parent | Merge pull request #506 (diff) | |
parent | wallet: optional automatic refresh from the daemon (diff) | |
download | monero-bc1bc4adb246b08adee2144ce2c7e3784f7899f1.tar.xz |
Merge pull request #507
62e49a5 wallet: optional automatic refresh from the daemon (moneromooo-monero)
Diffstat (limited to 'contrib/epee/include')
-rw-r--r-- | contrib/epee/include/console_handler.h | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h index 0eff095e1..c6e7c857d 100644 --- a/contrib/epee/include/console_handler.h +++ b/contrib/epee/include/console_handler.h @@ -251,27 +251,33 @@ namespace epee m_stdin_reader.stop(); } + void print_prompt() + { + if (!m_prompt.empty()) + { + epee::log_space::set_console_color(epee::log_space::console_color_yellow, true); + std::cout << m_prompt; + if (' ' != m_prompt.back()) + std::cout << ' '; + epee::log_space::reset_console_color(); + std::cout.flush(); + } + } + private: template<typename t_cmd_handler> bool run(const std::string& prompt, const std::string& usage, const t_cmd_handler& cmd_handler, std::function<void(void)> exit_handler) { TRY_ENTRY(); bool continue_handle = true; + m_prompt = prompt; while(continue_handle) { if (!m_running) { break; } - if (!prompt.empty()) - { - epee::log_space::set_console_color(epee::log_space::console_color_yellow, true); - std::cout << prompt; - if (' ' != prompt.back()) - std::cout << ' '; - epee::log_space::reset_console_color(); - std::cout.flush(); - } + print_prompt(); std::string command; bool get_line_ret = m_stdin_reader.get_line(command); @@ -313,6 +319,7 @@ namespace epee private: async_stdin_reader m_stdin_reader; std::atomic<bool> m_running = {true}; + std::string m_prompt; }; @@ -447,6 +454,11 @@ namespace epee { return m_console_handler.run(boost::bind(&console_handlers_binder::process_command_str, this, _1), prompt, usage_string, exit_handler); } + + void print_prompt() + { + m_console_handler.print_prompt(); + } }; ///* work around because of broken boost bind */ |