summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-05-19 18:24:09 +0000
committerPaul Phillips <paulp@improving.org>2009-05-19 18:24:09 +0000
commit92be0221eac42864fdb4e60310758f4cae98a819 (patch)
treeaef08a6c0f758dc2e97c3389571437dfc53e3782 /src
parent6d20b470c5b43c17a885615e1761190fab366096 (diff)
downloadscala-92be0221eac42864fdb4e60310758f4cae98a819.tar.gz
scala-92be0221eac42864fdb4e60310758f4cae98a819.tar.bz2
scala-92be0221eac42864fdb4e60310758f4cae98a819.zip
Added :silent feature to disable automatic toSt...
Added :silent feature to disable automatic toString calls in repl.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala6
-rw-r--r--src/compiler/scala/tools/nsc/InterpreterLoop.scala11
2 files changed, 10 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index b357e0569d..bf48b2bbe6 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -87,11 +87,7 @@ class Interpreter(val settings: Settings, out: PrintWriter)
this(settings, new NewLinePrintWriter(new ConsoleWriter, true))
/** whether to print out result lines */
- private var printResults: Boolean = true
-
- /** Be quiet. Do not print out the results of each
- * submitted command unless an exception is thrown. */
- def beQuiet { printResults = false }
+ private[nsc] var printResults: Boolean = true
/** Temporarily be quiet */
def beQuietDuring[T](operation: => T): T = {
diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
index ff74d5177b..15a57729fc 100644
--- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala
+++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
@@ -156,9 +156,10 @@ class InterpreterLoop(in0: Option[BufferedReader], out: PrintWriter) {
List(
NoArgs("help", "prints this help message", printHelp),
OneArg("load", "followed by a filename loads a Scala file", load),
- NoArgs("replay", "resets execution and replays all previous commands", replay),
+ NoArgs("power", "enable power user mode", power),
NoArgs("quit", "exits the interpreter", () => Result(false, None)),
- NoArgs("power", "enable power user mode", power)
+ NoArgs("replay", "resets execution and replays all previous commands", replay),
+ NoArgs("silent", "disable/enable automatic printing of results", verbosity)
)
}
@@ -266,6 +267,12 @@ class InterpreterLoop(in0: Option[BufferedReader], out: PrintWriter) {
interpreter.powerUser()
}
+ def verbosity() = {
+ val old = interpreter.printResults
+ interpreter.printResults = !old
+ out.println("Switched " + (if (old) "off" else "on") + " result printing.")
+ }
+
/** Run one command submitted by the user. Two values are returned:
* (1) whether to keep running, (2) the line to record for replay,
* if any. */