Skip to content

Commit

Permalink
fix ui disown
Browse files Browse the repository at this point in the history
  • Loading branch information
Kl4rry committed Dec 5, 2024
1 parent 99b0b91 commit 6826629
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
12 changes: 2 additions & 10 deletions crates/ferrite-tui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use std::{
io::{self, IsTerminal},
sync::mpsc,
time::Instant,
};
use std::{sync::mpsc, time::Instant};

use anyhow::{bail, Result};
use anyhow::Result;
use ferrite_cli::Args;
use ferrite_core::{
engine::Engine,
Expand Down Expand Up @@ -58,10 +54,6 @@ where

let Size { width, height } = backend.size()?;

if !io::stdout().is_terminal() {
bail!("Stdout must be a terminal");
}

Ok(Self {
terminal: tui::Terminal::new(backend)?,
buffer_area: Rect {
Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tracing_subscriber::{filter, fmt, layer::Layer, prelude::*, Registry};
#[global_allocator]
static GLOBAL: ferrite_talloc::Talloc = ferrite_talloc::Talloc;

/*#[cfg(not(target_os = "windows"))]
#[cfg(not(target_os = "windows"))]
fn maybe_disown(args: &ferrite_cli::Args) {
use std::{env, io::IsTerminal, process};
if args.wait || !std::io::stdout().is_terminal() {
Expand All @@ -35,7 +35,7 @@ fn maybe_disown(args: &ferrite_cli::Args) {
} else {
eprintln!("error in disowning process, cannot obtain the path for the current executable, continuing without disowning...");
}
}*/
}

#[cfg(feature = "tui")]
fn run_tui(args: &ferrite_cli::Args, rx: mpsc::Receiver<LogMessage>) -> Result<()> {
Expand All @@ -48,8 +48,8 @@ fn run_tui(args: &ferrite_cli::Args, rx: mpsc::Receiver<LogMessage>) -> Result<(

#[cfg(feature = "gui")]
fn run_gui(args: &ferrite_cli::Args, rx: mpsc::Receiver<LogMessage>) -> Result<()> {
//#[cfg(not(target_os = "windows"))]
//maybe_disown(&args);
#[cfg(not(target_os = "windows"))]
maybe_disown(args);
if let Err(err) = ferrite_gui::run(args, rx) {
tracing::error!("{err}");
return Err(err);
Expand Down Expand Up @@ -174,6 +174,7 @@ fn main() -> Result<ExitCode> {
eprintln!("Ferrite has not been compiled with tui");
return Ok(ExitCode::FAILURE);
}
return Ok(ExitCode::SUCCESS);
}
Some(Ui::Gui) => {
#[cfg(feature = "gui")]
Expand All @@ -184,6 +185,7 @@ fn main() -> Result<ExitCode> {
eprintln!("Ferrite has not been compiled with gui");
return Ok(ExitCode::FAILURE);
}
return Ok(ExitCode::SUCCESS);
}
_ => {
#[cfg(feature = "gui")]
Expand Down

0 comments on commit 6826629

Please sign in to comment.