@@ -4,9 +4,7 @@ use crate::{vec2, APP_INFO, PREFS_KEY};
44use core:: f32;
55use eframe:: egui:: panel:: Side ;
66use eframe:: egui:: plot:: { Legend , Line , Plot , PlotPoints } ;
7- use eframe:: egui:: {
8- global_dark_light_mode_buttons, ColorImage , FontFamily , FontId , RichText , Vec2 , Visuals ,
9- } ;
7+ use eframe:: egui:: { global_dark_light_mode_buttons, ColorImage , FontFamily , FontId , Vec2 , Visuals } ;
108use eframe:: glow:: HasContext ;
119use eframe:: { egui, glow, Storage } ;
1210use image:: { ImageResult , RgbaImage } ;
@@ -314,22 +312,28 @@ impl eframe::App for MyApp {
314312 . max_height ( height - spacing)
315313 . min_scrolled_height ( height - spacing)
316314 . max_width ( width)
317- . show_rows ( ui, row_height, num_rows, |ui, row_range| {
318- for row in row_range {
319- let packet = & self . data . raw_traffic [ row] ;
320- let color = if self . gui_conf . dark_mode {
321- egui:: Color32 :: WHITE
322- } else {
323- egui:: Color32 :: BLACK
324- } ;
325- ui. horizontal_wrapped ( |ui| {
326- if let Some ( text) = self . console_text ( packet) {
327- ui. label (
328- RichText :: new ( text) . color ( color) . font ( DEFAULT_FONT_ID ) ,
329- ) ;
330- }
331- } ) ;
332- }
315+ . show_rows ( ui, row_height, num_rows, |ui, _row_range| {
316+ let content: String = self
317+ . data
318+ . raw_traffic
319+ . iter ( )
320+ . map ( |packet| match self . console_text ( packet) {
321+ None => "" . to_string ( ) ,
322+ Some ( text) => text + "\n " ,
323+ } )
324+ . collect ( ) ;
325+ let color = if self . gui_conf . dark_mode {
326+ egui:: Color32 :: WHITE
327+ } else {
328+ egui:: Color32 :: BLACK
329+ } ;
330+ ui. add (
331+ egui:: TextEdit :: multiline ( & mut content. as_str ( ) )
332+ . font ( DEFAULT_FONT_ID ) // for cursor height
333+ . lock_focus ( true )
334+ . text_color ( color)
335+ . desired_width ( width) ,
336+ ) ;
333337 } ) ;
334338 let mut text_triggered = false ;
335339 let mut button_triggered = false ;
@@ -580,21 +584,20 @@ impl eframe::App for MyApp {
580584 . auto_shrink ( [ false ; 2 ] )
581585 . stick_to_bottom ( true )
582586 . max_height ( row_height * 15.5 )
583- . show_rows ( ui, row_height, num_rows, |ui, row_range| {
584- for row in row_range {
585- if let Some ( msg) =
586- & self . console [ row] . scroll_area_message ( & self . gui_conf )
587- {
588- ui. horizontal_wrapped ( |ui| {
589- ui. label (
590- RichText :: new ( & msg. label )
591- . color ( msg. color )
592- . font ( DEFAULT_FONT_ID ) ,
593- ) ;
594- ui. label ( RichText :: new ( & msg. content ) . font ( DEFAULT_FONT_ID ) ) ;
595- } ) ;
596- }
597- }
587+ . show_rows ( ui, row_height, num_rows, |ui, _row_range| {
588+ let content: String = self
589+ . console
590+ . iter ( )
591+ . map ( |row| match row. scroll_area_message ( & self . gui_conf ) {
592+ None => "" . to_string ( ) ,
593+ Some ( msg) => msg. label + msg. content . as_str ( ) + "\n " ,
594+ } )
595+ . collect ( ) ;
596+ ui. add (
597+ egui:: TextEdit :: multiline ( & mut content. as_str ( ) )
598+ . font ( DEFAULT_FONT_ID ) // for cursor height
599+ . lock_focus ( true ) , // TODO: add a layouter to highlight the labels
600+ ) ;
598601 } ) ;
599602 } ) ;
600603
0 commit comments