@@ -263,6 +263,8 @@ impl CodeEditor {
263263
264264 #[ cfg( feature = "egui" ) ]
265265 fn numlines_show ( & self , ui : & mut egui:: Ui , text : & str ) {
266+ use egui:: TextBuffer ;
267+
266268 let total = if text. ends_with ( '\n' ) || text. is_empty ( ) {
267269 text. lines ( ) . count ( ) + 1
268270 } else {
@@ -295,9 +297,9 @@ impl CodeEditor {
295297 * 0.5
296298 * !( total + self . numlines_shift <= 0 && self . numlines_only_natural ) as u8 as f32 ;
297299
298- let mut layouter = |ui : & egui:: Ui , string : & str , _wrap_width : f32 | {
300+ let mut layouter = |ui : & egui:: Ui , text_buffer : & dyn TextBuffer , _wrap_width : f32 | {
299301 let layout_job = egui:: text:: LayoutJob :: single_section (
300- string . to_string ( ) ,
302+ text_buffer . as_str ( ) . to_string ( ) ,
301303 egui:: TextFormat :: simple (
302304 egui:: FontId :: monospace ( self . fontsize ) ,
303305 self . theme . type_color ( TokenType :: Comment ( true ) ) ,
@@ -321,6 +323,8 @@ impl CodeEditor {
321323 #[ cfg( feature = "egui" ) ]
322324 /// Show Code Editor
323325 pub fn show ( & mut self , ui : & mut egui:: Ui , text : & mut dyn egui:: TextBuffer ) -> TextEditOutput {
326+ use egui:: TextBuffer ;
327+
324328 let mut text_edit_output: Option < TextEditOutput > = None ;
325329 let mut code_editor = |ui : & mut egui:: Ui | {
326330 ui. horizontal_top ( |h| {
@@ -331,10 +335,11 @@ impl CodeEditor {
331335 egui:: ScrollArea :: horizontal ( )
332336 . id_salt ( format ! ( "{}_inner_scroll" , self . id) )
333337 . show ( h, |ui| {
334- let mut layouter = |ui : & egui:: Ui , string : & str , _wrap_width : f32 | {
335- let layout_job = highlight ( ui. ctx ( ) , self , string) ;
336- ui. fonts ( |f| f. layout_job ( layout_job) )
337- } ;
338+ let mut layouter =
339+ |ui : & egui:: Ui , text_buffer : & dyn TextBuffer , _wrap_width : f32 | {
340+ let layout_job = highlight ( ui. ctx ( ) , self , text_buffer. as_str ( ) ) ;
341+ ui. fonts ( |f| f. layout_job ( layout_job) )
342+ } ;
338343 let output = egui:: TextEdit :: multiline ( text)
339344 . id_source ( & self . id )
340345 . lock_focus ( true )
0 commit comments