Add REPL history
diff --git a/Repl.cpp b/Repl.cpp
index 415602f..6137c19 100644
--- a/Repl.cpp
+++ b/Repl.cpp
@@ -44,16 +44,21 @@
return string;
}
+void Repl::addHistory(QString line)
+{
+ ReadLine::add_history(line.toUtf8());
+}
+
void Repl::start()
{
while (_running)
{
- QString line = readLine();
-
- line = line.trimmed();
+ QString line = readLine().trimmed();
QList<AstNode> expr;
+ addHistory(line);
+
if (trySpecialCase(line))
{}
else if (tryEvaluate(line, &expr))
@@ -80,7 +85,7 @@
if (okay)
{
- qDebug() << pprint(out);
+ qDebug().noquote() << pprint(out);
}
}
else
diff --git a/Repl.h b/Repl.h
index a4939d3..b3470f2 100644
--- a/Repl.h
+++ b/Repl.h
@@ -16,6 +16,7 @@
protected:
QString readLine();
+ void addHistory(QString line);
bool trySpecialCase(QString line);
bool tryEvaluate(QString line, QList<AstNode> *expr);