I've discovered some interesting behaviour - not necessarily a bug, and (if 
it is a bug) not necessarily a bug in Clojure.

Essentially, to emulate a 1970s user interface, I want to read single key 
strokes from the console. I've found two recipes online, both using the 
JLine java package:

http://stackoverflow.com/questions/13435541/reading-unbuffered-keyboard-input-in-clojure
http://stackoverflow.com/questions/3225025/single-character-console-input-in-java-clojure

One of these recipes uses Terminal.getTerminal(), the other uses new 
ConsoleReader(). What happens in my context (Debian on 64 bit Intel) is 
that as soon as an instance of either class is instantiated, echoing to the 
console ceases. If you do (obviously, with the jline jar on the classpath):

(import 'jline.Terminal)
(def term (Terminal/getTerminal))
(.initializeTerminal term)
(.enableEcho term)


(or the equivalent things with a ConsoleReader), every keystroke is echoed 
twice. But if you do

user=> ((..ddiissaabblleeEEcchhoo  tteerrmm))
^Jnil

one single further character gets echoed and then nothing more, unless you 
type (blindly) (.enableEcho term), when the double-echoing behaviour 
resumes. This is consistent - on my Debian box - with Clojure 1.2, Clojure 
1.3, and Clojure 1.5.1, all using jline 1.0. I haven't yet compiled up a 
little Java app to find out what happens without Clojure, and I haven't 
tried compiling a little command-line Clojure app, because I want to be 
able to read single characters in the context of the REPL, so if, as I 
hypothesise, jline is fighting with the REPL, proving whether it works 
outwith the context of the REPL doesn't really help me.

Has anyone else seen this behaviour? Is there any solution?

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to