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