in app/packer/PackerOutputParser.scala [48:81]
private def parseAnsiColouredString(message: String): Seq[MessagePart] = {
val it = AnsiColouredPart.findAllIn(message)
val parts = ArrayBuffer.empty[MessagePart]
var previousEndIndex = 0
while (it.hasNext) {
it.next()
if (it.start > previousEndIndex) {
// Add any non-coloured part between the end of the previous coloured part
// and the start of this one
parts += MessagePart(
message.substring(previousEndIndex, it.start),
MessagePart.defaultColour
)
}
val colourCode = it.group(1)
val colour = AnsiColours.getOrElse(colourCode, MessagePart.defaultColour)
val text = it.group(2)
parts += MessagePart(text, colour)
previousEndIndex = it.end
}
if (previousEndIndex < message.length) {
// Add any non-coloured part after the final coloured part
parts += MessagePart(
message.substring(previousEndIndex),
MessagePart.defaultColour
)
}
parts.toSeq
}