mirror of https://github.com/sbt/sbt.git
Merge pull request #5696 from eatkins/progress-blinking
Make progress lines blink less
This commit is contained in:
commit
6a29b7f927
|
|
@ -77,11 +77,11 @@ private[sbt] final class ProgressState(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private[util] def printPrompt(terminal: Terminal, printStream: PrintStream): Unit =
|
private[util] def getPrompt(terminal: Terminal): Array[Byte] = {
|
||||||
if (terminal.prompt != Prompt.Running && terminal.prompt != Prompt.Batch) {
|
if (terminal.prompt != Prompt.Running && terminal.prompt != Prompt.Batch) {
|
||||||
val prefix = if (terminal.isAnsiSupported) s"$DeleteLine$CursorLeft1000" else ""
|
val prefix = if (terminal.isAnsiSupported) s"$DeleteLine$CursorLeft1000" else ""
|
||||||
printStream.write(prefix.getBytes ++ terminal.prompt.render().getBytes)
|
prefix.getBytes ++ terminal.prompt.render().getBytes("UTF-8")
|
||||||
printStream.flush()
|
} else Array.empty
|
||||||
}
|
}
|
||||||
private[util] def write(
|
private[util] def write(
|
||||||
terminal: Terminal,
|
terminal: Terminal,
|
||||||
|
|
@ -91,15 +91,14 @@ private[sbt] final class ProgressState(
|
||||||
): Unit = {
|
): Unit = {
|
||||||
addBytes(terminal, bytes)
|
addBytes(terminal, bytes)
|
||||||
if (hasProgress) {
|
if (hasProgress) {
|
||||||
|
val toWrite = new ArrayBuffer[Byte]
|
||||||
terminal.prompt match {
|
terminal.prompt match {
|
||||||
case a: Prompt.AskUser if a.render.nonEmpty =>
|
case a: Prompt.AskUser if a.render.nonEmpty =>
|
||||||
printStream.print(DeleteLine + ClearScreenAfterCursor + CursorLeft1000)
|
toWrite ++= (DeleteLine + ClearScreenAfterCursor + CursorLeft1000).getBytes("UTF-8")
|
||||||
printStream.flush()
|
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
printStream.write(bytes)
|
toWrite ++= bytes
|
||||||
printStream.write(ClearScreenAfterCursor.getBytes("UTF-8"))
|
toWrite ++= ClearScreenAfterCursor.getBytes("UTF-8")
|
||||||
printStream.flush()
|
|
||||||
if (bytes.endsWith(lineSeparatorBytes)) {
|
if (bytes.endsWith(lineSeparatorBytes)) {
|
||||||
if (progressLines.get.nonEmpty) {
|
if (progressLines.get.nonEmpty) {
|
||||||
val lastLine = terminal.prompt match {
|
val lastLine = terminal.prompt match {
|
||||||
|
|
@ -107,10 +106,12 @@ private[sbt] final class ProgressState(
|
||||||
case _ => currentLine.getOrElse("")
|
case _ => currentLine.getOrElse("")
|
||||||
}
|
}
|
||||||
val lines = printProgress(terminal, lastLine)
|
val lines = printProgress(terminal, lastLine)
|
||||||
printStream.print(ClearScreenAfterCursor + lines)
|
toWrite ++= (ClearScreenAfterCursor + lines).getBytes("UTF-8")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printPrompt(terminal, printStream)
|
toWrite ++= getPrompt(terminal)
|
||||||
|
printStream.write(toWrite.toArray)
|
||||||
|
printStream.flush()
|
||||||
} else printStream.write(bytes)
|
} else printStream.write(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,8 +178,9 @@ private[sbt] object ProgressState {
|
||||||
val lastLine =
|
val lastLine =
|
||||||
if (isAskUser) terminal.prompt.render() else terminal.getLastLine.getOrElse("")
|
if (isAskUser) terminal.prompt.render() else terminal.getLastLine.getOrElse("")
|
||||||
state.padding.set(math.max(0, prevSize - currentLength))
|
state.padding.set(math.max(0, prevSize - currentLength))
|
||||||
state.printPrompt(terminal, ps)
|
val toWrite =
|
||||||
ps.print(state.printProgress(terminal, lastLine))
|
state.getPrompt(terminal) ++ state.printProgress(terminal, lastLine).getBytes("UTF-8")
|
||||||
|
ps.write(toWrite)
|
||||||
ps.flush()
|
ps.flush()
|
||||||
}
|
}
|
||||||
} else if (state.progressLines.get.nonEmpty) {
|
} else if (state.progressLines.get.nonEmpty) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue