diff options
Diffstat (limited to 'frontend/rl.cpp')
-rw-r--r-- | frontend/rl.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/frontend/rl.cpp b/frontend/rl.cpp new file mode 100644 index 0000000..3e1cc37 --- /dev/null +++ b/frontend/rl.cpp @@ -0,0 +1,27 @@ +#include <cstdlib> +#include <cstdio> + +#include <readline/readline.h> +#include <readline/history.h> + +#include "rl.h" +#include "frontend/print.h" + +using namespace std; + +string rl() { + const char * PROMPT = "> "; + + char * input = readline(PROMPT); + SessionLog::get().append(PROMPT); + if (input == NULL) exit(EXIT_SUCCESS); // ctrl-d + string out = string(input); + if (out.size() > 0) add_history(input); + free(input); + + SessionLog::get().append(out); + SessionLog::get().append("\n"); + + return out; +} + |