ConsoleView

scalata.infrastructure.view.terminal.cli.ConsoleView
final class ConsoleView[F[_]] extends GameView[F, String]

Console implementation of GameView.

Uses ANSI escape sequences to clear the screen and reads input via StdIn.readLine(), which is blocking.

Attributes

See also

GameView for method-level semantics

Graph
Supertypes
trait GameView[F, String]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def clearScreen: F[Unit]

Clear the entire screen / viewport.

Clear the entire screen / viewport.

On a terminal implementation this is usually an ANSI escape sequence; on Swing it might reset a text area; on web it may send a “clear” event.

Attributes

Definition Classes
override def display[String](text: String): F[Unit]

Render text or any printable value.

Render text or any printable value.

Implementations decide where to display: • console (println) • Swing text area • web socket, etc.

Attributes

Definition Classes
override def displayError[String](msg: String): F[Unit]

Show an error message to the player.

Show an error message to the player.

Recommended to prefix the text with "Error: " or apply red colour, but exact styling is up to the concrete adapter.

Attributes

Definition Classes
override def getInput: F[String]

Block (or suspend) until the next player command is available.

Block (or suspend) until the next player command is available.

Implementations must: • return an empty/default value if the input source is closed; • guarantee that reads are safe to call repeatedly; • suspend in F rather than performing side effects eagerly.

Attributes

Definition Classes