diff --git a/README.md b/README.md index 28399b6..93eaa70 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,4 @@ Library subjugation (got the raw files of the egui_code_editor for some internal # 1.0.2 : Added find and replace function Added multi line tab and shift+tab +Added Ctrl+E : comment multiline diff --git a/src/calcifer.rs b/src/calcifer.rs index f850813..161bfe1 100644 --- a/src/calcifer.rs +++ b/src/calcifer.rs @@ -155,7 +155,7 @@ impl super::Calcifer { .with_theme(self.theme) .with_syntax(tools::to_syntax(¤t_tab.language)) .with_numlines(true) - .show(ui, &mut current_tab.code, &mut current_tab.history, &mut current_tab.last_cursor, &mut current_tab.scroll_offset, override_cursor); + .show(ui, &mut current_tab.code, &mut current_tab.saved, &mut current_tab.last_cursor, &mut current_tab.scroll_offset, override_cursor); } pub fn save_tab(&self) -> Option { diff --git a/src/calcifer/code_editor/mod.rs b/src/calcifer/code_editor/mod.rs index d6552f9..ac4b11c 100644 --- a/src/calcifer/code_editor/mod.rs +++ b/src/calcifer/code_editor/mod.rs @@ -237,7 +237,7 @@ impl CodeEditor { } /// Show Code Editor - pub fn show(&mut self, ui: &mut egui::Ui, text: &mut String, history: &mut Vec, last_cursor: &mut Option, vertical_offset: &mut f32, override_cursor: Option) { + pub fn show(&mut self, ui: &mut egui::Ui, text: &mut String, saved: &mut bool, last_cursor: &mut Option, vertical_offset: &mut f32, override_cursor: Option) { //let mut text_edit_output: Option = None; let mut code_editor = |ui: &mut egui::Ui| { ui.horizontal_top(|h| { @@ -269,6 +269,7 @@ impl CodeEditor { if output.response.has_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)) { println!("line break"); + //get previous line number of tabs, and 2 charcters before cursor } if output.response.has_focus() && ui.input(|i| i.key_pressed(egui::Key::E) && i.modifiers.ctrl) { @@ -296,17 +297,6 @@ impl CodeEditor { } } - if output.response.has_focus() && ui.input( |i| i.key_pressed(egui::Key::Z) && i.modifiers.ctrl) { - println!("Ctrl+Z"); - //let current_tab = &mut self.tabs[self.selected_tab.to_index()]; - //if current_tab.history.len() > 1 { - //current_tab.code = current_tab.history[current_tab.history.len() - 2].clone(); - //current_tab.history.pop(); - //} - } - - - if override_cursor != None { output.response.request_focus(); output.state.set_ccursor_range(override_cursor); @@ -332,20 +322,10 @@ impl CodeEditor { } } - - //text_edit_output = Some(output); - - if history.len() < 1 { - history.push(text.clone()); + if previous_text != text.clone() { + *saved = false; } - - //if ¤t_tab.code != current_tab.history.last().expect("There should be an history") { - //current_tab.history.push(current_tab.code.clone()); - //current_tab.saved = false; - //if current_tab.history.len() > super::HISTORY_LENGTH { - //current_tab.history.remove(0); - //} - //} + //text_edit_output = Some(output); }); }); }; diff --git a/src/main.rs b/src/main.rs index 0963c36..eb7262a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,6 @@ use calcifer::code_editor::themes::DEFAULT_THEMES; const TERMINAL_HEIGHT : f32 = 200.0; const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99); -const HISTORY_LENGTH : usize = 2; const SAVE_PATH : &str = "calcifer_save.json"; diff --git a/src/tools/mod.rs b/src/tools/mod.rs index fa2f6be..f438f60 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -77,7 +77,6 @@ pub struct Tab { pub code : String, pub language : String, pub saved : bool, - pub history : Vec, pub scroll_offset : f32, pub last_cursor : Option, } @@ -89,7 +88,6 @@ impl Default for Tab { code: "// Hello there, Master".into(), language: "rs".into(), saved: false, - history: vec![], scroll_offset: 0.0, last_cursor: None, }