Skip to content

Instantly share code, notes, and snippets.

@dariathecracker
Last active June 4, 2020 11:42
Show Gist options
  • Save dariathecracker/297b944df7898c7e4477b5a7f5b3c231 to your computer and use it in GitHub Desktop.
Save dariathecracker/297b944df7898c7e4477b5a7f5b3c231 to your computer and use it in GitHub Desktop.
`Console` service in `TerminalLive`
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