Skip to content

Commit

Permalink
Draw only at start and end when dealing with non-tty
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Walker-GM committed May 9, 2023
1 parent b8c0397 commit 1f5b68b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/tui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ export class RedwoodTUI {
throw new Error('TUI has no reactive content')
}

// Only draw once if the TUI is not a TTY
if (!this.outStream.isTTY) {
this.drawReactive(true)
return
}

if (!this.manager.isHooked) {
// Take control of the terminal
this.manager.hook()
Expand All @@ -234,6 +240,12 @@ export class RedwoodTUI {
* @param clear If true, the last drawn content will be cleared
*/
stopReactive(clear = false) {
// If the TUI is not a TTY, draw one last time and return
if (!this.outStream.isTTY) {
this.drawReactive(true)
return
}

if (this.manager.isHooked) {
// Stop the draw loop
this.isReactive = false
Expand Down

0 comments on commit 1f5b68b

Please sign in to comment.