From ee5c845d7f1be16870b9734a52f5a6729ade3f2c Mon Sep 17 00:00:00 2001 From: Penwing Date: Sat, 27 Jan 2024 23:36:30 +0100 Subject: [PATCH] added windows placeholder terminal --- Cargo.toml | 3 +- src/tools/mod.rs | 5 +++ src/tools/windows_terminal.rs | 57 +++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/tools/windows_terminal.rs diff --git a/Cargo.toml b/Cargo.toml index a687a20..186a127 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,5 +13,4 @@ image = "0.24.8" serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0.111" nix = { version = "0.27.1", features = ["fs"] } -homedir = "0.2.1" - +homedir = "0.2.1" \ No newline at end of file diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 4eeaa35..cb6dd8f 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -16,9 +16,14 @@ pub mod settings; pub mod shortcuts; pub mod file_tree; +#[cfg(target_os = "linux")] pub mod terminal; pub use terminal::*; +#[cfg(target_os = "windows")] +pub mod windows_terminal; +pub use windows_terminal::*; + pub mod tabs; pub use tabs::*; diff --git a/src/tools/windows_terminal.rs b/src/tools/windows_terminal.rs new file mode 100644 index 0000000..50bb5ea --- /dev/null +++ b/src/tools/windows_terminal.rs @@ -0,0 +1,57 @@ +// Placeholder + +pub struct Line { + pub text: String, + pub error: bool, +} + +impl Line { + fn output(text: String) -> Self { + Self { + text: remove_line_break(text), + error: false, + } + } + fn error(text: String) -> Self { + Self { + text: remove_line_break(text), + error: true, + } + } +} + +pub struct CommandEntry { + pub env: String, + pub command: String, + pub result: Vec, +} + +impl CommandEntry { + pub fn new(env: String, command: String) -> Self { + CommandEntry { + env, + command, + result: vec![Line::error("General Kenobi")], + } + } + + pub fn update(&mut self) { + return + } +} + +pub fn send_command(command: String) -> CommandEntry { + return CommandEntry::new("windows>", "hello there"); +} + + +fn remove_line_break(input: String) -> String { + let mut text = input.clone(); + while text.ends_with('\n') { + text.pop(); + if text.ends_with('\r') { + text.pop(); + } + } + text +}