From 92be0221eac42864fdb4e60310758f4cae98a819 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 19 May 2009 18:24:09 +0000 Subject: Added :silent feature to disable automatic toSt... Added :silent feature to disable automatic toString calls in repl. --- src/compiler/scala/tools/nsc/Interpreter.scala | 6 +----- src/compiler/scala/tools/nsc/InterpreterLoop.scala | 11 +++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') 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. */ -- cgit v1.2.3