Remove unused code

This commit is contained in:
Hanno Braun 2023-06-19 13:51:44 +02:00
parent da46baa209
commit 0cf9f07867
2 changed files with 0 additions and 55 deletions

View File

@ -15,13 +15,11 @@ mod camera;
mod graphics;
mod input;
mod screen;
mod status_report;
mod viewer;
pub use self::{
graphics::RendererInitError,
input::InputEvent,
screen::{NormalizedScreenPosition, Screen, ScreenSize},
status_report::StatusReport,
viewer::Viewer,
};

View File

@ -1,53 +0,0 @@
//! Struct to store and update status messages
use std::collections::VecDeque;
use chrono::Local;
/// Struct to store and update status messages
#[derive(Default)]
pub struct StatusReport {
status: VecDeque<String>,
}
impl StatusReport {
/// Create a new `StatusReport` instance with a blank status
pub fn new() -> Self {
Self::default()
}
/// Update the status
pub fn update_status(&mut self, status: &str) {
let date = {
let date = Local::now();
format!("{}", date.format("[%H:%M:%S.%3f]"))
};
let empty_space = " ".repeat(date.chars().count());
let mut rendered = String::new();
for (i, line) in status.lines().enumerate() {
let prefix = if i == 0 { &date } else { &empty_space };
rendered.push_str(&format!("\n{prefix} {line}"));
}
self.status.push_back(rendered);
if self.status.len() > 5 {
for _ in 0..(self.status.len() - 5) {
self.status.pop_front();
}
}
}
/// Get current status
pub fn status(&self) -> String {
self.status
.iter()
.map(std::string::ToString::to_string)
.collect::<String>()
}
/// Reset status
pub fn clear_status(&mut self) {
self.status.clear();
}
}