uncovered already implemented undo, cleaned up code
This commit is contained in:
parent
4e03fb8c03
commit
467d2b698a
|
@ -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
|
||||
|
|
|
@ -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<PathBuf> {
|
||||
|
|
|
@ -237,7 +237,7 @@ impl CodeEditor {
|
|||
}
|
||||
|
||||
/// Show Code Editor
|
||||
pub fn show(&mut self, ui: &mut egui::Ui, text: &mut String, history: &mut Vec<String>, last_cursor: &mut Option<CCursorRange>, vertical_offset: &mut f32, override_cursor: Option<CCursorRange>) {
|
||||
pub fn show(&mut self, ui: &mut egui::Ui, text: &mut String, saved: &mut bool, last_cursor: &mut Option<CCursorRange>, vertical_offset: &mut f32, override_cursor: Option<CCursorRange>) {
|
||||
//let mut text_edit_output: Option<TextEditOutput> = 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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ pub struct Tab {
|
|||
pub code : String,
|
||||
pub language : String,
|
||||
pub saved : bool,
|
||||
pub history : Vec<String>,
|
||||
pub scroll_offset : f32,
|
||||
pub last_cursor : Option<CCursorRange>,
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue