terminal_theme.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. from typing import List, Optional, Tuple
  2. from .color_triplet import ColorTriplet
  3. from .palette import Palette
  4. _ColorTuple = Tuple[int, int, int]
  5. class TerminalTheme:
  6. """A color theme used when exporting console content.
  7. Args:
  8. background (Tuple[int, int, int]): The background color.
  9. foreground (Tuple[int, int, int]): The foreground (text) color.
  10. normal (List[Tuple[int, int, int]]): A list of 8 normal intensity colors.
  11. bright (List[Tuple[int, int, int]], optional): A list of 8 bright colors, or None
  12. to repeat normal intensity. Defaults to None.
  13. """
  14. def __init__(
  15. self,
  16. background: _ColorTuple,
  17. foreground: _ColorTuple,
  18. normal: List[_ColorTuple],
  19. bright: Optional[List[_ColorTuple]] = None,
  20. ) -> None:
  21. self.background_color = ColorTriplet(*background)
  22. self.foreground_color = ColorTriplet(*foreground)
  23. self.ansi_colors = Palette(normal + (bright or normal))
  24. DEFAULT_TERMINAL_THEME = TerminalTheme(
  25. (255, 255, 255),
  26. (0, 0, 0),
  27. [
  28. (0, 0, 0),
  29. (128, 0, 0),
  30. (0, 128, 0),
  31. (128, 128, 0),
  32. (0, 0, 128),
  33. (128, 0, 128),
  34. (0, 128, 128),
  35. (192, 192, 192),
  36. ],
  37. [
  38. (128, 128, 128),
  39. (255, 0, 0),
  40. (0, 255, 0),
  41. (255, 255, 0),
  42. (0, 0, 255),
  43. (255, 0, 255),
  44. (0, 255, 255),
  45. (255, 255, 255),
  46. ],
  47. )
  48. MONOKAI = TerminalTheme(
  49. (12, 12, 12),
  50. (217, 217, 217),
  51. [
  52. (26, 26, 26),
  53. (244, 0, 95),
  54. (152, 224, 36),
  55. (253, 151, 31),
  56. (157, 101, 255),
  57. (244, 0, 95),
  58. (88, 209, 235),
  59. (196, 197, 181),
  60. (98, 94, 76),
  61. ],
  62. [
  63. (244, 0, 95),
  64. (152, 224, 36),
  65. (224, 213, 97),
  66. (157, 101, 255),
  67. (244, 0, 95),
  68. (88, 209, 235),
  69. (246, 246, 239),
  70. ],
  71. )
  72. DIMMED_MONOKAI = TerminalTheme(
  73. (25, 25, 25),
  74. (185, 188, 186),
  75. [
  76. (58, 61, 67),
  77. (190, 63, 72),
  78. (135, 154, 59),
  79. (197, 166, 53),
  80. (79, 118, 161),
  81. (133, 92, 141),
  82. (87, 143, 164),
  83. (185, 188, 186),
  84. (136, 137, 135),
  85. ],
  86. [
  87. (251, 0, 31),
  88. (15, 114, 47),
  89. (196, 112, 51),
  90. (24, 109, 227),
  91. (251, 0, 103),
  92. (46, 112, 109),
  93. (253, 255, 185),
  94. ],
  95. )
  96. NIGHT_OWLISH = TerminalTheme(
  97. (255, 255, 255),
  98. (64, 63, 83),
  99. [
  100. (1, 22, 39),
  101. (211, 66, 62),
  102. (42, 162, 152),
  103. (218, 170, 1),
  104. (72, 118, 214),
  105. (64, 63, 83),
  106. (8, 145, 106),
  107. (122, 129, 129),
  108. (122, 129, 129),
  109. ],
  110. [
  111. (247, 110, 110),
  112. (73, 208, 197),
  113. (218, 194, 107),
  114. (92, 167, 228),
  115. (105, 112, 152),
  116. (0, 201, 144),
  117. (152, 159, 177),
  118. ],
  119. )
  120. SVG_EXPORT_THEME = TerminalTheme(
  121. (41, 41, 41),
  122. (197, 200, 198),
  123. [
  124. (75, 78, 85),
  125. (204, 85, 90),
  126. (152, 168, 75),
  127. (208, 179, 68),
  128. (96, 138, 177),
  129. (152, 114, 159),
  130. (104, 160, 179),
  131. (197, 200, 198),
  132. (154, 155, 153),
  133. ],
  134. [
  135. (255, 38, 39),
  136. (0, 130, 61),
  137. (208, 132, 66),
  138. (25, 132, 233),
  139. (255, 44, 122),
  140. (57, 130, 128),
  141. (253, 253, 197),
  142. ],
  143. )