Use set_mode! to change to raw (not-line-buffered) mode first and call
start reading. You may need to invoke process_events too

Or perhaps structure your algorithm to handle ^C and recover gracefully

Or run the code in a separate worker and send progress updates to the
controller

On Friday, April 4, 2014, John Myles White <johnmyleswh...@gmail.com> wrote:

> I'm trying to find a way to see if a user has typed anything into the REPL
> while a long-running computation takes place so that users can hit a
> special key to pause their computation and inspect its intermediate state.
>
> To get started, I wrote this snippet and tried to see if it would count
> input that I typed into the REPL:
>
> for i in 1:5
>     sleep(1)
>     println()
>     println(nb_available(STDIN))
> end
>
> It doesn't seem like STDIN receives the keystrokes I type while this loop
> is executing.
>
> How would one get access to those keystrokes in the current REPL? Should I
> be using some kind of interrupt handling instead?
>
>  -- John
>
>

Reply via email to