From 5cdeffe3c4c53c06fcb83769d6a5d8b9c5afdc1b Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 26 Jun 2021 18:59:16 +0200 Subject: Fixture display: Inject a faster REPL The standard Guile REPL, especially with readline/colorized enabled, is only really suitable for humans. Computers can use something simpler, and faster. And which doesn't save all previous results. --- src/repl-connection.c | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/src/repl-connection.c b/src/repl-connection.c index dec9486..3dc1896 100644 --- a/src/repl-connection.c +++ b/src/repl-connection.c @@ -75,40 +75,14 @@ static char *strip_crap(const char *line_orig) } -static int find_reply(const char *line) -{ - const char *eq; - size_t eq_pos; - int i; - - if ( line[0] != '$' ) return 0; - - eq = strstr(line, " = "); - if ( eq == NULL ) return 0; - eq_pos = eq - line; - - for ( i=1; iprocess_func = process_func; repl->process_func_data = data; + repl_send(repl, "(let loop ()" + " (let ((line (read)))" + " (unless (eq? line 'exit)" + " (let ((res (eval line (interaction-environment))))" + " (unless (unspecified? res)" + " (write res)" + " (newline)))" + " (loop))))"); + g_input_stream_read_async(g_io_stream_get_input_stream(G_IO_STREAM(repl->conn)), repl->inbuf, 1023, G_PRIORITY_DEFAULT, NULL, input_ready, repl); @@ -246,5 +229,6 @@ int repl_closed(ReplConnection *repl) void repl_connection_close(ReplConnection *repl) { + repl_send(repl, "exit"); repl_send(repl, ",q"); } -- cgit v1.2.3