@@ -42,6 +42,7 @@ use crate::core::renderer;
4242use crate :: core:: text:: editor:: { Cursor , Editor as _} ;
4343use crate :: core:: text:: highlighter:: { self , Highlighter } ;
4444use crate :: core:: text:: { self , LineHeight , Text , Wrapping } ;
45+ use crate :: core:: theme;
4546use crate :: core:: time:: { Duration , Instant } ;
4647use crate :: core:: widget:: operation;
4748use crate :: core:: widget:: { self , Widget } ;
@@ -148,7 +149,7 @@ where
148149 max_height : f32:: INFINITY ,
149150 padding : Padding :: new ( 5.0 ) ,
150151 wrapping : Wrapping :: default ( ) ,
151- class : Theme :: default ( ) ,
152+ class : < Theme as Catalog > :: default ( ) ,
152153 key_binding : None ,
153154 on_edit : None ,
154155 highlighter_settings : ( ) ,
@@ -170,7 +171,7 @@ impl<'a, Highlighter, Message, Theme, Renderer>
170171 TextEditor < ' a , Highlighter , Message , Theme , Renderer >
171172where
172173 Highlighter : text:: Highlighter ,
173- Theme : Catalog + ' static ,
174+ Theme : Catalog ,
174175 Renderer : text:: Renderer ,
175176{
176177 /// Sets the placeholder of the [`TextEditor`].
@@ -335,7 +336,7 @@ where
335336
336337 fn input_method < ' b > (
337338 & self ,
338- state : & ' b State < Highlighter , Theme > ,
339+ state : & ' b State < Highlighter > ,
339340 renderer : & Renderer ,
340341 layout : Layout < ' _ > ,
341342 ) -> InputMethod < & ' b str > {
@@ -508,13 +509,13 @@ where
508509
509510/// The state of a [`TextEditor`].
510511#[ derive( Debug ) ]
511- pub struct State < Highlighter : text:: Highlighter , Theme > {
512+ pub struct State < Highlighter : text:: Highlighter > {
512513 focus : Option < Focus > ,
513514 preedit : Option < input_method:: Preedit > ,
514515 last_click : Option < mouse:: Click > ,
515516 drag_click : Option < mouse:: click:: Kind > ,
516517 partial_scroll : f32 ,
517- last_theme : RefCell < Option < Theme > > ,
518+ last_theme : RefCell < Option < String > > ,
518519 highlighter : RefCell < Highlighter > ,
519520 highlighter_settings : Highlighter :: Settings ,
520521 highlighter_format_address : usize ,
@@ -548,15 +549,15 @@ impl Focus {
548549 }
549550}
550551
551- impl < Highlighter : text:: Highlighter , Theme > State < Highlighter , Theme > {
552+ impl < Highlighter : text:: Highlighter > State < Highlighter > {
552553 /// Returns whether the [`TextEditor`] is currently focused or not.
553554 pub fn is_focused ( & self ) -> bool {
554555 self . focus . is_some ( )
555556 }
556557}
557558
558- impl < Highlighter : text:: Highlighter , Theme > operation:: Focusable
559- for State < Highlighter , Theme >
559+ impl < Highlighter : text:: Highlighter > operation:: Focusable
560+ for State < Highlighter >
560561{
561562 fn is_focused ( & self ) -> bool {
562563 self . focus . is_some ( )
@@ -575,11 +576,11 @@ impl<Highlighter, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
575576 for TextEditor < ' _ , Highlighter , Message , Theme , Renderer >
576577where
577578 Highlighter : text:: Highlighter ,
578- Theme : Catalog + ' static ,
579+ Theme : Catalog ,
579580 Renderer : text:: Renderer ,
580581{
581582 fn tag ( & self ) -> widget:: tree:: Tag {
582- widget:: tree:: Tag :: of :: < State < Highlighter , Theme > > ( )
583+ widget:: tree:: Tag :: of :: < State < Highlighter > > ( )
583584 }
584585
585586 fn state ( & self ) -> widget:: tree:: State {
@@ -589,7 +590,7 @@ where
589590 last_click : None ,
590591 drag_click : None ,
591592 partial_scroll : 0.0 ,
592- last_theme : RefCell :: < Option < Theme > > :: default ( ) ,
593+ last_theme : RefCell :: default ( ) ,
593594 highlighter : RefCell :: new ( Highlighter :: new (
594595 & self . highlighter_settings ,
595596 ) ) ,
@@ -612,7 +613,7 @@ where
612613 limits : & layout:: Limits ,
613614 ) -> iced_renderer:: core:: layout:: Node {
614615 let mut internal = self . content . 0 . borrow_mut ( ) ;
615- let state = tree. state . downcast_mut :: < State < Highlighter , Theme > > ( ) ;
616+ let state = tree. state . downcast_mut :: < State < Highlighter > > ( ) ;
616617
617618 if state. highlighter_format_address != self . highlighter_format as usize
618619 {
@@ -677,7 +678,7 @@ where
677678 return ;
678679 } ;
679680
680- let state = tree. state . downcast_mut :: < State < Highlighter , Theme > > ( ) ;
681+ let state = tree. state . downcast_mut :: < State < Highlighter > > ( ) ;
681682 let is_redraw = matches ! (
682683 event,
683684 Event :: Window ( window:: Event :: RedrawRequested ( _now) ) ,
@@ -789,12 +790,11 @@ where
789790 fn apply_binding <
790791 H : text:: Highlighter ,
791792 R : text:: Renderer ,
792- T ,
793793 Message ,
794794 > (
795795 binding : Binding < Message > ,
796796 content : & Content < R > ,
797- state : & mut State < H , T > ,
797+ state : & mut State < H > ,
798798 on_edit : & dyn Fn ( Action ) -> Message ,
799799 clipboard : & mut dyn Clipboard ,
800800 shell : & mut Shell < ' _ , Message > ,
@@ -937,18 +937,21 @@ where
937937 let bounds = layout. bounds ( ) ;
938938
939939 let mut internal = self . content . 0 . borrow_mut ( ) ;
940- let state = tree. state . downcast_ref :: < State < Highlighter , Theme > > ( ) ;
940+ let state = tree. state . downcast_ref :: < State < Highlighter > > ( ) ;
941941
942942 let font = self . font . unwrap_or_else ( || renderer. default_font ( ) ) ;
943943
944+ let theme_name = theme. name ( ) ;
945+
944946 if state
945947 . last_theme
946948 . borrow ( )
947949 . as_ref ( )
948- . is_none_or ( |last_theme| last_theme != theme )
950+ . is_none_or ( |last_theme| last_theme != theme_name )
949951 {
950952 state. highlighter . borrow_mut ( ) . change_line ( 0 ) ;
951- let _ = state. last_theme . borrow_mut ( ) . replace ( theme. clone ( ) ) ;
953+ let _ =
954+ state. last_theme . borrow_mut ( ) . replace ( theme_name. to_owned ( ) ) ;
952955 }
953956
954957 internal. editor . highlight (
@@ -1077,7 +1080,7 @@ where
10771080 _renderer : & Renderer ,
10781081 operation : & mut dyn widget:: Operation ,
10791082 ) {
1080- let state = tree. state . downcast_mut :: < State < Highlighter , Theme > > ( ) ;
1083+ let state = tree. state . downcast_mut :: < State < Highlighter > > ( ) ;
10811084
10821085 operation. focusable ( self . id . as_ref ( ) , layout. bounds ( ) , state) ;
10831086 }
@@ -1089,7 +1092,7 @@ impl<'a, Highlighter, Message, Theme, Renderer>
10891092where
10901093 Highlighter : text:: Highlighter ,
10911094 Message : ' a ,
1092- Theme : Catalog + ' static ,
1095+ Theme : Catalog + ' a ,
10931096 Renderer : text:: Renderer ,
10941097{
10951098 fn from (
@@ -1245,9 +1248,9 @@ enum Ime {
12451248}
12461249
12471250impl < Message > Update < Message > {
1248- fn from_event < H : Highlighter , T > (
1251+ fn from_event < H : Highlighter > (
12491252 event : & Event ,
1250- state : & State < H , T > ,
1253+ state : & State < H > ,
12511254 bounds : Rectangle ,
12521255 padding : Padding ,
12531256 cursor : mouse:: Cursor ,
@@ -1404,7 +1407,7 @@ pub struct Style {
14041407}
14051408
14061409/// The theme catalog of a [`TextEditor`].
1407- pub trait Catalog : PartialEq + Clone {
1410+ pub trait Catalog : theme :: Base {
14081411 /// The item class of the [`Catalog`].
14091412 type Class < ' a > ;
14101413
0 commit comments