Implement more sophisticated readline-mode

This commit is contained in:
2021-11-04 13:40:42 -04:00
parent cf5a2d7462
commit deaf4e4873
7 changed files with 150 additions and 64 deletions

View File

@@ -144,6 +144,10 @@ public:
//
void set_readline(bool enabled);
// Set the prompt for readline mode.
//
void set_prompt(const std::string &prompt);
// You may delete any channel except for stdio. This closes
// the channel.
//
@@ -155,10 +159,11 @@ private:
//
Channel(DrivenEngine *de, int chid, int port, const std::string &target);
int readline_space() { return READLINE_MAX - readline_len_; }
int echo_space() { return READLINE_MAX - echo_len_; }
void feed_readline(int nbytes, const char *bytes);
void peek_outgoing(int *nbytes, const char **bytes);
void sent_outgoing(int nbytes);
void show_command();
void hide_command();
private:
static const int READLINE_MAX=512;
@@ -170,12 +175,16 @@ private:
bool closed_;
std::string error_;
std::string target_;
char readline_buf_[READLINE_MAX];
int readline_len_;
// Readline stuff.
std::string desired_command_;
std::string current_command_;
std::string desired_prompt_;
std::string current_prompt_;
std::string readline_echo_;
char readline_lastc_;
char echo_buf_[READLINE_MAX];
int echo_len_;
bool readline_enabled_;
friend class DrivenEngine;
};