fixed sterr not streamed
This commit is contained in:
parent
e1dcf6748e
commit
88747a3cd8
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -570,7 +570,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calcifer"
|
name = "calcifer"
|
||||||
version = "1.1.0"
|
version = "1.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "calcifer"
|
name = "calcifer"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -43,3 +43,7 @@ Max framerate => 30 fps (less cpu usage)
|
||||||
Added confirm prompt if unsaved
|
Added confirm prompt if unsaved
|
||||||
Async terminal !
|
Async terminal !
|
||||||
Real Ui
|
Real Ui
|
||||||
|
|
||||||
|
# 1.0.1 :
|
||||||
|
|
||||||
|
Fixed sterr not streamed
|
|
@ -90,7 +90,7 @@ impl Calcifer {
|
||||||
let response = ui.add(egui::TextEdit::singleline(command).desired_width(f32::INFINITY).lock_focus(true));
|
let response = ui.add(egui::TextEdit::singleline(command).desired_width(f32::INFINITY).lock_focus(true));
|
||||||
|
|
||||||
if response.lost_focus() && ctx.input(|i| i.key_pressed(egui::Key::Enter)) {
|
if response.lost_focus() && ctx.input(|i| i.key_pressed(egui::Key::Enter)) {
|
||||||
self.command_history.push(tools::run_command(self.command.clone()));
|
self.command_history.push(tools::send_command(self.command.clone()));
|
||||||
self.command = "".into();
|
self.command = "".into();
|
||||||
response.request_focus();
|
response.request_focus();
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ impl Calcifer {
|
||||||
if ui.add(egui::Button::new("open in terminal")).clicked() {
|
if ui.add(egui::Button::new("open in terminal")).clicked() {
|
||||||
let mut path = self.tabs[self.selected_tab.to_index()].path.clone();
|
let mut path = self.tabs[self.selected_tab.to_index()].path.clone();
|
||||||
path.pop();
|
path.pop();
|
||||||
tools::run_command(format!("cd {}", path.display()));
|
tools::send_command(format!("cd {}", path.display()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.label("Picked file:");
|
ui.label("Picked file:");
|
||||||
|
|
|
@ -153,15 +153,24 @@ impl Calcifer {
|
||||||
|
|
||||||
|
|
||||||
pub fn toggle(&self, ui: &mut egui::Ui, display : bool, title : &str) -> bool {
|
pub fn toggle(&self, ui: &mut egui::Ui, display : bool, title : &str) -> bool {
|
||||||
let color = if display.clone() {
|
let bg_color : Color32;
|
||||||
Color32::from_hex(self.theme.functions).expect("Could not convert color to hex (functions)")
|
let text_color : Color32;
|
||||||
|
|
||||||
|
if display.clone() {
|
||||||
|
bg_color = Color32::from_hex(self.theme.functions).expect("Could not convert color to hex (functions)");
|
||||||
|
text_color = Color32::from_hex(self.theme.bg).expect("Could not convert color to hex (bg)");
|
||||||
} else {
|
} else {
|
||||||
Color32::from_hex(self.theme.bg).expect("Could not convert color to hex (bg)")
|
bg_color = Color32::from_hex(self.theme.bg).expect("Could not convert color to hex (bg)");
|
||||||
|
text_color = Color32::from_hex(self.theme.literals).expect("Could not convert color to hex (literals)");
|
||||||
};
|
};
|
||||||
|
|
||||||
if ui.add(egui::Button::new(title).fill(color)).clicked() {
|
ui.style_mut().visuals.override_text_color = Some(text_color);
|
||||||
|
|
||||||
|
if ui.add(egui::Button::new(title).fill(bg_color)).clicked() {
|
||||||
return !display
|
return !display
|
||||||
}
|
}
|
||||||
|
ui.style_mut().visuals.override_text_color = None;
|
||||||
|
|
||||||
return display
|
return display
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ use calcifer::code_editor::themes::DEFAULT_THEMES;
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
mod build {
|
mod build {
|
||||||
pub const SAVE_PATH : &str = "/home/penwing/Documents/.saves/debug/calcifer_save.json";
|
pub const SAVE_PATH : &str = "/var/lib/calcifer/debug/calcifer_save.json";
|
||||||
pub const TITLE: &str = " debug";
|
pub const TITLE: &str = " debug";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
mod build {
|
mod build {
|
||||||
pub const SAVE_PATH : &str = "/home/penwing/Documents/.saves/calcifer_save.json";
|
pub const SAVE_PATH : &str = "/var/lib/calcifer/calcifer_save.json";
|
||||||
pub const TITLE: &str = "";
|
pub const TITLE: &str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,13 @@ pub struct CommandEntry {
|
||||||
pub output: String,
|
pub output: String,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub output_buffer: BufReader<std::process::ChildStdout>,
|
pub output_buffer: BufReader<std::process::ChildStdout>,
|
||||||
|
pub error_buffer: BufReader<std::process::ChildStderr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl CommandEntry {
|
impl CommandEntry {
|
||||||
pub fn new(command: String) -> Self {
|
pub fn new(command: String) -> Self {
|
||||||
let stdout_reader = execute(command.clone());
|
let (stdout_reader, stderr_reader) = execute(command.clone());
|
||||||
|
|
||||||
CommandEntry {
|
CommandEntry {
|
||||||
env: format_path(&env::current_dir().expect("Could not find Shell Environnment")),
|
env: format_path(&env::current_dir().expect("Could not find Shell Environnment")),
|
||||||
|
@ -26,6 +27,7 @@ impl CommandEntry {
|
||||||
output: String::new(),
|
output: String::new(),
|
||||||
error: String::new(),
|
error: String::new(),
|
||||||
output_buffer: stdout_reader,
|
output_buffer: stdout_reader,
|
||||||
|
error_buffer: stderr_reader,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,11 +37,17 @@ impl CommandEntry {
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
self.output += &output;
|
self.output += &output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut error = String::new();
|
||||||
|
let _ = self.error_buffer.read_line(&mut error);
|
||||||
|
if !error.is_empty() {
|
||||||
|
self.error += &error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn run_command(command: String) -> CommandEntry {
|
pub fn send_command(command: String) -> CommandEntry {
|
||||||
if command.len() < 2 {
|
if command.len() < 2 {
|
||||||
return CommandEntry::new(command);
|
return CommandEntry::new(command);
|
||||||
}
|
}
|
||||||
|
@ -75,11 +83,12 @@ pub fn run_command(command: String) -> CommandEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn execute(command: String) -> BufReader<std::process::ChildStdout> {
|
pub fn execute(command: String) -> (BufReader<std::process::ChildStdout>, BufReader<std::process::ChildStderr>) {
|
||||||
let mut child = Command::new("sh")
|
let mut child = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(command.clone())
|
.arg(command.clone())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
|
@ -88,5 +97,10 @@ pub fn execute(command: String) -> BufReader<std::process::ChildStdout> {
|
||||||
|
|
||||||
fcntl(stdout_fd, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("Failed to set non-blocking mode");
|
fcntl(stdout_fd, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("Failed to set non-blocking mode");
|
||||||
|
|
||||||
return BufReader::new(stdout);
|
let stderr = child.stderr.take().unwrap();
|
||||||
|
let stderr_fd = stderr.as_raw_fd();
|
||||||
|
|
||||||
|
fcntl(stderr_fd, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("Failed to set non-blocking mode");
|
||||||
|
|
||||||
|
return (BufReader::new(stdout), BufReader::new(stderr));
|
||||||
}
|
}
|
Loading…
Reference in a new issue