Readd incomplete changes, now without missing apply method
This commit is contained in:
parent
0d797ea684
commit
517720c720
|
@ -126,23 +126,30 @@ case class Pause(millisec: Long) extends Slide
|
|||
case object PauseKey extends Slide
|
||||
case class Meta(contents: (Presentation, Int) => Slide) extends Slide
|
||||
|
||||
case class TypedCommand[T](exec: T => String, display: String, cmd: T) extends Slide:
|
||||
case class TypedCommand[T](exec: T => String, display: String, cmd: T, cmdIsHidden: Boolean, outputIsHidden: Boolean) extends Slide:
|
||||
private lazy val _output = exec(cmd)
|
||||
def output = _output
|
||||
|
||||
infix def showing (s: String): TypedCommand[T] = TypedCommand(exec, s, cmd)
|
||||
|
||||
def show() =
|
||||
prompt()
|
||||
Terminal.showCursor()
|
||||
typeCmd()
|
||||
print(output)
|
||||
Terminal.hideCursor()
|
||||
force()
|
||||
if ! cmdIsHidden then
|
||||
prompt()
|
||||
Terminal.showCursor()
|
||||
typeCmd()
|
||||
if ! outputIsHidden then
|
||||
print(output)
|
||||
if ! cmdIsHidden then
|
||||
Terminal.hideCursor()
|
||||
|
||||
def quickShow() =
|
||||
prompt()
|
||||
println(display)
|
||||
print(output)
|
||||
force()
|
||||
if ! cmdIsHidden then
|
||||
prompt()
|
||||
println(display)
|
||||
if ! outputIsHidden then
|
||||
print(output)
|
||||
|
||||
def prompt() = print(fansi.Color.LightGreen("user@host % "))
|
||||
def force() = _output
|
||||
|
@ -180,6 +187,10 @@ object TypedCommand:
|
|||
def apply(cmd: String*)(using Path): TypedCommand[Vector[String]] =
|
||||
TypedCommand(run, cmd.mkString(" "), cmd.toVector)
|
||||
|
||||
def apply[T](exec: T => String, display: String, cmd: T) =
|
||||
new TypedCommand(exec, display, cmd, false, false)
|
||||
|
||||
|
||||
def shell(cmd: String*)(using Path): TypedCommand[Vector[String]] =
|
||||
TypedCommand(runShell, cmd.mkString(" "), cmd.toVector)
|
||||
|
||||
|
|
Loading…
Reference in a new issue