Guest User

Untitled

a guest
Mar 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. package server
  2.  
  3. enum class Color(val fg: String, val bg: String) {
  4. BLACK("30", "40"),
  5. RED("31", "41"),
  6. GREEN("32", "42"),
  7. YELLOW("33", "43"),
  8. BLUE("34", "44"),
  9. MAGENTA("35", "45"),
  10. CYAN("36", "46"),
  11. WHITE("37", "47")
  12. }
  13.  
  14. private fun String.color(color: Color): String {
  15. return "\u001B[${color.fg}m${this}\u001B[39m"
  16. }
  17.  
  18. fun String.red(): String {
  19. return color(Color.RED)
  20. }
  21.  
  22. fun String.black(): String {
  23. return color(Color.BLACK)
  24. }
  25.  
  26. fun String.green(): String {
  27. return color(Color.GREEN)
  28. }
  29.  
  30. fun String.yellow(): String {
  31. return color(Color.YELLOW)
  32. }
  33.  
  34. fun String.blue(): String {
  35. return color(Color.BLUE)
  36. }
  37.  
  38. fun String.magenta(): String {
  39. return color(Color.MAGENTA)
  40. }
  41.  
  42. fun String.white(): String {
  43. return color(Color.WHITE)
  44. }
Add Comment
Please, Sign In to add comment