How to read a single keystroke from a terminal (not Swing) in Clojure?
I tried several things, including various versions of the JLine library, but did not get them (see example below).
I will gladly accept a working Unix-only example (Mac, Linux, ...). Ideally, I would like to know how to disable buffering for both stdin and stdout.
Something is close here:
;; project.clj dependencies: ;; [[org.clojure/clojure "1.4.0"] ;; [jline/jline "2.8"]]) (ns slosh.core (:import [jline.console ConsoleReader]) (:gen-class)) (defn -main [] (println "start") (let [cr (ConsoleReader.)] (.readCharacter cr) (println "done")))
This prints "start", but does not respond to any input other than control-C.
Johnj
source share