-
Notifications
You must be signed in to change notification settings - Fork 3
05 Staying on the current line
Vladyslav Pekker edited this page Dec 26, 2015
·
3 revisions
In the ClearPrintModule spells defines methods clearPrint
and clearPrintln
, which erase the characters in the current line and move the carrot to the beginning of the line, before calling print
or println
respectively:
object SpinningWheel {
import scala.concurrent._
def show()(implicit ec: ExecutionContext = ExecutionContext.Implicits.global): Unit = {
if (off) {
on = true
Future {
while (on) {
clearPrint('/'); Thread sleep 500
clearPrint('-'); Thread sleep 500
clearPrint('\\'); Thread sleep 500
}
clearPrintln()
}
}
}
def hide(): Unit = on = false
@volatile private var on: Boolean = false
private def off = !on
}
The defaults can be found in the reference.conf file and the Configuration wiki page shows how to override as well as retrieve them programmatically.