aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/repl/ammonite/Protocol.scala
blob: e066050b68cc3edb68cdcc404f7a7d2e71f8bf30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package dotty.tools
package dotc
package repl
package ammonite.terminal

case class TermInfo(ts: TermState, width: Int)

trait TermAction
case class Printing(ts: TermState, stdout: String) extends TermAction
case class TermState(
  inputs: LazyList[Int],
  buffer: Vector[Char],
  cursor: Int,
  msg: Ansi.Str = ""
) extends TermAction

object TermState {
  def unapply(ti: TermInfo): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
    TermState.unapply(ti.ts)

  def unapply(ti: TermAction): Option[(LazyList[Int], Vector[Char], Int, Ansi.Str)] =
    ti match {
      case ts: TermState => TermState.unapply(ts)
      case _ => None
    }
}

case class ClearScreen(ts: TermState) extends TermAction
case object Exit extends TermAction
case class Result(s: String) extends TermAction