Skip to content

Commit

Permalink
Flush stdout (#187)
Browse files Browse the repository at this point in the history
* Ensure stdout is flushed after a print

* Flush after the other stdout

* Fix compilation
  • Loading branch information
0xTim authored Sep 26, 2023
1 parent dcaea6c commit d4b580e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/ConsoleKit/Terminal/ANSI.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

/// Terminal ANSI commands
enum ANSICommand {
case eraseScreen
Expand Down Expand Up @@ -43,6 +45,7 @@ extension Terminal {
func command(_ command: ANSICommand) {
guard enableCommands else { return }
Swift.print(command.ansi, terminator: "")
fflush(stdout)
}
}

Expand Down
1 change: 1 addition & 0 deletions Sources/ConsoleKit/Terminal/Terminal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public final class Terminal: Console, Sendable {
output = text.description
}
Swift.print(output, terminator: terminator)
fflush(stdout)
}

/// See `Console`
Expand Down

0 comments on commit d4b580e

Please sign in to comment.