diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 15:02:57 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 15:02:57 +0100 |
commit | 953f18fe681a2f120dab5be9e9884bf35765e21e (patch) | |
tree | d0cc4812c2f8c95a773e938bf7c3576af40cd98d /frontend/rl.cpp | |
parent | 3562802cacc8dbd0c155146acfdb8d04c6440009 (diff) |
more WIP (command handling moved to player)
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; +} + |