Add Delete line to terminal prompt

This commit is contained in:
Ethan Atkins 2019-12-10 11:56:59 -08:00
parent 2e3a1e767d
commit 293e83ef9f
2 changed files with 4 additions and 1 deletions

View File

@ -106,6 +106,7 @@ object ConsoleAppender {
private[sbt] def cursorUp(n: Int): String = s"\u001B[${n}A"
private[sbt] def cursorDown(n: Int): String = s"\u001B[${n}B"
private[sbt] def scrollUp(n: Int): String = s"\u001B[${n}S"
private[sbt] def clearScreen(n: Int): String = s"\u001B[${n}J"
private[sbt] final val DeleteLine = "\u001B[2K"
private[sbt] final val CursorLeft1000 = "\u001B[1000D"
private[sbt] final val CursorDown1 = cursorDown(1)

View File

@ -23,7 +23,9 @@ private[sbt] final class ConsoleChannel(val name: String) extends CommandChannel
val history = (s get historyPath) getOrElse (new File(s.baseDir, ".history")).some
val prompt = (s get shellPrompt) match {
case Some(pf) => pf(s)
case None => "> "
case None =>
def ansi(s: String): String = if (ConsoleAppender.formatEnabledInEnv) s"$s" else ""
s"${ansi(ConsoleAppender.DeleteLine)}> ${ansi(ConsoleAppender.clearScreen(0))}"
}
val reader =
new FullReader(history, s.combinedParser, JLine.HandleCONT, Terminal.throwOnClosedSystemIn)