So I have a full working prototype (at https://github.com/cgrand/unrepl) but I haven’t wrote the spec yet for the input part.
Clojure 1.9.0-alpha14
user=> (require 'unrepl.repl)
nil
user=> (unrepl.repl/start)
outputs:
[:unrepl/hello {:commands {:interrupt #unrepl/raw \u0003, :exit #unrepl/raw \u0004, :set-source #unrepl/raw [\u0010 #unrepl/edn (set-file-line-col #unrepl/param :unrepl/sourcename #unrepl/param :unrepl/line #unrepl/param :unrepl/col)]}}][:prompt {clojure.core/*warn-on-reflection* false, clojure.core/*ns* #unrepl/ns user}]
so this unrepl session supports three commands : :interrupt
, :exit
and :set-source
:interrupt
is documented as just sending \u0003
aka ^C
, let’s try
(while true (Thread/sleep 1000) (print "."))
[:out "." 2][:out "." 2][:out "." 2][:out "." 2][:out "." 2][:out "." 2]^C
[:interrupted nil 2]
Let’s see if elision works
(range)
[:eval (0 1 2 3 4 5 6 7 8 9 #ednrepl/... {:get #unrepl/raw "\u0010(... G__226)"}) 3][:prompt {clojure.core/*warn-on-reflection* false, clojure.core/*ns* #unrepl/ns user}]
^P(... G__226)
[:command (10 11 12 13 14 15 16 17 18 19 #ednrepl/... {:get #unrepl/raw "\u0010(... G__227)"}) 4][:prompt {clojure.core/*warn-on-reflection* false, clojure.core/*ns* #unrepl/ns user}]
^P(... G__227)
[:command (20 21 22 23 24 25 26 27 28 29 #ednrepl/... {:get #unrepl/raw "\u0010(... G__228)"}) 5][:prompt {clojure.core/*warn-on-reflection* false, clojure.core/*ns* #unrepl/ns user}]
(note: to enter control characters in a terminal you must ecsape them with ^V before (eg ^V^P to get ^P sent to the repl))