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

@@ -1,6 +1,5 @@
#include "drivertests.hpp"
#include "drivenengine.hpp"
#include <iostream>
#include <iomanip>
static void write_closed_message(Channel *ch, StreamBuffer *out) {
@@ -107,17 +106,23 @@ public:
// This test just prints the time.
class DriverPrintClockTest : public DrivenEngine {
public:
int count;
int count_;
double last_clock_;
virtual void event_init(int argc, char *argv[]) {
count = 0;
count_ = 0;
last_clock_ = 0.0;
}
virtual void event_update() {
std::cerr << std::fixed << std::setprecision(2) << get_clock() << " ";
count++;
if (count == 10) {
std::cerr << std::endl;
count = 0;
double clock = get_clock();
if (clock > last_clock_ + 0.5) {
stdostream() << std::fixed << std::setprecision(2) << clock << " ";
count_++;
last_clock_ = clock;
}
if (count_ == 10) {
stdostream() << std::endl;
count_ = 0;
}
}
};