added windows placeholder terminal

This commit is contained in:
Penwing 2024-01-27 23:36:30 +01:00
parent 7767ebf956
commit ee5c845d7f
3 changed files with 63 additions and 2 deletions

View file

@ -13,5 +13,4 @@ image = "0.24.8"
serde = { version = "1.0.195", features = ["derive"] } serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111" serde_json = "1.0.111"
nix = { version = "0.27.1", features = ["fs"] } nix = { version = "0.27.1", features = ["fs"] }
homedir = "0.2.1" homedir = "0.2.1"

View file

@ -16,9 +16,14 @@ pub mod settings;
pub mod shortcuts; pub mod shortcuts;
pub mod file_tree; pub mod file_tree;
#[cfg(target_os = "linux")]
pub mod terminal; pub mod terminal;
pub use terminal::*; pub use terminal::*;
#[cfg(target_os = "windows")]
pub mod windows_terminal;
pub use windows_terminal::*;
pub mod tabs; pub mod tabs;
pub use tabs::*; pub use tabs::*;

View file

@ -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<Line>,
}
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
}