Aha neat!

Just for reference to anyone who may want to use this to make a nice console-based Tetris etc., while in this tty mode repl-input-port *cannot* be used to drive the REPL. Though, it is ctrl+c sensitive.

(
Using the REPL in this mode does not do eval when pressing enter anymore, does not echo input, and when using any arrow keys shows:

> *** ERROR IN (console)@8.1 -- Illegal character: #\esc
)

So here's a nice example of 'clean' use of this feature:

> (begin (tty-mode-set! (repl-input-port) #t #f #t #f 0) (write (read-char)) (force-output) (write (read-char)) (force-output)(write (read-char)) (force-output)(write (read-char)) (force-output)(write (read-char)) (force-output)(write (read-char)) (force-output) (tty-mode-set! (repl-input-port) #t #t #f #f 0))
#\newline#\esc#\[#\A#\esc#\[>


Rather for completeness, how can add hooks to the switching of activity from the user code to Gambit REPL (on CTRL+C or exception) and back (by ,c)?


By adding hooks to that that switch the TTY between read-char-friendly mode and REPL-friendly, people can also debug their console-based Tetris:es nicely.

With warm regards,
Mikael

2013/1/2 Marc Feeley <feeley@iro.umontreal.ca>
Mikael, you need to change the tty mode :

> (tty-mode-set! (repl-input-port) #t #f #t #f 0)

The booleans indicate various settings (ctrl-c handling, input echo, raw input, raw output).

On UNIX, this changes the terminal's line discipline.  On Windows, it changes the console mode.

Marc


On 2013-01-02, at 11:59 AM, Mikael <mikael.rcv@gmail.com> wrote:

> Hi,
>
> In using read-char I get results only on a per input line basis. I was trying to switch the input console to byte/character mode instead of line buffered, though I didn't get any result with this.
>
> Any thought or suggestion?
>
> Mikael
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list@iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list