diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-17 01:00:57 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-17 01:00:57 +0000 |
commit | 363a1456f671323b35dcacf2c8b8eb39180b8a53 (patch) | |
tree | 553913c9a121fa5595a95d40e59c5d9f6944d64c /src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala | |
parent | b7fcc7c73e41b326fe4d85d81c49c50fa954c990 (diff) | |
download | scala-363a1456f671323b35dcacf2c8b8eb39180b8a53.tar.gz scala-363a1456f671323b35dcacf2c8b8eb39180b8a53.tar.bz2 scala-363a1456f671323b35dcacf2c8b8eb39180b8a53.zip |
Two annoying REPL things made less annoying:
* ctrl-C will no longer kill the repl unless you hit it again
* ctrl-Z will no longer make the repl useless because of jline
In the service of the first I wrote signal handling code, which we can
put to use in other ways as well. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala index 74b3c6ee48..7e4abd1d76 100644 --- a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala +++ b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala @@ -5,19 +5,24 @@ package scala.tools.nsc package interpreter + +import java.io.IOException +import java.nio.channels.ClosedByInterruptException import scala.util.control.Exception._ +import InteractiveReader._ /** Reads lines from an input stream */ trait InteractiveReader { - import InteractiveReader._ - import java.io.IOException protected def readOneLine(prompt: String): String val interactive: Boolean + def init(): Unit = () def readLine(prompt: String): String = { def handler: Catcher[String] = { - case e: IOException if restartSystemCall(e) => readLine(prompt) + case e: ClosedByInterruptException => error("Reader closed by interrupt.") + // Terminal has to be re-initialized after SIGSTP or up arrow etc. stop working. + case e: IOException if restartSystemCall(e) => init() ; readLine(prompt) } catching(handler) { readOneLine(prompt) } } @@ -34,7 +39,6 @@ trait InteractiveReader { Properties.isMac && (e.getMessage == msgEINTR) } - object InteractiveReader { val msgEINTR = "Interrupted system call" def createDefault(): InteractiveReader = createDefault(null) |