Add support for > and >> prompts with new readline
This commit is contained in:
@@ -126,6 +126,10 @@ SharedChannel DrivenEngine::get_stdio_channel() {
|
||||
return stdio_channel_;
|
||||
}
|
||||
|
||||
void DrivenEngine::set_console_prompt(const eng::string &prompt) {
|
||||
console_prompt_ = prompt;
|
||||
}
|
||||
|
||||
util::LuaSourcePtr DrivenEngine::get_lua_source() {
|
||||
return std::move(lua_source_);
|
||||
}
|
||||
@@ -382,6 +386,11 @@ bool DrivenEngine::drv_get_outgoing_empty(uint32_t chid) const {
|
||||
return (v.size() == 0);
|
||||
}
|
||||
|
||||
void DrivenEngine::drv_get_console_prompt(uint32_t *len, const char **data) const {
|
||||
*len = console_prompt_.size();
|
||||
*data = console_prompt_.c_str();
|
||||
}
|
||||
|
||||
double DrivenEngine::drv_get_clock() const {
|
||||
return clock_;
|
||||
}
|
||||
@@ -497,6 +506,10 @@ static bool drv_get_outgoing_empty(EngineWrapper *w, uint32_t chid) {
|
||||
return w->engine->drv_get_outgoing_empty(chid);
|
||||
}
|
||||
|
||||
static void drv_get_console_prompt(EngineWrapper *w, uint32_t *len, const char **data) {
|
||||
return w->engine->drv_get_console_prompt(len, data);
|
||||
}
|
||||
|
||||
static double drv_get_clock(EngineWrapper *w) {
|
||||
return w->engine->drv_get_clock();
|
||||
}
|
||||
@@ -906,6 +919,7 @@ static void init_engine_wrapper_helper(EngineWrapper *w) {
|
||||
w->get_channel_released = drv_get_channel_released;
|
||||
w->get_outgoing = drv_get_outgoing;
|
||||
w->get_outgoing_empty = drv_get_outgoing_empty;
|
||||
w->get_console_prompt = drv_get_console_prompt;
|
||||
w->get_clock = drv_get_clock;
|
||||
w->get_rescan_lua_source = drv_get_rescan_lua_source;
|
||||
w->get_stop_driver = drv_get_stop_driver;
|
||||
|
||||
@@ -204,6 +204,10 @@ public:
|
||||
//
|
||||
std::ostream &stdostream() { return get_stdio_channel()->out()->ostream(); }
|
||||
|
||||
// Set the prompt for the console.
|
||||
//
|
||||
void set_console_prompt(const eng::string &prompt);
|
||||
|
||||
// Fetches the lua source, and takes ownership of it. The DrivenEngine
|
||||
// no longer contains the source after calling this.
|
||||
//
|
||||
@@ -262,6 +266,7 @@ public:
|
||||
bool drv_get_channel_released(uint32_t chid) const;
|
||||
void drv_get_outgoing(uint32_t chid, uint32_t *len, const char **data) const;
|
||||
bool drv_get_outgoing_empty(uint32_t chid) const;
|
||||
void drv_get_console_prompt(uint32_t *len, const char **data) const;
|
||||
double drv_get_clock() const;
|
||||
bool drv_get_rescan_lua_source() const;
|
||||
bool drv_get_stop_driver() const;
|
||||
@@ -294,6 +299,7 @@ private:
|
||||
bool rescan_lua_source_;
|
||||
double clock_;
|
||||
bool stop_driver_;
|
||||
eng::string console_prompt_;
|
||||
friend class Channel;
|
||||
};
|
||||
|
||||
|
||||
@@ -88,6 +88,10 @@ struct EngineWrapper {
|
||||
//
|
||||
bool (*get_outgoing_empty)(EngineWrapper *w, uint32_t chid);
|
||||
|
||||
// Get the console prompt.
|
||||
//
|
||||
void (*get_console_prompt)(EngineWrapper *w, uint32_t *len, const char **data);
|
||||
|
||||
// Get the clock.
|
||||
//
|
||||
// Get the current time. This is equal to the last value passed
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
channel_ = new_outgoing_channel("nocert:localhost:8085");
|
||||
|
||||
// Set the console prompt
|
||||
// get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
set_console_prompt(console_.get_prompt());
|
||||
|
||||
// The driver loads the lua source automatically.
|
||||
// However, we don't need it. Throw it out.
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
eng::string line = get_stdio_channel()->in()->readline();
|
||||
if (line == "") break;
|
||||
console_.add(line);
|
||||
// get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
set_console_prompt(console_.get_prompt());
|
||||
do_command(console_.get_command());
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
listen_port(8080);
|
||||
|
||||
// Set the console prompt.
|
||||
// get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
set_console_prompt(console_.get_prompt());
|
||||
}
|
||||
|
||||
void do_luainvoke_command(const util::StringVec &words) {
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
eng::string line = get_stdio_channel()->in()->readline();
|
||||
if (line == "") break;
|
||||
console_.add(line);
|
||||
// get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
set_console_prompt(console_.get_prompt());
|
||||
do_command(console_.get_command());
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
world_->run_unittests();
|
||||
actor_id_ = world_->create_login_actor();
|
||||
stdostream() << "Login actor ID: " << actor_id_ << std::endl;
|
||||
//get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
set_console_prompt(console_.get_prompt());
|
||||
}
|
||||
|
||||
void event_update()
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
eng::string line = get_stdio_channel()->in()->readline();
|
||||
if (line == "") break;
|
||||
console_.add(line);
|
||||
//get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
set_console_prompt(console_.get_prompt());
|
||||
do_command(console_.get_command());
|
||||
if (print_channeler_.channel(world_->get_printbuffer(actor_id_), stdostream())) {
|
||||
world_->invoke(print_channeler_.invocation(actor_id_));
|
||||
|
||||
Reference in New Issue
Block a user