tree refresh

This commit is contained in:
WanderingPenwing 2024-02-28 15:33:23 +01:00
parent 43f2ebb2ae
commit b84cde8e2b
3 changed files with 385 additions and 378 deletions

View file

@ -55,8 +55,10 @@ impl Calcifer {
if !self.tree_visible {
return;
}
let mut init_update : bool = false;
if self.file_tree.is_none() {
self.file_tree = Some(panels::generate_folder_entry(self.home.as_path()));
init_update = true
}
let mut n_files: usize = 0;
egui::SidePanel::left("file_tree_panel").show(ctx, |ui| {
@ -69,7 +71,7 @@ impl Calcifer {
egui::ScrollArea::vertical().show(ui, |ui| {
if let Some(file_tree) = self.file_tree.clone() {
let update_requested = self.list_files(ui, &file_tree, &mut n_files);
if update_requested {
if update_requested || init_update {
self.file_tree = Some(panels::update_file_tree(
file_tree,
self.tree_dir_opened.clone(),

View file

View file

@ -17,7 +17,7 @@ const TITLE: &str = " debug";
#[cfg(not(debug_assertions))]
const TITLE: &str = "";
const ALLOWED_FILE_EXTENSIONS: [&str; 7] = ["", "rs", "toml", "txt", "project", "sh", "md", "html", "js", "css", "php", "py"];
const ALLOWED_FILE_EXTENSIONS: [&str; 12] = ["", "rs", "toml", "txt", "project", "sh", "md", "html", "js", "css", "php", "py"];
const PROJECT_EXTENSION: &str = "project";
const TERMINAL_HEIGHT: f32 = 200.0;
const TERMINAL_RANGE: Range<f32> = 100.0..600.0;
@ -186,6 +186,11 @@ impl eframe::App for Calcifer {
self.handle_save_file(self.save_tab());
}
if ctx.input(|i| i.key_pressed(egui::Key::T) && i.modifiers.ctrl) {
self.file_tree = None;
self.tree_dir_opened = vec![];
}
if ctx.input(|i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl && i.modifiers.shift) {
self.handle_save_file(self.save_tab_as());
}