@@ -149,6 +149,22 @@ pub struct AnsiPalette {
149149 pub white : HexColor ,
150150}
151151
152+ impl AnsiPalette {
153+ /// Returns palette colors indexed from `offset` (0 for normal, 8 for bright).
154+ pub fn as_indexed ( & self , offset : u8 ) -> [ ( u8 , & HexColor ) ; 8 ] {
155+ [
156+ ( offset, & self . black ) ,
157+ ( offset + 1 , & self . red ) ,
158+ ( offset + 2 , & self . green ) ,
159+ ( offset + 3 , & self . yellow ) ,
160+ ( offset + 4 , & self . blue ) ,
161+ ( offset + 5 , & self . magenta ) ,
162+ ( offset + 6 , & self . cyan ) ,
163+ ( offset + 7 , & self . white ) ,
164+ ]
165+ }
166+ }
167+
152168#[ derive( Debug , Clone ) ]
153169pub struct AnsiColors {
154170 pub normal : AnsiPalette ,
@@ -181,3 +197,53 @@ pub struct ThemeIR {
181197 // Terminal ANSI
182198 pub terminal : AnsiColors ,
183199}
200+
201+ #[ cfg( test) ]
202+ pub ( crate ) mod test_fixtures {
203+ use super :: * ;
204+
205+ pub fn make_test_ir ( ) -> ThemeIR {
206+ let hex = |s : & str | HexColor :: parse ( s) . unwrap ( ) ;
207+ let palette = || AnsiPalette {
208+ black : hex ( "#000000" ) ,
209+ red : hex ( "#FF0000" ) ,
210+ green : hex ( "#00FF00" ) ,
211+ yellow : hex ( "#FFFF00" ) ,
212+ blue : hex ( "#0000FF" ) ,
213+ magenta : hex ( "#FF00FF" ) ,
214+ cyan : hex ( "#00FFFF" ) ,
215+ white : hex ( "#FFFFFF" ) ,
216+ } ;
217+ ThemeIR {
218+ id : "test-theme" . to_string ( ) ,
219+ name : "Test Theme" . to_string ( ) ,
220+ theme_type : ThemeType :: Dark ,
221+ background : hex ( "#1E1E1E" ) ,
222+ foreground : hex ( "#D4D4D4" ) ,
223+ accent : hex ( "#0078D4" ) ,
224+ cursor : hex ( "#D4D4D4" ) ,
225+ selection_bg : hex ( "#264F78" ) ,
226+ border : hex ( "#3E3E3E" ) ,
227+ sidebar_bg : hex ( "#252526" ) ,
228+ sidebar_fg : hex ( "#CCCCCC" ) ,
229+ input_bg : hex ( "#3C3C3C" ) ,
230+ muted_fg : hex ( "#858585" ) ,
231+ chart_colors : [
232+ hex ( "#E06C75" ) ,
233+ hex ( "#98C379" ) ,
234+ hex ( "#61AFEF" ) ,
235+ hex ( "#C678DD" ) ,
236+ hex ( "#56B6C2" ) ,
237+ ] ,
238+ terminal : AnsiColors {
239+ normal : palette ( ) ,
240+ bright : palette ( ) ,
241+ background : hex ( "#1E1E1E" ) ,
242+ foreground : hex ( "#D4D4D4" ) ,
243+ cursor : hex ( "#D4D4D4" ) ,
244+ cursor_accent : None ,
245+ selection_bg : Some ( hex ( "#264F78" ) ) ,
246+ } ,
247+ }
248+ }
249+ }
0 commit comments