InteractionService#terminalWidth

Adds `def terminalWidth: Int` to InteractionService to wrap JLine 2 (or 3 in the future).

Fixes #3352
This commit is contained in:
Eugene Yokota 2017-07-24 22:44:18 -04:00
parent ac7b1498a9
commit f96c8b9668
2 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,6 @@
package sbt
import sbt.internal.util.SimpleReader
import sbt.internal.util.{ JLine, SimpleReader }
trait CommandLineUIService extends InteractionService {
override def readLine(prompt: String, mask: Boolean): Option[String] = {
@ -19,6 +19,10 @@ trait CommandLineUIService extends InteractionService {
case _ => false
}
}
override def terminalWidth: Int = JLine.usingTerminal(_.getWidth)
override def terminalHeight: Int = JLine.usingTerminal(_.getHeight)
}
object CommandLineUIService extends CommandLineUIService

View File

@ -13,5 +13,9 @@ abstract class InteractionService {
/** Ask the user to confirm something (yes or no) before continuing. */
def confirm(msg: String): Boolean
def terminalWidth: Int
def terminalHeight: Int
// TODO - Ask for input with autocomplete?
}