mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[terminal] SimpleTerminalLinesCollector
GitOrigin-RevId: e15d3fcfa14dabe018f4fe057a0d8aae15ce88a3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
466a9b23a4
commit
7ffdfe2186
@@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user