int run_repl(JSContextRef ctx) { global_ctx = ctx; current_ns = strdup("cljs.user"); current_prompt = form_prompt(current_ns, false); // Per-type initialization if (!config.dumb_terminal) { char *home = getenv("HOME"); if (home != NULL) { char history_name[] = ".planck_history"; int len = strlen(home) + strlen(history_name) + 2; history_path = malloc(len * sizeof(char)); snprintf(history_path, len, "%s/%s", home, history_name); linenoiseHistoryLoad(history_path); // TODO: load keymap } linenoiseSetMultiLine(1); linenoiseSetCompletionCallback(completion); linenoiseSetHighlightCallback(highlight); linenoiseSetHighlightCancelCallback(highlight_cancel); } run_cmdline_loop(ctx); return exit_value; }
int run_repl() { repl_t *repl = make_repl(); s_repl = repl; repl->current_ns = strdup("cljs.user"); repl->current_prompt = form_prompt(repl->current_ns, false); // Per-type initialization if (!config.dumb_terminal) { char *home = getenv("HOME"); if (home != NULL) { char history_name[] = ".planck_history"; size_t len = strlen(home) + strlen(history_name) + 2; repl->history_path = malloc(len * sizeof(char)); snprintf(repl->history_path, len, "%s/%s", home, history_name); linenoiseHistoryLoad(repl->history_path); exit_value = load_keymap(home); if (exit_value != EXIT_SUCCESS) { return exit_value; } } linenoiseSetMultiLine(1); linenoiseSetCompletionCallback(completion); linenoiseSetHighlightCallback(highlight); linenoiseSetHighlightCancelCallback(highlight_cancel); } if (!config.dumb_terminal) { cljs_set_print_sender(&linenoisePrintNow); } if (config.socket_repl_port) { pthread_t thread; pthread_create(&thread, NULL, accept_connections, NULL); } run_cmdline_loop(repl); return exit_value; }