-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec09ec4
commit ea8f6ac
Showing
3 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package tofu.terminal | ||
|
||
import scala.io.AnsiColor | ||
|
||
object TerminalOps { | ||
def locate(x: Int, y: Int): String = s"\u001b[${y};${x}H" | ||
|
||
def clearScreen(): String = s"\u001b[2J\u001b[H" | ||
|
||
def getColor(color: String): String = color match { | ||
case "red" => AnsiColor.RED | ||
case "green" => AnsiColor.GREEN | ||
case "blue" => AnsiColor.BLUE | ||
case "yellow" => AnsiColor.YELLOW | ||
case "magenta" => AnsiColor.MAGENTA | ||
case "cyan" => AnsiColor.CYAN | ||
case "white" => AnsiColor.WHITE | ||
case "black" => AnsiColor.BLACK | ||
case "blink" => AnsiColor.BLINK | ||
case "bold" => AnsiColor.BOLD | ||
case "invisible" => AnsiColor.INVISIBLE | ||
case "reset" => AnsiColor.RESET | ||
case "reversed" => AnsiColor.REVERSED | ||
case "underlined" => AnsiColor.UNDERLINED | ||
case _ => throw new IllegalArgumentException(s"Unknown color '$color'") | ||
} | ||
|
||
def getBackgroundColor(color: String): String = color match { | ||
case "red" => AnsiColor.RED_B | ||
case "green" => AnsiColor.GREEN_B | ||
case "blue" => AnsiColor.BLUE_B | ||
case "yellow" => AnsiColor.YELLOW_B | ||
case "magenta" => AnsiColor.MAGENTA_B | ||
case "cyan" => AnsiColor.CYAN_B | ||
case "white" => AnsiColor.WHITE_B | ||
case "black" => AnsiColor.BLACK_B | ||
case "blink" => AnsiColor.BLINK | ||
case "bold" => AnsiColor.BOLD | ||
case "invisible" => AnsiColor.INVISIBLE | ||
case "reset" => AnsiColor.RESET | ||
case "reversed" => AnsiColor.REVERSED | ||
case "underlined" => AnsiColor.UNDERLINED | ||
case _ => throw new IllegalArgumentException(s"Unknown background color '$color'") | ||
} | ||
} |