mirror of https://github.com/sbt/sbt.git
commit
540ee83f2a
|
|
@ -9,9 +9,11 @@ package sbt.internal.util
|
|||
|
||||
import jline.console.ConsoleReader
|
||||
import jline.console.history.{ FileHistory, MemoryHistory }
|
||||
import java.io.{ File, InputStream, FileInputStream, FileDescriptor, FilterInputStream }
|
||||
import java.io.{ File, FileDescriptor, FileInputStream, FilterInputStream, InputStream }
|
||||
|
||||
import complete.Parser
|
||||
import scala.concurrent.duration.Duration
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.annotation.tailrec
|
||||
|
||||
abstract class JLine extends LineReader {
|
||||
|
|
@ -120,12 +122,12 @@ private[sbt] object JLine {
|
|||
protected[this] val originalIn = new FileInputStream(FileDescriptor.in)
|
||||
|
||||
private[sbt] def makeInputStream(injectThreadSleep: Boolean): InputStream =
|
||||
if (injectThreadSleep) new InputStreamWrapper(originalIn, Duration("50 ms"))
|
||||
if (injectThreadSleep) new InputStreamWrapper(originalIn, 2.milliseconds)
|
||||
else originalIn
|
||||
|
||||
// When calling this, ensure that enableEcho has been or will be called.
|
||||
// TerminalFactory.get will initialize the terminal to disable echo.
|
||||
private def terminal = jline.TerminalFactory.get
|
||||
private[sbt] def terminal = jline.TerminalFactory.get
|
||||
|
||||
private def withTerminal[T](f: jline.Terminal => T): T =
|
||||
synchronized {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ trait CommandLineUIService extends InteractionService {
|
|||
}
|
||||
}
|
||||
|
||||
override def terminalWidth: Int = JLine.usingTerminal(_.getWidth)
|
||||
override def terminalWidth: Int = JLine.terminal.getWidth
|
||||
|
||||
override def terminalHeight: Int = JLine.usingTerminal(_.getHeight)
|
||||
override def terminalHeight: Int = JLine.terminal.getHeight
|
||||
}
|
||||
|
||||
object CommandLineUIService extends CommandLineUIService
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ object Graph {
|
|||
// [info] |
|
||||
// [info] +-quux
|
||||
def toAscii[A](top: A, children: A => Seq[A], display: A => String, defaultWidth: Int): String = {
|
||||
val maxColumn = math.max(JLine.usingTerminal(_.getWidth), defaultWidth) - 8
|
||||
val maxColumn = math.max(JLine.terminal.getWidth, defaultWidth) - 8
|
||||
val twoSpaces = " " + " " // prevent accidentally being converted into a tab
|
||||
def limitLine(s: String): String =
|
||||
if (s.length > maxColumn) s.slice(0, maxColumn - 2) + ".."
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ private[sbt] final class TaskProgress
|
|||
private[this] val isStopped = new AtomicBoolean(false)
|
||||
|
||||
override def initial(): Unit = {
|
||||
ConsoleAppender.setTerminalWidth(JLine.usingTerminal(_.getWidth))
|
||||
ConsoleAppender.setTerminalWidth(JLine.terminal.getWidth)
|
||||
}
|
||||
|
||||
override def afterReady(task: Task[_]): Unit = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue