added time debug
This commit is contained in:
parent
600db0ec01
commit
08d7344a02
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -570,7 +570,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calcifer"
|
name = "calcifer"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "calcifer"
|
name = "calcifer"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -8,8 +8,8 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = "0.25.0"
|
eframe = "0.25.0"
|
||||||
env_logger = { version = "0.10.1", default-features = false, features = [
|
env_logger = { version = "0.10.1", default-features = false, features = [
|
||||||
"auto-color",
|
"auto-color",
|
||||||
"humantime",
|
"humantime",
|
||||||
] }
|
] }
|
||||||
rfd = "0.12.1"
|
rfd = "0.12.1"
|
||||||
egui_extras = "0.25.0"
|
egui_extras = "0.25.0"
|
||||||
|
|
|
@ -19,4 +19,8 @@ Added find and replace function
|
||||||
Added multi line tab and shift+tab
|
Added multi line tab and shift+tab
|
||||||
Added Ctrl+E : comment multiline
|
Added Ctrl+E : comment multiline
|
||||||
Fixed Ctr+Z (was already in library, tried to make my own, and then found the better one)
|
Fixed Ctr+Z (was already in library, tried to make my own, and then found the better one)
|
||||||
Added indent recognition (when there is a line break, the indentaion level is kept)
|
Added indent recognition (when there is a line break, the indentation level is kept)
|
||||||
|
|
||||||
|
|
||||||
|
# 1.0.3 :
|
||||||
|
Added Ctrl+T : turn 4 spaces into tab across the whole document
|
BIN
assets/source.png
Normal file
BIN
assets/source.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
|
@ -2,6 +2,7 @@ use eframe::egui;
|
||||||
use egui::{text::CCursor, text_edit::CCursorRange};
|
use egui::{text::CCursor, text_edit::CCursorRange};
|
||||||
use std::{env, path::Path, path::PathBuf, cmp::max, io, fs, cmp::min};
|
use std::{env, path::Path, path::PathBuf, cmp::max, io, fs, cmp::min};
|
||||||
use crate::tools;
|
use crate::tools;
|
||||||
|
use crate::TIME_LABELS;
|
||||||
|
|
||||||
pub mod code_editor;
|
pub mod code_editor;
|
||||||
use code_editor::CodeEditor;
|
use code_editor::CodeEditor;
|
||||||
|
@ -25,6 +26,19 @@ impl super::Calcifer {
|
||||||
ui.selectable_value(&mut self.theme, theme, theme.name);
|
ui.selectable_value(&mut self.theme, theme, theme.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
ui.checkbox(&mut self.debug_display, "Debug display");
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
|
if self.debug_display {
|
||||||
|
let combined_string: Vec<String> = TIME_LABELS.into_iter().zip(self.time_watch.clone().into_iter())
|
||||||
|
.map(|(s, v)| format!("{} : {:.1} ms", s, v)).collect();
|
||||||
|
|
||||||
|
let mut result = combined_string.join(" ; ");
|
||||||
|
result.push_str(&format!(" total : {:.1}", self.time_watch.clone().iter().sum::<f32>()));
|
||||||
|
ui.label(result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -230,6 +244,11 @@ impl super::Calcifer {
|
||||||
let _ = tools::save_state(&app_state, super::SAVE_PATH);
|
let _ = tools::save_state(&app_state, super::SAVE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn indent_with_tabs(&mut self) {
|
||||||
|
let current_tab = &mut self.tabs[self.selected_tab.to_index()];
|
||||||
|
current_tab.code = current_tab.code.replace(" ", "\t")
|
||||||
|
}
|
||||||
|
|
||||||
fn list_files(&mut self, ui: &mut egui::Ui, path: &Path) -> io::Result<()> {
|
fn list_files(&mut self, ui: &mut egui::Ui, path: &Path) -> io::Result<()> {
|
||||||
if let Some(name) = path.file_name() {
|
if let Some(name) = path.file_name() {
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
|
|
100
src/main.rs
100
src/main.rs
|
@ -3,13 +3,15 @@ mod calcifer;
|
||||||
|
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use calcifer::code_editor::ColorTheme;
|
use calcifer::code_editor::ColorTheme;
|
||||||
use std::{path::Path, sync::Arc};
|
use std::{path::Path, sync::Arc, time::Instant};
|
||||||
|
|
||||||
use tools::Demo;
|
use tools::Demo;
|
||||||
use calcifer::code_editor::themes::DEFAULT_THEMES;
|
use calcifer::code_editor::themes::DEFAULT_THEMES;
|
||||||
|
|
||||||
const TERMINAL_HEIGHT : f32 = 200.0;
|
const TERMINAL_HEIGHT : f32 = 200.0;
|
||||||
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
||||||
const SAVE_PATH : &str = "calcifer_save.json";
|
const SAVE_PATH : &str = "calcifer_save.json";
|
||||||
|
const TIME_LABELS : [&str; 5] = ["settings", "tree", "terminal", "tabs", "content"];
|
||||||
|
|
||||||
|
|
||||||
fn main() -> Result<(), eframe::Error> {
|
fn main() -> Result<(), eframe::Error> {
|
||||||
|
@ -17,49 +19,52 @@ fn main() -> Result<(), eframe::Error> {
|
||||||
|
|
||||||
let icon_data = tools::load_icon();
|
let icon_data = tools::load_icon();
|
||||||
|
|
||||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||||
let options = eframe::NativeOptions {
|
let options = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
.with_inner_size([1200.0, 800.0])
|
.with_inner_size([1200.0, 800.0])
|
||||||
.with_icon(Arc::new(icon_data)),
|
.with_icon(Arc::new(icon_data)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let app_state: tools::AppState;
|
let app_state: tools::AppState;
|
||||||
// Attempt to load previous state
|
// Attempt to load previous state
|
||||||
if Path::new(SAVE_PATH).exists() {
|
if Path::new(SAVE_PATH).exists() {
|
||||||
app_state = tools::load_state(SAVE_PATH).expect("Failed to load the save");
|
app_state = tools::load_state(SAVE_PATH).expect("Failed to load the save");
|
||||||
} else {
|
} else {
|
||||||
app_state = tools::AppState {
|
app_state = tools::AppState {
|
||||||
tabs: vec![],
|
tabs: vec![],
|
||||||
theme: 0,
|
theme: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
"Calcifer v1.0.2",
|
"Calcifer v1.0.3",
|
||||||
options,
|
options,
|
||||||
Box::new(move |_cc| Box::from(Calcifer::from_app_state(app_state))),
|
Box::new(move |_cc| Box::from(Calcifer::from_app_state(app_state))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Calcifer {
|
struct Calcifer {
|
||||||
selected_tab : tools::TabNumber,
|
selected_tab : tools::TabNumber,
|
||||||
tabs: Vec<tools::Tab>,
|
tabs: Vec<tools::Tab>,
|
||||||
|
|
||||||
command: String,
|
command: String,
|
||||||
command_history: Vec<tools::CommandEntry>,
|
command_history: Vec<tools::CommandEntry>,
|
||||||
|
|
||||||
theme: ColorTheme,
|
theme: ColorTheme,
|
||||||
|
|
||||||
search: tools::search::SearchWindow,
|
search: tools::search::SearchWindow,
|
||||||
searching: bool,
|
searching: bool,
|
||||||
|
|
||||||
|
debug_display: bool,
|
||||||
|
time_watch: Vec<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Default for Calcifer {
|
impl Default for Calcifer {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
selected_tab: tools::TabNumber::Zero,
|
selected_tab: tools::TabNumber::Zero,
|
||||||
tabs: vec![tools::Tab::default()],
|
tabs: vec![tools::Tab::default()],
|
||||||
|
@ -71,17 +76,26 @@ impl Default for Calcifer {
|
||||||
|
|
||||||
search: tools::search::SearchWindow::default(),
|
search: tools::search::SearchWindow::default(),
|
||||||
searching: false,
|
searching: false,
|
||||||
|
|
||||||
|
debug_display: false,
|
||||||
|
time_watch: vec![0.0; TIME_LABELS.len()],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl eframe::App for Calcifer {
|
impl eframe::App for Calcifer {
|
||||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
|
let mut watch = Instant::now();
|
||||||
|
|
||||||
if ctx.input( |i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl) {
|
if ctx.input( |i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl) {
|
||||||
self.handle_save_file(self.save_tab());
|
self.handle_save_file(self.save_tab());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.input( |i| i.key_pressed(egui::Key::T) && i.modifiers.ctrl) {
|
||||||
|
self.indent_with_tabs();
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.input( |i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl && i.modifiers.shift) {
|
if ctx.input( |i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl && i.modifiers.shift) {
|
||||||
self.handle_save_file(self.save_tab_as());
|
self.handle_save_file(self.save_tab_as());
|
||||||
}
|
}
|
||||||
|
@ -94,10 +108,28 @@ impl eframe::App for Calcifer {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.draw_settings(ctx);
|
self.draw_settings(ctx);
|
||||||
self.draw_tree_panel(ctx);
|
|
||||||
self.draw_terminal_panel(ctx);
|
self.time_watch[0] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
self.draw_tab_panel(ctx);
|
watch = Instant::now();
|
||||||
self.draw_content_panel(ctx);
|
|
||||||
|
self.draw_tree_panel(ctx);
|
||||||
|
|
||||||
|
self.time_watch[1] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
|
watch = Instant::now();
|
||||||
|
|
||||||
|
self.draw_terminal_panel(ctx);
|
||||||
|
|
||||||
|
self.time_watch[2] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
|
watch = Instant::now();
|
||||||
|
|
||||||
|
self.draw_tab_panel(ctx);
|
||||||
|
|
||||||
|
self.time_watch[3] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
|
watch = Instant::now();
|
||||||
|
|
||||||
|
self.draw_content_panel(ctx);
|
||||||
|
|
||||||
|
self.time_watch[4] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
|
|
||||||
if self.searching {
|
if self.searching {
|
||||||
self.search.show(ctx, &mut self.searching, &mut self.tabs, &mut self.selected_tab);
|
self.search.show(ctx, &mut self.searching, &mut self.tabs, &mut self.selected_tab);
|
||||||
|
|
Loading…
Reference in a new issue