rascal icon indicating copy to clipboard operation
rascal copied to clipboard

Obtaining keyboard interrupts status on the Java side

Open rodinaarssen opened this issue 4 years ago • 2 comments
trafficstars

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:

  1. Create a Java method that computes sufficiently long and checks isCanceled; link it using the Java bridge.
  2. Call the Java function from a Rascal terminal
  3. Press Ctrl+C
  4. Observe that isCanceled does 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)

rodinaarssen avatar Jul 01 '21 07:07 rodinaarssen

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.

jurgenvinju avatar Jul 01 '21 08:07 jurgenvinju

The actual monitor I seem to obtain is a SaveWarningsMonitor.

rodinaarssen avatar Jul 01 '21 09:07 rodinaarssen