void jl_input_line_callback(char *input) { int end=0, doprint=1; if (!input || ios_eof(ios_stdin)) { end = 1; rl_ast = NULL; } else if (!rl_ast) { // In vi mode, it's possible for this function to be called w/o a // previous call to return_callback. rl_ast = jl_parse_input_line(rl_line_buffer); } if (rl_ast != NULL) { doprint = !ends_with_semicolon(input); add_history_permanent(input); jl_putc('\n', jl_uv_stdout); free(input); } callback_en = 0; rl_callback_handler_remove(); handle_input(rl_ast, end, doprint); rl_ast = NULL; }
DLLEXPORT int jl_pututf8(uv_stream_t *s, uint32_t wchar ) { char buf[8]; if (wchar < 0x80) return jl_putc((int)wchar, s); size_t n = u8_toutf8(buf, 8, &wchar, 1); return jl_write(s, buf, n); }
DLLEXPORT void jl_clear_input(void) { //todo: how to do this better / the correct way / ??? //move the cursor to a clean line: char *p = rl_line_buffer; int i; for (i = 0; *p != '\0'; p++, i++) { if (i >= rl_point && *p == '\n') { jl_putc('\n', jl_uv_stdout); } } jl_putc('\n', jl_uv_stdout); jl_putc('\n', jl_uv_stdout); //reset state: rl_reset_line_state(); reset_indent(); rl_initialize(); //and redisplay prompt: rl_forced_update_display(); rl_on_new_line_with_prompt(); #ifdef __WIN32__ jl_write(jl_uv_stdout, "\e[4C", 4); //hack: try to fix cursor location #endif }