Skip to content

Commit

Permalink
Hide cursor while progressAnimation is running
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Jun 14, 2023
1 parent 5a54db1 commit e05b835
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@

### Changed
- Fix typo in enum name: renamed `Borders.TOM_BOTTOM` to `Borders.TOP_BOTTOM`. [(#100)](https://github.com/ajalt/mordant/issues/100)
- The terminal cursor will now be hidden when `progressAnimation` is running.

## 2.0.0-beta13
### Added
Expand Down
Expand Up @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit
class ProgressAnimationBuilder internal constructor() : ProgressBuilder() {
/**
* The maximum number of times per second to update idle animations like the progress bar pulse
* (default: 10fps)
* (default: 30fps)
*/
var animationFrameRate: Int = 30

Expand Down Expand Up @@ -89,7 +89,7 @@ private class ProgressHistory(windowLengthSeconds: Float, private val timeSource
* A pretty animated progress bar. Manages a timer thread to update the progress bar, so be sure to [stop] it when you're done.
*/
class ProgressAnimation internal constructor(
t: Terminal,
private val t: Terminal,
private val layout: ProgressLayout,
historyLength: Float,
private val ticker: Ticker,
Expand Down Expand Up @@ -148,6 +148,7 @@ class ProgressAnimation internal constructor(
@Synchronized
fun start() {
if (tickerStarted) return
t.cursor.hide(showOnExit = true)
tickerStarted = true
history.start()
ticker.start {
Expand All @@ -167,6 +168,7 @@ class ProgressAnimation internal constructor(
@Synchronized
fun stop() {
if (!tickerStarted) return
t.cursor.show()
tickerStarted = false
ticker.stop()
animation.stop()
Expand Down

0 comments on commit e05b835

Please sign in to comment.