You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB

3 months ago
2 months ago
3 months ago
3 months ago
  1. module Semantic
  2. # common definitions and constants
  3. module AnsiColors
  4. ANSI_REGEX = /\e\[[0-9;]*m/ # TODO: support for \x1b and \033
  5. # FORMAT
  6. CLEAR = "\e[0m".freeze
  7. BOLD = "\e[1m".freeze
  8. UNDERLINE = "\e[4m".freeze
  9. # TEXT
  10. TEXT_BLACK = "\e[30m".freeze
  11. TEXT_RED = "\e[31m".freeze
  12. TEXT_GREEN = "\e[32m".freeze
  13. TEXT_YELLOW = "\e[33m".freeze
  14. TEXT_BLUE = "\e[34m".freeze
  15. TEXT_MAGENTA = "\e[35m".freeze
  16. TEXT_CYAN = "\e[36m".freeze
  17. TEXT_WHITE = "\e[37m".freeze
  18. # TEXT EXTRA COLOR NAME
  19. TEXT__PINK = "\e[38;5;175m".freeze
  20. TEXT__ORANGE = "\e[38;5;202m".freeze
  21. # TEXT GRAY SHADES
  22. TEXT_GRAY_800 = "\e[38;5;232m".freeze
  23. TEXT_GRAY_700 = "\e[38;5;233m".freeze
  24. TEXT_GRAY_600 = "\e[38;5;235m".freeze
  25. TEXT_GRAY_500 = "\e[38;5;238m".freeze
  26. TEXT_GRAY_400 = "\e[38;5;241m".freeze
  27. TEXT_GRAY_300 = "\e[38;5;244m".freeze
  28. TEXT_GRAY_200 = "\e[38;5;249m".freeze
  29. TEXT_GRAY_100 = "\e[38;5;252m".freeze
  30. # DARK TEXT
  31. DARK_TEXT_BLACK = "\e[90m".freeze
  32. DARK_TEXT_RED = "\e[91m".freeze
  33. DARK_TEXT_GREEN = "\e[92m".freeze
  34. DARK_TEXT_YELLOW = "\e[93m".freeze
  35. DARK_TEXT_BLUE = "\e[94m".freeze
  36. DARK_TEXT_MAGENTA = "\e[95m".freeze
  37. DARK_TEXT_CYAN = "\e[96m".freeze
  38. DARK_TEXT_WHITE = "\e[97m".freeze
  39. # BACKGROUND
  40. BG_BLACK = "\e[40m".freeze
  41. BG_WHITE = "\e[47m".freeze
  42. BG_GRAY = "\e[100m".freeze
  43. BG_RED = "\e[41m".freeze
  44. BG_GREEN = "\e[42m".freeze
  45. BG_YELLOW = "\e[43m".freeze
  46. BG_BLUE = "\e[44m".freeze
  47. BG_MAGENTA = "\e[45m".freeze
  48. BG_CYAN = "\e[46m".freeze
  49. # DARK BACKGROUND
  50. DARK_BG_RED = "\e[101m".freeze
  51. DARK_BG_GREEN = "\e[102m".freeze
  52. DARK_BG_YELLOW = "\e[103m".freeze
  53. DARK_BG_BLUE = "\e[104m".freeze
  54. DARK_BG_MAGENTA = "\e[105m".freeze
  55. DARK_BG_CYAN = "\e[106m".freeze
  56. # helper methods
  57. # --------------
  58. def colorize(text, tint = color) = "#{tint}#{text}#{CLEAR}"
  59. end
  60. end