Make luaconsole even easier to use.
This commit is contained in:
@@ -32,9 +32,13 @@ public:
|
||||
|
||||
// Establish a connection to the server.
|
||||
channel_ = new_outgoing_channel("localhost:8085");
|
||||
|
||||
// Set the console prompt
|
||||
get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
}
|
||||
|
||||
void do_command(const util::StringVec &words) {
|
||||
if (words.empty()) return;
|
||||
stdostream() << "Command: ";
|
||||
for (const std::string &word : words) {
|
||||
stdostream() << word << " ";
|
||||
@@ -48,12 +52,8 @@ public:
|
||||
std::string line = get_stdio_channel()->in()->readline();
|
||||
if (line == "") break;
|
||||
console_.add(line);
|
||||
const util::StringVec &words = console_.words();
|
||||
if (!words.empty()) {
|
||||
do_command(words);
|
||||
console_.clear();
|
||||
}
|
||||
get_stdio_channel()->out()->write_bytes(console_.get_prompt());
|
||||
get_stdio_channel()->set_prompt(console_.get_prompt());
|
||||
do_command(console_.get_command());
|
||||
}
|
||||
|
||||
// Check for communication from server..
|
||||
|
||||
Reference in New Issue
Block a user