animateInCoroutine

fun <T> ProgressBarDefinition<T>.animateInCoroutine(terminal: Terminal, context: T, total: Long? = null, completed: Long = 0, start: Boolean = true, visible: Boolean = true, clearWhenFinished: Boolean = false, speedEstimateDuration: Duration = 30.seconds, timeSource: TimeSource.WithComparableMarks = TimeSource.Monotonic, maker: ProgressBarWidgetMaker = MultiProgressBarWidgetMaker): CoroutineProgressTaskAnimator<T>

Create a progress bar animation that runs in a coroutine.

Example

val animation = progressBarContextLayout<String> { ... }.animateInCoroutine(terminal, "context")
launch { animation.execute() }
animation.update { ... }

Parameters

terminal

The terminal to draw the progress bar to

context

The context to pass to the task

total

The total number of steps needed to complete the progress task, or null if it is indeterminate.

completed

The number of steps currently completed in the progress task.

start

If true, start the task immediately.

visible

If false, the task will not be drawn to the screen.

clearWhenFinished

If true, the animation will be cleared when all tasks are finished. Otherwise, the animation will stop when all tasks are finished, but remain on the screen.

speedEstimateDuration

The duration over which to estimate the speed of the progress tasks. This estimate will be a rolling average over this duration.

timeSource

The time source to use for the animation.

maker

The widget maker to use to lay out the progress bars.


fun ProgressBarDefinition<Unit>.animateInCoroutine(terminal: Terminal, total: Long? = null, completed: Long = 0, start: Boolean = true, visible: Boolean = true, clearWhenFinished: Boolean = false, speedEstimateDuration: Duration = 30.seconds, timeSource: TimeSource.WithComparableMarks = TimeSource.Monotonic, maker: ProgressBarWidgetMaker = MultiProgressBarWidgetMaker): CoroutineProgressTaskAnimator<Unit>

Create a progress bar animation for a single task that runs synchronously.

Example

val animation = progressBarLayout { ... }.animateInCoroutine(terminal)
launch { animation.execute() }
animation.update { ... }

Parameters

terminal

The terminal to draw the progress bar to

total

The total number of steps needed to complete the progress task, or null if it is indeterminate.

completed

The number of steps currently completed in the progress task.

start

If true, start the task immediately.

visible

If false, the task will not be drawn to the screen.

clearWhenFinished

If true, the animation will be cleared when all tasks are finished. Otherwise, the animation will stop when all tasks are finished, but remain on the screen.

speedEstimateDuration

The duration over which to estimate the speed of the progress tasks. This estimate will be a rolling average over this duration.

timeSource

The time source to use for the animation.

maker

The widget maker to use to lay out the progress bars.


inline fun Animation<Unit>.animateInCoroutine(fps: Int = 30, crossinline finished: () -> Boolean = { false }): CoroutineAnimator

Create an animator that runs this animation in a coroutine.

Example

val animation = terminal.animation<Unit> { ... }.animateInCoroutine(terminal)
launch { animation.execute() }

Create an animator that runs this animation in a coroutine.

Example

val animator = animation.animateInCoroutine(terminal)
launch { animator.execute() }

Create an animator that runs this animation in a coroutine.

Example

val animator = animation.animateInCoroutine()
launch { animator.execute() }