The JLine story is indeed confusing.  I 
believe https://github.com/jline/jline2 is the current one you want ([jline 
"2.11"] in your project.clj deps).  See the forthcoming Clojure Cookbook 
recipe<https://github.com/clojure-cookbook/clojure-cookbook/blob/master/local-io/console/read-unbuffered-keystroke/read-unbuffered-keystroke.asciidoc>.
 
 If that recipe (or its trivial extension to echo repeated 
characters) indeed does not work correctly for you, now would be an 
excellent time to let people know so there is a chance to correct it before 
it goes to print!  

John

On Sunday, September 22, 2013 7:30:29 AM UTC-5, juan.facorro wrote:
>
> According to the JLine <https://github.com/jline/jline>'s source code 
> (v1.0) in 
> UnixTerminal.java<https://github.com/jline/jline/blob/jline-1.0/src/main/java/jline/UnixTerminal.java#L355>,
>  
> echo is disabled with the command *stty -echo* which disables all echoing 
> in the console (just tried it in a terminal since I wasn't familiar with 
> this command).  
>
> There are two projects for JLine in github <https://github.com/jline>, JLine 
> and JLine2. The latter seems to be actively mantained, but after digging a 
> little I found the same command is used when disabling echo in Unix 
> terminals, see 
> here<https://github.com/jline/jline2/blob/master/src/main/java/jline/UnixTerminal.java#L89>and
>  
> here<https://github.com/jline/jline2/blob/master/src/main/java/jline/internal/TerminalLineSettings.java#L76>
> .
>
> I don't know of a way you could go around that, but maybe someone can help 
> or suggest an alternative.
>
> HTH,
>
> J   
>
> On Saturday, September 21, 2013 12:49:29 AM UTC+8, Simon Brooke wrote:
>>
>> 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