Re: A problem with read-char

On Jun 6, 6:54 pm, meta.per...@xxxxxxxxx wrote:

Is it possible to make read-char behave like getch in ó when working
with interactive stream (*standard-input*)?
In SBCL read-char wants "enter" key to unhang from REPL, in C getchar
returns immediately after user press key on keyboard.
Probably is possible to run code that uses read-char with direct
console access, aside REPL?
C's getchar() reads and returns one byte from the stdin file stream.
stdin needs not to be your terminals input; Sometimes a terminal just
isn't there.
(same applies for *standard-input*)
In C & Common Lisp any read from a file stream may block;
If the ISO group on C (or the ANSI on common lisp) had standarized a
function similar to curses getch(), the portability of these languages
would get more limitted.
Thus, such function does not exist in either language.
Since you want to do something that might not be portable to a
microcontroller (but the benifit is the much more enhanced UI), use a
non-standard library, such as CL-ncurses.

Relevant Pages

  • Re: A problem with read-char
    ... Is it possible to make read-char behave like getch in С ... In SBCL read-char wants "enter" key to unhang from REPL, ... About the curses routine getch, ... Now, I don't know about SBCL,. ...
  • Re: (read) with timeout
    ... Windows. ... (return-from read-char-with-timeout (read-char stream)) ... Return to top loop level 0. ...
  • Re: Implementing REPL...
    ... line-buffering terminal with Gray streams. ... and then feed characters from this line one by one. ... name READ-CHAR, thinking that it should behave like getchin C programs... ... In what way do you think READ-CHAR differs from getch() in C programs? ...
  • Re: fflush(stdin)
    ... away all input characters waiting for getch() out of stdin. ... According to the C standard calling fflush() on an input ... If stream points to an output stream or an update stream ...
  • Re: two problems involving streams
    ... Whether to use READ-BYTE or READ-CHAR is determined by the stream ... FLEXI-STREAMS library for converting between the types of streams. ...