diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-10-26 22:34:04 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-10-26 22:34:04 +0200 |
commit | 442c58e994b0fae67147fe21f94bfb7e72ace26b (patch) | |
tree | 533176d7ce85690f081c96e2f6b6c45d5320f5ad | |
parent | Merge pull request #4561 (diff) | |
parent | readline_buffer: fix "cursor in prompt" bug (diff) | |
download | monero-442c58e994b0fae67147fe21f94bfb7e72ace26b.tar.xz |
Merge pull request #4573
8f3c7937 readline_buffer: fix "cursor in prompt" bug (moneromooo-monero)
-rw-r--r-- | contrib/epee/include/readline_buffer.h | 1 | ||||
-rw-r--r-- | contrib/epee/src/readline_buffer.cpp | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/contrib/epee/include/readline_buffer.h b/contrib/epee/include/readline_buffer.h index 87c8826cb..5968d243d 100644 --- a/contrib/epee/include/readline_buffer.h +++ b/contrib/epee/include/readline_buffer.h @@ -27,6 +27,7 @@ namespace rdln private: std::streambuf* m_cout_buf; + size_t m_prompt_length; static std::vector<std::string>& completion_commands(); }; diff --git a/contrib/epee/src/readline_buffer.cpp b/contrib/epee/src/readline_buffer.cpp index 076a63612..da264471f 100644 --- a/contrib/epee/src/readline_buffer.cpp +++ b/contrib/epee/src/readline_buffer.cpp @@ -44,7 +44,7 @@ std::vector<std::string>& rdln::readline_buffer::completion_commands() } rdln::readline_buffer::readline_buffer() -: std::stringbuf(), m_cout_buf(NULL) +: std::stringbuf(), m_cout_buf(NULL), m_prompt_length(0) { current = this; } @@ -86,8 +86,11 @@ void rdln::readline_buffer::set_prompt(const std::string& prompt) if(m_cout_buf == NULL) return; boost::lock_guard<boost::mutex> lock(sync_mutex); + rl_set_prompt(std::string(m_prompt_length, ' ').c_str()); + rl_redisplay(); rl_set_prompt(prompt.c_str()); rl_redisplay(); + m_prompt_length = prompt.size(); } void rdln::readline_buffer::add_completion(const std::string& command) |