diff --git a/src/cli/REPL.cpp b/src/cli/REPL.cpp index 4d8d805..2048853 100644 --- a/src/cli/REPL.cpp +++ b/src/cli/REPL.cpp @@ -27,7 +27,7 @@ void REPL::readInput() { char* input; string accumulatedInput; - rl_pre_input_hook = prefillIndentation; + rl_pre_input_hook = preInputHook; while ((input = readline(getPrompt().c_str())) != nullptr) { accumulatedInput += string(input); @@ -77,14 +77,12 @@ void REPL::execute(string source) { Compiler::getInstance().clearExceptions(); } -int REPL::prefillIndentation(const char *text, int count) { +void REPL::prefillIndentation() { string indents(delimeterStack.size() * 2, ' '); rl_insert_text(indents.c_str()); rl_point = rl_end; rl_redisplay(); - - return 0; } string REPL::getPrompt() { diff --git a/src/cli/REPL.hpp b/src/cli/REPL.hpp index 97352b3..c76442d 100644 --- a/src/cli/REPL.hpp +++ b/src/cli/REPL.hpp @@ -13,7 +13,19 @@ namespace Theta { void readInput(); - static int prefillIndentation(const char *text, int count); + #ifdef __APPLE__ + static int preInputHook(const char *text, int count) { + prefillIndentation(); + return 0; + } + #else + static int preInputHook() { + prefillIndentation(); + return 0; + } + #endif + + static void prefillIndentation(); private: static stack delimeterStack;