rascal
rascal copied to clipboard
Obtaining keyboard interrupts status on the Java side
Describe the bug
There exists a method IEvaluatorContext::isInterrupted that yields true if Ctrl+C was pressed in the terminal. Without IEvaluatorContext, there does not seem to be a possibility to obtain this information. There is IRascalMonitor::isCanceled, but that does not have the same semantics. In fact, the current implementation of the former method in Evaluator is
return interrupt || isCanceled();
To Reproduce
Steps to reproduce the behavior:
- Create a Java method that computes sufficiently long and checks
isCanceled; link it using the Java bridge. - Call the Java function from a Rascal terminal
- Press Ctrl+C
- Observe that
isCanceleddoes not return true.
Expected behavior
I would like it to be possible to propagate keyboard interrupts over the Java bridge without IEvaluatorContext, either through isCanceled or through something else entirely.
Desktop (please complete the following information):
- Context: Eclipse 2020-03
- Rascal Version: 0.19.3 (latest release on unstable)
It depends on which IRascalMonitor is injected into the configuration of the evaluator how this works. So to fix this issue, for every context that a REPL runs in, we have to check how the CTRL+C effect is pushed down into the concrete implementation of IRascalMonitor.
The actual monitor I seem to obtain is a SaveWarningsMonitor.