Last active
June 4, 2020 11:42
-
-
Save dariathecracker/297b944df7898c7e4477b5a7f5b3c231 to your computer and use it in GitHub Desktop.
`Console` service in `TerminalLive`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ioleo.tictactoe.cli | |
import zio.console.Console | |
trait TerminalLive extends Terminal { | |
val console: Console.Service[Any] | |
final val terminal = new Terminal.Service[Any] { | |
val getUserInput = | |
console.getStrLn.orDie | |
def display(frame: String) = | |
for { | |
_ <- console.putStr(TerminalLive.ANSI_CLEARSCREEN) | |
_ <- console.putStrLn(frame) | |
} yield () | |
} | |
} | |
object TerminalLive { | |
val ANSI_CLEARSCREEN: String = | |
"\u001b[H\u001b[2J" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment