From 698eda90a45e92b11da70a7280c0e94fc126837e Mon Sep 17 00:00:00 2001 From: Robert-M-Lucas Date: Fri, 24 May 2024 14:46:31 +0100 Subject: [PATCH 1/2] Allow the user to detect whether the console is open. --- src/ui.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ui.rs b/src/ui.rs index 2c836d3..4ab6a0b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -24,7 +24,7 @@ pub const COMMAND_MESSAGE_NAME: &str = "console_command"; pub const COMMAND_RESULT_NAME: &str = "console_result"; #[derive(Default, Resource)] -pub(crate) struct ConsoleUiState { +pub struct ConsoleUiState { /// Wherever the console is open or not. pub(crate) open: bool, /// Whether we have set focus this open or not. @@ -36,6 +36,12 @@ pub(crate) struct ConsoleUiState { pub(crate) command: String, } +impl ConsoleUiState { + pub fn open(&self) -> bool { + self.open + } +} + fn system_time_to_chrono_utc(t: SystemTime) -> chrono::DateTime { let dur = t.duration_since(web_time::SystemTime::UNIX_EPOCH).unwrap(); let (sec, nsec) = (dur.as_secs() as i64, dur.subsec_nanos()); From bcb7c2c49ba7903a9ee6384b00f81f079e2e87e4 Mon Sep 17 00:00:00 2001 From: Robert-M-Lucas Date: Fri, 24 May 2024 14:47:59 +0100 Subject: [PATCH 2/2] Added a docstring for the new function --- src/ui.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ui.rs b/src/ui.rs index 4ab6a0b..3047f82 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -37,6 +37,7 @@ pub struct ConsoleUiState { } impl ConsoleUiState { + /// Whether the console is currently open or not pub fn open(&self) -> bool { self.open }