Minor bugfix to drivenengine readline mode
This commit is contained in:
@@ -23,9 +23,9 @@ Channel::~Channel() {
|
|||||||
driven_->channels_[chid_] = nullptr;
|
driven_->channels_[chid_] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channel::show_or_hide_command() {
|
void Channel::show_or_hide_command(bool ignore_sb_out) {
|
||||||
// Decide if we should hide the command, and if so, do it.
|
bool sb_out_empty = (sb_out_->fill() == 0) || ignore_sb_out;
|
||||||
if ((!readline_enabled_) || (driven_->stop_driver_) || (sb_out_->fill() > 0)) {
|
if (!sb_out_empty || (!readline_enabled_) || (driven_->stop_driver_)) {
|
||||||
int ccsize = current_prompt_.size() + current_command_.size();
|
int ccsize = current_prompt_.size() + current_command_.size();
|
||||||
readline_echo_ += util::repeat_string("\b \b", ccsize);
|
readline_echo_ += util::repeat_string("\b \b", ccsize);
|
||||||
current_prompt_ = "";
|
current_prompt_ = "";
|
||||||
@@ -62,7 +62,7 @@ void Channel::show_or_hide_command() {
|
|||||||
|
|
||||||
void Channel::set_prompt(const std::string &p) {
|
void Channel::set_prompt(const std::string &p) {
|
||||||
desired_prompt_ = p;
|
desired_prompt_ = p;
|
||||||
show_or_hide_command();
|
show_or_hide_command(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channel::feed_readline(int nbytes, const char *bytes) {
|
void Channel::feed_readline(int nbytes, const char *bytes) {
|
||||||
@@ -72,7 +72,7 @@ void Channel::feed_readline(int nbytes, const char *bytes) {
|
|||||||
// Ignore newline immediately after carriage return.
|
// Ignore newline immediately after carriage return.
|
||||||
// Otherwise, crlf produces two newlines.
|
// Otherwise, crlf produces two newlines.
|
||||||
} else if ((c == '\r') || (c == '\n')) {
|
} else if ((c == '\r') || (c == '\n')) {
|
||||||
show_or_hide_command();
|
show_or_hide_command(true);
|
||||||
readline_echo_ = readline_echo_ + " \n";
|
readline_echo_ = readline_echo_ + " \n";
|
||||||
sb_in_->write_bytes(desired_command_);
|
sb_in_->write_bytes(desired_command_);
|
||||||
sb_in_->write_uint8('\n');
|
sb_in_->write_uint8('\n');
|
||||||
@@ -95,7 +95,7 @@ void Channel::feed_readline(int nbytes, const char *bytes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Channel::peek_outgoing(int *nbytes, const char **bytes) {
|
void Channel::peek_outgoing(int *nbytes, const char **bytes) {
|
||||||
show_or_hide_command();
|
show_or_hide_command(false);
|
||||||
if (readline_echo_.size() > 0) {
|
if (readline_echo_.size() > 0) {
|
||||||
*nbytes = readline_echo_.size();
|
*nbytes = readline_echo_.size();
|
||||||
*bytes = readline_echo_.c_str();
|
*bytes = readline_echo_.c_str();
|
||||||
@@ -123,7 +123,7 @@ void Channel::set_readline(bool e) {
|
|||||||
if (e != readline_enabled_) {
|
if (e != readline_enabled_) {
|
||||||
readline_enabled_ = e;
|
readline_enabled_ = e;
|
||||||
desired_command_ = "";
|
desired_command_ = "";
|
||||||
show_or_hide_command();
|
show_or_hide_command(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ private:
|
|||||||
void feed_readline(int nbytes, const char *bytes);
|
void feed_readline(int nbytes, const char *bytes);
|
||||||
void peek_outgoing(int *nbytes, const char **bytes);
|
void peek_outgoing(int *nbytes, const char **bytes);
|
||||||
void sent_outgoing(int nbytes);
|
void sent_outgoing(int nbytes);
|
||||||
void show_or_hide_command();
|
void show_or_hide_command(bool ignore_sb_out);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int READLINE_MAX=512;
|
static const int READLINE_MAX=512;
|
||||||
|
|||||||
Reference in New Issue
Block a user