blob: 3ce360f6e4369bea8f31bd71a7ba9e6244e9648b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <cstdlib>
#include <cstdio>
#include <readline/readline.h>
#include <readline/history.h>
#include "rl.h"
#include "backend/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.c_str());
SessionLog::get().append("\n");
return out;
}
|