@@ -10,8 +10,6 @@ use embedded_graphics::geometry::{self, Dimensions};
1010use embedded_graphics:: mono_font:: { MonoFont , MonoTextStyleBuilder } ;
1111use embedded_graphics:: pixelcolor:: { PixelColor , Rgb888 } ;
1212use embedded_graphics:: text:: Text ;
13- #[ cfg( feature = "simulator" ) ]
14- use embedded_graphics_simulator:: { OutputSettings , SimulatorDisplay , SimulatorEvent , Window } ;
1513use ratatui_core:: backend:: { Backend , ClearType } ;
1614use ratatui_core:: layout;
1715use ratatui_core:: style;
@@ -62,16 +60,10 @@ where
6260 D : DrawTarget < Color = C > + ' display ,
6361 C : PixelColor + ' display ,
6462{
65- #[ cfg( not( feature = "simulator" ) ) ]
6663 display : & ' display mut D ,
67- #[ cfg( feature = "simulator" ) ]
68- display : & ' display mut SimulatorDisplay < C > ,
6964 display_type : PhantomData < D > ,
7065
71- #[ cfg( not( feature = "simulator" ) ) ]
7266 flush_callback : Box < dyn FnMut ( & mut D ) > ,
73- #[ cfg( feature = "simulator" ) ]
74- flush_callback : Box < dyn FnMut ( & mut SimulatorDisplay < C > ) > ,
7567
7668 buffer : framebuffer:: HeapBuffer < C > ,
7769
8375
8476 columns_rows : layout:: Size ,
8577 pixels : layout:: Size ,
86-
87- #[ cfg( feature = "simulator" ) ]
88- simulator_window : Window ,
8978}
9079
9180impl < ' display , D , C > EmbeddedBackend < ' display , D , C >
9483 C : PixelColor + Into < Rgb888 > + From < Rgb888 > + From < TermColor > + ' static ,
9584{
9685 fn init (
97- #[ cfg( not( feature = "simulator" ) ) ] display : & ' display mut D ,
98- #[ cfg( feature = "simulator" ) ] display : & ' display mut SimulatorDisplay < C > ,
99- #[ cfg( not( feature = "simulator" ) ) ] flush_callback : impl FnMut ( & mut D ) + ' static ,
100- #[ cfg( feature = "simulator" ) ] flush_callback : impl FnMut ( & mut SimulatorDisplay < C > ) + ' static ,
86+ display : & ' display mut D ,
87+ flush_callback : impl FnMut ( & mut D ) + ' static ,
10188 font_regular : MonoFont < ' static > ,
10289 font_bold : Option < MonoFont < ' static > > ,
10390 font_italic : Option < MonoFont < ' static > > ,
@@ -120,24 +107,13 @@ where
120107 width : pixels. width / font_regular. character_size . width as u16 ,
121108 } ,
122109 pixels,
123- #[ cfg( feature = "simulator" ) ]
124- simulator_window : Window :: new (
125- "mousefood emulator" ,
126- & OutputSettings {
127- scale : 4 ,
128- max_fps : 30 ,
129- ..Default :: default ( )
130- } ,
131- ) ,
132110 }
133111 }
134112
135113 /// Creates a new `EmbeddedBackend` using default fonts.
136114 pub fn new (
137- #[ cfg( not( feature = "simulator" ) ) ] display : & ' display mut D ,
138- #[ cfg( feature = "simulator" ) ] display : & ' display mut SimulatorDisplay < C > ,
139- #[ cfg( not( feature = "simulator" ) ) ] config : EmbeddedBackendConfig < D , C > ,
140- #[ cfg( feature = "simulator" ) ] config : EmbeddedBackendConfig < SimulatorDisplay < C > , C > ,
115+ display : & ' display mut D ,
116+ config : EmbeddedBackendConfig < D , C > ,
141117 ) -> EmbeddedBackend < ' display , D , C > {
142118 Self :: init (
143119 display,
@@ -147,19 +123,6 @@ where
147123 config. font_italic ,
148124 )
149125 }
150-
151- #[ cfg( feature = "simulator" ) ]
152- fn update_simulation ( & mut self ) -> Result < ( ) > {
153- self . simulator_window . update ( self . display ) ;
154- if self
155- . simulator_window
156- . events ( )
157- . any ( |e| e == SimulatorEvent :: Quit )
158- {
159- return Err ( crate :: error:: Error :: SimulatorQuit ) ;
160- }
161- Ok ( ( ) )
162- }
163126}
164127
165128type Result < T , E = crate :: error:: Error > = core:: result:: Result < T , E > ;
@@ -281,8 +244,6 @@ where
281244 . fill_contiguous ( & self . display . bounding_box ( ) , & self . buffer )
282245 . map_err ( |_| crate :: error:: Error :: DrawError ) ?;
283246 ( self . flush_callback ) ( self . display ) ;
284- #[ cfg( feature = "simulator" ) ]
285- self . update_simulation ( ) ?;
286247 Ok ( ( ) )
287248 }
288249}
0 commit comments