Welcome! Please see the About page for a little more info on how this works.

0 votes
in IO by

As a learning exercise I'm making a terminal based interactive program (a game). I want the program to process input one character at a time. Every time a user presses a button, the program processes it and gives output. I couldn't find a way to do it using standard library. I know read and read-line functions but they take an entire line (until enter is pressed). That is not what I want. I searched online and found this solution that uses jline3 Java library: https://stackoverflow.com/questions/58571928/how-can-i-read-a-single-character-from-stdin-in-clojure. I tried to follow it but when I run my program I'm getting the following warning and error.

WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information) Exception in thread "main" Syntax error compiling at (/private/var/folders/nt/26pz2dqj4y70z38vrtgd8t4m0000gn/T/form-init7411586405251765923.clj:1:125). Caused by: java.lang.IllegalArgumentException: No matching field found: read for class org.jline.terminal.impl.DumbTerminal

I don't know how to enable debug logging. I'm working on OSX and iTerm2. I have asked the same question here https://clojureverse.org/t/reading-standard-input-one-character-at-a-time/5354?u=jewiet

1 Answer

+1 vote
by

This is not really an answer to your question, but you might find it helpful to use https://github.com/theophilusx/tui or https://github.com/MultiMUD/clojure-lanterna which probably covers a lot of the lower level terminal stuff for you and would let you focus on your game.

by
Thank you for your reply. I worked around the problem using lanterna library. I wrote a short description of the answer in clojureverse.org.

https://clojureverse.org/t/reading-standard-input-one-character-at-a-time/5354/2?u=jewiet
...