Permalink
Browse files

Use jline for standalone version again

There are huge tradeoffs here. The worst of it, the way I see it, is
requiring us to keep the ugliness of reply.reader.jline and the
JlineInputReader around a bit longer. But that can be mitigated by
eliminating lots of duplication between reply.reader.jline and
simple-jline.

From the user perspective, we also have to choose between reading
multiple forms on the same line vs. decoupling jline and input-reading
via stuff like (read). There may be a way to do both, but I can't think
of one (that also works for multi-line forms).
  • Loading branch information...
1 parent 9f33f5a commit 2e953934e702428bbe402f60f09a21256b5eef32 @trptcolin committed Apr 6, 2013
Showing with 13 additions and 9 deletions.
  1. +9 −6 src/clj/reply/eval_modes/standalone.clj
  2. +0 −1 src/clj/reply/main.clj
  3. +4 −2 src/clj/reply/reader/jline.clj
@@ -3,18 +3,21 @@
[reply.eval-state :as eval-state]
[reply.exit :as exit]
[reply.initialization :as initialization]
+ [reply.reader.jline :as jline]
[reply.signals :as signals]))
(def reply-read
(fn [prompt exit]
(concurrency/starting-read!)
(binding [*ns* (eval-state/get-ns)]
- (print (str (ns-name *ns*) "=> "))
- (flush)
- (let [read-result (clojure.main/repl-read prompt exit)]
- (if (exit/done? exit read-result)
- exit
- read-result)))))
+ (let [result (jline/read prompt exit)]
+ (when-let [reader @jline/jline-reader]
+ (.clear (.getCursorBuffer reader))
+ (.restore (.getTerminal reader))
+ (.shutdown reader)
+ (reset! jline/jline-reader nil)
+ (reset! jline/jline-pushback-reader nil))
+ result))))
(def reply-eval
(concurrency/act-in-future
View
@@ -4,7 +4,6 @@
[reply.exit :as exit]
[reply.hacks.printing :as hacks.printing]
[reply.initialization :as initialization]
- ;[reply.reader.jline :as reader.jline]
[reply.signals :as signals]
[clojure.main]
[clojure.repl]
@@ -38,7 +38,9 @@
(or output-stream System/out))
history (FileHistory. (make-history-file history-file))
completer (jline.completion/make-completer
- reply.initialization/eval-in-user-ns #() *ns*)]
+ reply.initialization/eval-in-user-ns
+ #()
+ (str (ns-name *ns*)))]
(.setBlinkMatchingParen (.getKeys reader) true)
(.setHandleUserInterrupt reader true)
(doto reader
@@ -109,7 +111,7 @@
(fn []
(.redrawLine @jline-reader)
(.flush @jline-reader))
- ns)))
+ (str (ns-name ns)))))
(defmacro with-jline-in [& body]
`(do

0 comments on commit 2e95393

Please sign in to comment.