ensure enableEcho called after jline.Terminal.getTerminal. fixes #460

This commit is contained in:
Mark Harrah 2012-05-19 18:20:19 -04:00
parent e5bedb3e14
commit eec347e2dd
2 changed files with 10 additions and 4 deletions

View File

@ -53,8 +53,9 @@ abstract class JLine extends LineReader
}
private object JLine
{
def terminal = jline.Terminal.getTerminal
def resetTerminal() = withTerminal { _ => jline.Terminal.resetTerminal }
// When calling this, ensure that enableEcho has been or will be called.
// getTerminal will initialize the terminal to disable echo.
private def terminal = jline.Terminal.getTerminal
private def withTerminal[T](f: jline.Terminal => T): T =
synchronized
{

View File

@ -35,8 +35,13 @@ object ConsoleLogger
}
private[this] def ansiSupported =
try { jline.Terminal.getTerminal.isANSISupported }
catch { case e: Exception => !isWindows }
try {
val terminal = jline.Terminal.getTerminal
terminal.enableEcho() // #460
terminal.isANSISupported
} catch {
case e: Exception => !isWindows
}
private[this] def os = System.getProperty("os.name")
private[this] def isWindows = os.toLowerCase.indexOf("windows") >= 0