44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
|
use eframe::egui;
|
|
use std::env;
|
|
use std::io::IsTerminal;
|
|
use std::path::PathBuf;
|
|
|
|
mod app;
|
|
mod io;
|
|
mod ui;
|
|
use app::{config::Config, TextEditor};
|
|
|
|
fn main() -> eframe::Result {
|
|
let args: Vec<String> = env::args().collect();
|
|
|
|
let initial_paths: Vec<PathBuf> = args.iter().skip(1).map(|arg| PathBuf::from(arg)).collect();
|
|
|
|
if std::io::stdin().is_terminal() {
|
|
println!("This is a GUI application, are you sure you want to launch from terminal?");
|
|
}
|
|
|
|
let options = eframe::NativeOptions {
|
|
viewport: egui::ViewportBuilder::default()
|
|
.with_min_inner_size([600.0, 400.0])
|
|
.with_title("ced")
|
|
.with_app_id("io.lampnet.ced"),
|
|
..Default::default()
|
|
};
|
|
|
|
let config = Config::load();
|
|
|
|
eframe::run_native(
|
|
"ced",
|
|
options,
|
|
Box::new(move |cc| {
|
|
Ok(Box::new(TextEditor::from_config_with_context(
|
|
config,
|
|
cc,
|
|
initial_paths,
|
|
)))
|
|
}),
|
|
)
|
|
}
|