[terminal] SimpleTerminalLinesCollector

GitOrigin-RevId: e15d3fcfa14dabe018f4fe057a0d8aae15ce88a3
This commit is contained in:
Vladimir Shefer
2024-08-08 16:27:10 +02:00
committed by intellij-monorepo-bot
parent 466a9b23a4
commit 7ffdfe2186

View File

@@ -0,0 +1,27 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.terminal.block.session.scraper
import com.jediterm.terminal.model.TerminalLine
import org.jetbrains.plugins.terminal.block.ui.normalize
internal class SimpleTerminalLinesCollector(
private val delegate: StringCollector,
) : TerminalLinesCollector {
override fun addLine(line: TerminalLine) {
line.forEachEntry { entry ->
val text = entry.text.normalize()
if (text.isNotEmpty() && !entry.isNul) {
delegate.write(text)
}
}
if (!line.isWrapped) {
delegate.newline()
}
}
override fun flush() {
delegate.buildText()
}
}