mirror of https://github.com/sbt/sbt.git
Cleanup implementation of progress report
It was a bit cleaner to consolidate `extra` and (previousLines|info).length into prevLength and currentLength.
This commit is contained in:
parent
0b18ccebbd
commit
5cfab4c9a9
|
|
@ -373,20 +373,19 @@ class ConsoleAppender private[ConsoleAppender] (
|
|||
}
|
||||
|
||||
val width = ConsoleAppender.terminalWidth
|
||||
val extra: Int = info.foldLeft(0)(_ + terminalLines(width)(_))
|
||||
val currentLength = info.foldLeft(info.length)(_ + terminalLines(width)(_))
|
||||
val previousLines = progressLines.getAndSet(info)
|
||||
val prevExtra = previousLines.foldLeft(0)(_ + terminalLines(width)(_))
|
||||
val prevLength = previousLines.foldLeft(previousLines.length)(_ + terminalLines(width)(_))
|
||||
|
||||
val prevPadding = padding.get
|
||||
val newPadding =
|
||||
math.max(0, previousLines.length + prevExtra + prevPadding - info.length - extra)
|
||||
val newPadding = math.max(0, prevLength + prevPadding - currentLength)
|
||||
padding.set(newPadding)
|
||||
|
||||
deleteConsoleLines(newPadding)
|
||||
deleteConsoleLines(blankZone)
|
||||
info.foreach(i => out.println(i))
|
||||
|
||||
out.print(cursorUp(blankZone + info.length + newPadding + extra))
|
||||
out.print(cursorUp(blankZone + currentLength + newPadding))
|
||||
out.flush()
|
||||
}
|
||||
private def terminalLines(width: Int): String => Int =
|
||||
|
|
|
|||
Loading…
Reference in New Issue