Skip to content

Commit

Permalink
Support synchronized update (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicDima committed Jun 4, 2024
1 parent be8adb1 commit e36abdc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## [Unreleased]

New:
- Nothing yet!
- Support synchronized terminal update for rendering.

Changed:
- Сhange `DrawScope#drawRect` API with the ability to draw with text characters and specify `DrawStyle` (`Fill` or `Stroke`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import kotlin.math.roundToInt
private const val ESC = "\u001B"
internal const val CSI = "$ESC["

internal const val ansiBeginSynchronizedUpdate = "$CSI?2026h"
internal const val ansiEndSynchronizedUpdate = "$CSI?2026l"

internal const val ansiReset = "${CSI}0"
internal const val clearLine = "${CSI}K"
internal const val cursorUp = "${CSI}F"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public suspend fun runMosaic(body: suspend MosaicScope.() -> Unit): Unit = corou
var displaySignal: CompletableDeferred<Unit>? = null
val applier = MosaicNodeApplier(rootNode) {
val render = rendering.render(rootNode)
platformDisplay(render)
platformDisplay("$ansiBeginSynchronizedUpdate$render$ansiEndSynchronizedUpdate")

displaySignal?.complete(Unit)
hasFrameWaiters = false
Expand Down

0 comments on commit e36abdc

Please sign in to comment.