Load a local rc file.
This commit is contained in:
parent
c5a968ad24
commit
55bf0489d4
12
src/main.cpp
12
src/main.cpp
|
@ -3,6 +3,8 @@
|
||||||
#include <mpfr.h>
|
#include <mpfr.h>
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
#include "functions.hpp"
|
#include "functions.hpp"
|
||||||
|
@ -31,6 +33,15 @@ FUNCTION(request_precision) {
|
||||||
return LIBAB_SUCCESS;
|
return LIBAB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void run_rc(abacus& ab) {
|
||||||
|
std::ifstream rcfile("./.abcsrc");
|
||||||
|
std::ostringstream str;
|
||||||
|
if(rcfile.good()) {
|
||||||
|
str << rcfile.rdbuf();
|
||||||
|
ab.run(str.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
abacus ab;
|
abacus ab;
|
||||||
rl_bind_key('\t', rl_insert);
|
rl_bind_key('\t', rl_insert);
|
||||||
|
@ -82,6 +93,7 @@ int main() {
|
||||||
ab.add_operator_prefix("-", "negate");
|
ab.add_operator_prefix("-", "negate");
|
||||||
ab.add_operator_postfix("!", "factorial");
|
ab.add_operator_postfix("!", "factorial");
|
||||||
|
|
||||||
|
run_rc(ab);
|
||||||
while(!close_requested) {
|
while(!close_requested) {
|
||||||
char* data = readline(" > ");
|
char* data = readline(" > ");
|
||||||
std::string buffer(data);
|
std::string buffer(data);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user