diff --git a/crates/fj-host/src/lib.rs b/crates/fj-host/src/lib.rs index 18a2ea830..956ad0048 100644 --- a/crates/fj-host/src/lib.rs +++ b/crates/fj-host/src/lib.rs @@ -107,6 +107,7 @@ impl Model { } Err(_) => String::from("Failed to fetch command output"), }; + status.clear_status(); status.update_status(&format!( "Failed to compile model:\n{}", output diff --git a/crates/fj-interop/src/status_report.rs b/crates/fj-interop/src/status_report.rs index 4329d2867..23f74b802 100644 --- a/crates/fj-interop/src/status_report.rs +++ b/crates/fj-interop/src/status_report.rs @@ -1,31 +1,41 @@ //! Struct to store and update status messages +use std::collections::VecDeque; + /// Struct to store and update status messages pub struct StatusReport { - status: Vec, + status: VecDeque, } impl StatusReport { /// Create a new ``StatusReport`` instance with a blank status pub fn new() -> Self { - Self { status: Vec::new() } + Self { + status: VecDeque::new(), + } } /// Update the status pub fn update_status(&mut self, status: &str) { - if self.status.len() >= 5 { - self.clear_status(); + let status = format!("\n{}", status.to_owned()); + self.status.push_back(status); + if self.status.len() > 5 { + for _ in 0..(self.status.len() - 5) { + self.status.pop_front(); + } } - self.status.push(status.to_string()); } /// Get current status pub fn status(&self) -> String { - self.status.join("\n") + self.status + .iter() + .map(std::string::ToString::to_string) + .collect::() } /// Reset status - fn clear_status(&mut self) { + pub fn clear_status(&mut self) { self.status.clear(); } } diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index a2bef5f7f..160409ba7 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -574,11 +574,8 @@ impl Renderer { egui::Area::new("fj-status-message").show(&self.egui.context, |ui| { ui.group(|ui| { ui.add(egui::Label::new( - egui::RichText::new(format!( - "Status:\n{}", - status.status() - )) - .color(egui::Color32::BLACK), + egui::RichText::new(format!("Status:{}", status.status())) + .color(egui::Color32::BLACK), )) }) });