Skip to content

Commit

Permalink
Fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicDima committed Oct 27, 2024
1 parent 869b486 commit e86e22d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ New:
- Nothing yet!

Changed:
- Nothing yet!
- An empty line is not added at the end of the output.

Fixed:
- Nothing yet!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,27 @@ internal class AnsiRendering(

// don't need to move cursor up if there was zero or one line
if (lastHeight > 1) {
ansiMoveCursorUp(lastHeight - 1)
ansiMoveCursorUp(lastHeight - 1)
}
append(ansiMoveCursorToFirstColumn)

node.measureAndPlace()

var afterStatic = false // in order not to overwrite last line of static output
staticSurfaces.let { staticSurfaces ->
node.paintStatics(staticSurfaces, ansiLevel)
if (staticSurfaces.isNotEmpty()) {
staticSurfaces.forEach { staticSurface ->
appendSurface(staticSurface, addLineBreakAtBeginning = false)
if (!afterStatic && staticSurface.height > 0) {
afterStatic = true
}
}
staticSurfaces.clear()
}
}
var addLineBreakAtBeginning = false
staticSurfaces.let { staticSurfaces ->
node.paintStatics(staticSurfaces, ansiLevel)
if (staticSurfaces.isNotEmpty()) {
staticSurfaces.forEach { staticSurface ->
appendSurface(staticSurface, addLineBreakAtBeginning)
if (!addLineBreakAtBeginning && staticSurface.height > 0) {
addLineBreakAtBeginning = true
}
}
staticSurfaces.clear()
}
}

val surface = node.paint(ansiLevel)
if (node.height > 0) {
appendSurface(surface, addLineBreakAtBeginning = afterStatic)
appendSurface(surface, addLineBreakAtBeginning)
}
lastHeight = surface.height

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ class AnsiRenderingTest {

assertThat(rendering.render(rootNode).toString()).isEqualTo(
"""
|${ansiMoveCursorToFirstColumn}One $ansiClearLineAfterCursor
|Two $ansiClearLineAfterCursor
|${ansiMoveCursorToFirstColumn}One$ansiClearLineAfterCursor
|Two$ansiClearLineAfterCursor
|Three$ansiClearLineAfterCursor
|Four $ansiClearLineAfterCursor
|Five $ansiClearLineAfterCursor
|Four$ansiClearLineAfterCursor
|Five$ansiClearLineAfterCursor
|Sup$ansiClearLineAfterCursor$ansiClearAllAfterCursor
""".trimMargin().wrapWithAnsiSynchronizedUpdate().replaceLineEndingsWithCRLF(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ private class RealTestMosaicComposition(
} else {
rendering.render(rootNode).toString()
.removeSurrounding(ansiBeginSynchronizedUpdate, ansiEndSynchronizedUpdate)
.replace(Regex("$ESC\\[\\d+A"), "")
.removePrefix(ansiMoveCursorToFirstColumn)
.removePrefix(ansiClearAllAfterCursor)
.replace(ansiClearLineAfterCursor, "")
.replace(Regex("$ESC\\[\\d+A"), "")
.removePrefix(ansiMoveCursorToFirstColumn)
.removeSuffix(ansiClearAllAfterCursor)
.replace(ansiClearLineAfterCursor, "")
.replace("\r\n", "\n") // CRLF to LF for simplicity
}
renderSnapshots.trySend(stringRender)
Expand Down
2 changes: 1 addition & 1 deletion samples/rrtop/src/main/kotlin/example/RrtopApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun RrtopApp(rrtopViewModel: RrtopViewModel, colorsPalette: RrtopColorsPalette)
CompositionLocalProvider(LocalRrtopColorsPalette provides colorsPalette) {
Box(
modifier = Modifier
.size(terminal.size)
.size(terminal.size)
.background(LocalRrtopColorsPalette.current.mainBg)
.onKeyEvent {
when (it) {
Expand Down

0 comments on commit e86e22d

Please sign in to comment.