Scryer-prolog: Ctrl-c should interrupt get_single_char/1

Created on 5 May 2020  路  6Comments  路  Source: mthom/scryer-prolog

Currently, I get:

?- use_module(library(charsio)).
   true.
?- get_single_char(C).
(press Ctrl-c)
   C = c.

Expected: Interruption, yielding for example caught: error('$interrupt_thrown',repl).

Is it possible to implement this? One use case is interrupting animations of search processes, where get_single_char/1 is used for intermediate pausing.

Most helpful comment

Is it caught: error('$interrupt_thrown',repl)
or caught: error('$interrupt_thrown',get_single_char/1)?

The interrupt is caught by the REPL, typically.

All 6 comments

Another test case:

?- repeat, get_single_char(C), false.

Currently, it is not possible to interrupt this.

Is it caught: error('$interrupt_thrown',repl)
or caught: error('$interrupt_thrown',get_single_char/1)?

Is it caught: error('$interrupt_thrown',repl)
or caught: error('$interrupt_thrown',get_single_char/1)?

The interrupt is caught by the REPL, typically.

I have an implementation but get_single_char/1 is the one throwing error. Will make a PR for this.

That would be perfect! Thank you a lot!

Brilliantly resolved by @notoria in #460. Many thanks!

queens.pl now works very nicely, piping output to Ghostscript:

$ scryer-prolog -g 'show(20,[ff])' queens.pl | \
     gs -dNOPROMPT -g680x680 -dGraphicsAlphaBits=2 -r144 -q

Press any key to show the next solution. And now the animation can be nicely interrupted with Ctrl-c, followed by Ctrl-d to exit the Prolog process. Thank you again!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XVilka picture XVilka  路  3Comments

UWN picture UWN  路  3Comments

mkohlhaas picture mkohlhaas  路  3Comments

triska picture triska  路  3Comments

triska picture triska  路  3Comments