Here's an “instant echo” application using JLine that will print an int corresponding to registered keystrokes structured as a Leiningen project:
project.clj :
(defproject con "1.0.0-SNAPSHOT" :description "FIXME: write" :main con.core :dependencies [[org.clojure/clojure "1.1.0"] [org.clojure/clojure-contrib "1.1.0"] [jline "0.9.94"]])
src/con/core.clj :
(ns con.core (:import jline.Terminal) (:gen-class)) (defn -main [& args] (let [term (Terminal/getTerminal)] (while true (println (.readCharacter term System/in)))))
This functionality is provided by the jline.Terminal class, which provides a static getTerminal method that returns an instance of a subclass for a specific platform that can be used to interact with the terminal. See Javadoc for more details.
Let's see how asdf looks ...
$ java -jar con-1.0.0-SNAPSHOT-standalone.jar 97 115 100 102
( Cc still kills the application, of course.)
Michał Marczyk
source share