From 91f8922f3aa375c8e8ec85895e311279dbeab5ff Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 16 Jan 2012 16:26:14 -0800 Subject: [PATCH] make terminalHeight and terminalWidth lazy vals, to avoid recomputing it all the time. (Also prevents repeated error messages on unsupported terminals.) --- src/main/scala/scalala/ScalalaConsole.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/scalala/ScalalaConsole.scala b/src/main/scala/scalala/ScalalaConsole.scala index 7747d33..cf0d564 100644 --- a/src/main/scala/scalala/ScalalaConsole.scala +++ b/src/main/scala/scalala/ScalalaConsole.scala @@ -56,7 +56,7 @@ object ScalalaConsole { } /** The width of the console, or 80 if it can't be discovered. */ - def terminalWidth : Int = { + lazy val terminalWidth : Int = { // this ugly try-catch is here to use scala's built-in jline, // which only exists in scala > 2.9 try { @@ -75,8 +75,9 @@ object ScalalaConsole { } } }; - - def terminalHeight : Int = { + + /** The height of the console, or 24 if it can't be discovered. */ + lazy val terminalHeight : Int = { // this ugly try-catch is here to use scala's built-in jline, // which only exists in scala > 2.9 try {