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 +}