LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-13-2008, 11:47 PM   #1
andrw123
Member
 
Registered: Aug 2008
Distribution: Slackware 12.1
Posts: 35

Rep: Reputation: 15
Input without pressing "Enter" in Lisp?


Is there a way I can get user input without having the user press the "Enter" key?

For example, say I give the user a menu with a single character representing each option, they could just press the single key and Lisp will accept the character. They would not have to press "Enter" afterwards.

I know there is a way to do this in C, but I am still new to Lisp and I couldn't find anything on how to do it.

By the way I am using the "CLISP" interpreter.

Thanks in advance.
 
Old 10-14-2008, 11:00 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
CLISP has a built-in interface to curses (or equivalent on windows):
http://clisp.cons.org/impnotes.html#screen

quick example:
Code:
(with-open-stream (wnd (screen:make-window))
  (ext:with-keyboard t ; the t is to make emacs indent nicer
    (format t "press any key: ")
    (format t "~%you entered '~a'~%"
            (character (read-char ext:*keyboard-input*)))))
 
Old 10-15-2008, 12:12 AM   #3
andrw123
Member
 
Registered: Aug 2008
Distribution: Slackware 12.1
Posts: 35

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ntubski View Post
CLISP has a built-in interface to curses (or equivalent on windows):
http://clisp.cons.org/impnotes.html#screen

quick example:
Code:
(with-open-stream (wnd (screen:make-window))
  (ext:with-keyboard t ; the t is to make emacs indent nicer
    (format t "press any key: ")
    (format t "~%you entered '~a'~%"
            (character (read-char ext:*keyboard-input*)))))
Wow, I had no idea. More stuff to play with.

Thanks,
Andrew
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
input of a character from console without pressing enter Bonny Programming 8 10-28-2008 04:50 PM
Repeated "input: AT Translated Set 2 keyboard as /class/input/input" messages AcerKev Mandriva 2 09-16-2007 08:35 AM
Pressing "v" turns up File Browser? J_K9 Ubuntu 3 07-13-2005 03:34 PM
error message when pressing "Next" "BIOS Problems" , help ! HeRCuLeSX Fedora 3 07-21-2004 02:37 PM
<input type="button" disabled="true" > does not work in ns4.7 or 4.9 cybercop12us Programming 2 11-29-2002 08:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration