Move readline functionality into device-independent code
This commit is contained in:
@@ -123,6 +123,20 @@ public:
|
||||
//
|
||||
bool closed() const { return closed_; }
|
||||
|
||||
// True if the channel is in readline mode.
|
||||
//
|
||||
// Stdio always starts with this enabled, other channels always start
|
||||
// with this disabled.
|
||||
//
|
||||
bool readline_enabled() const { return readline_enabled_; }
|
||||
|
||||
// Put the channel into readline mode.
|
||||
//
|
||||
// Caution: the channel better be coming from a raw tty, otherwise,
|
||||
// this is going to produce weird results.
|
||||
//
|
||||
void set_readline(bool enabled);
|
||||
|
||||
// You may delete any channel except for stdio. This closes
|
||||
// the channel.
|
||||
//
|
||||
@@ -134,7 +148,13 @@ 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);
|
||||
|
||||
private:
|
||||
static const int READLINE_MAX=512;
|
||||
DrivenEngine *driven_;
|
||||
int chid_;
|
||||
std::unique_ptr<StreamBuffer> sb_in_;
|
||||
@@ -142,6 +162,12 @@ private:
|
||||
int port_;
|
||||
bool closed_;
|
||||
std::string target_;
|
||||
char readline_buf_[READLINE_MAX];
|
||||
int readline_len_;
|
||||
char readline_lastc_;
|
||||
char echo_buf_[READLINE_MAX];
|
||||
int echo_len_;
|
||||
bool readline_enabled_;
|
||||
friend class DrivenEngine;
|
||||
};
|
||||
using UniqueChannel = std::unique_ptr<Channel>;
|
||||
|
||||
Reference in New Issue
Block a user