terminal resize and hide
This commit is contained in:
parent
fcb1b7abba
commit
fee92f29a8
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -570,7 +570,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calcifer"
|
name = "calcifer"
|
||||||
version = "1.0.4"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "calcifer"
|
name = "calcifer"
|
||||||
version = "1.0.4"
|
version = "1.1.0"
|
||||||
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
|
||||||
|
|
|
@ -34,6 +34,7 @@ Added terminal color
|
||||||
Max tabs 8 => 20
|
Max tabs 8 => 20
|
||||||
Max framerate => 30 fps (less cpu usage)
|
Max framerate => 30 fps (less cpu usage)
|
||||||
|
|
||||||
# 1.0.4 :
|
# 1.1.0 :
|
||||||
Added close tab and refresh confirm prompt
|
Added close tab and refresh confirm prompt
|
||||||
Async terminal !
|
Async terminal !
|
||||||
|
Better Ui
|
|
@ -1,5 +1,5 @@
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui::{text::CCursor, text_edit::CCursorRange};
|
use egui::{text::CCursor, text_edit::CCursorRange, Rangef};
|
||||||
use std::{env, path::Path, cmp::max};
|
use std::{env, path::Path, cmp::max};
|
||||||
|
|
||||||
use crate::tools;
|
use crate::tools;
|
||||||
|
@ -26,19 +26,22 @@ impl Calcifer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.separator();
|
ui.separator();
|
||||||
self.tree_display = self.toggle(ui, self.tree_display, "🗐");
|
self.tree_visible = self.toggle(ui, self.tree_visible, "🗐");
|
||||||
|
ui.separator();
|
||||||
|
self.terminal_visible = self.toggle(ui, self.terminal_visible, "🖵");
|
||||||
ui.separator();
|
ui.separator();
|
||||||
self.settings_menu.visible = self.toggle(ui, self.settings_menu.visible, "⚙");
|
self.settings_menu.visible = self.toggle(ui, self.settings_menu.visible, "⚙");
|
||||||
ui.separator();
|
ui.separator();
|
||||||
self.profiler_menu.visible = self.toggle(ui, self.profiler_menu.visible, "🗠");
|
self.shortcuts_menu.visible = self.toggle(ui, self.shortcuts_menu.visible, "⌨");
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
self.profiler_visible = self.toggle(ui, self.profiler_visible, "🗠");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn draw_tree_panel(&mut self, ctx: &egui::Context) {
|
pub fn draw_tree_panel(&mut self, ctx: &egui::Context) {
|
||||||
if !self.tree_display {
|
if !self.tree_visible {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
egui::SidePanel::left("file_tree_panel").show(ctx, |ui| {
|
egui::SidePanel::left("file_tree_panel").show(ctx, |ui| {
|
||||||
|
@ -49,11 +52,24 @@ impl Calcifer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn draw_bottom_tray(&mut self, ctx: &egui::Context) {
|
||||||
|
egui::TopBottomPanel::bottom("tray")
|
||||||
|
.default_height(self.font_size * 1.2)
|
||||||
|
.resizable(false)
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label(self.profiler());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn draw_terminal_panel(&mut self, ctx: &egui::Context) {
|
pub fn draw_terminal_panel(&mut self, ctx: &egui::Context) {
|
||||||
|
if !self.terminal_visible {
|
||||||
|
return
|
||||||
|
}
|
||||||
egui::TopBottomPanel::bottom("terminal")
|
egui::TopBottomPanel::bottom("terminal")
|
||||||
.default_height(super::TERMINAL_HEIGHT.clone())
|
.default_height(super::TERMINAL_HEIGHT.clone())
|
||||||
.min_height(0.0)
|
.height_range(Rangef::new(super::TERMINAL_RANGE.start, super::TERMINAL_RANGE.end))
|
||||||
|
.resizable(true)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
|
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
|
||||||
let command_color = egui::Color32::from_hex(self.theme.functions).expect("Theme color issue (functions)");
|
let command_color = egui::Color32::from_hex(self.theme.functions).expect("Theme color issue (functions)");
|
||||||
|
@ -61,6 +77,7 @@ impl Calcifer {
|
||||||
let bg_color = egui::Color32::from_hex(self.theme.bg).expect("Theme color issue (bg)");
|
let bg_color = egui::Color32::from_hex(self.theme.bg).expect("Theme color issue (bg)");
|
||||||
|
|
||||||
ui.label("");
|
ui.label("");
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.style_mut().visuals.extreme_bg_color = bg_color;
|
ui.style_mut().visuals.extreme_bg_color = bg_color;
|
||||||
let Self { command, .. } = self;
|
let Self { command, .. } = self;
|
||||||
|
@ -192,8 +209,8 @@ impl Calcifer {
|
||||||
if self.refresh_confirm.visible {
|
if self.refresh_confirm.visible {
|
||||||
self.refresh_confirm.show(ctx);
|
self.refresh_confirm.show(ctx);
|
||||||
}
|
}
|
||||||
if self.profiler_menu.visible {
|
if self.shortcuts_menu.visible {
|
||||||
self.profiler_menu.show(ctx, self.time_watch.clone());
|
self.shortcuts_menu.show(ctx);
|
||||||
}
|
}
|
||||||
if self.settings_menu.visible {
|
if self.settings_menu.visible {
|
||||||
self.settings_menu.show(ctx);
|
self.settings_menu.show(ctx);
|
||||||
|
|
|
@ -8,6 +8,7 @@ use crate::PATH_ROOT;
|
||||||
use crate::DEFAULT_THEMES;
|
use crate::DEFAULT_THEMES;
|
||||||
use crate::MAX_TABS;
|
use crate::MAX_TABS;
|
||||||
use crate::SAVE_PATH;
|
use crate::SAVE_PATH;
|
||||||
|
use crate::TIME_LABELS;
|
||||||
|
|
||||||
|
|
||||||
impl Calcifer {
|
impl Calcifer {
|
||||||
|
@ -163,4 +164,16 @@ impl Calcifer {
|
||||||
}
|
}
|
||||||
return display
|
return display
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn profiler(&self) -> String {
|
||||||
|
if !self.profiler_visible {
|
||||||
|
return "".to_string()
|
||||||
|
}
|
||||||
|
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} ms", self.time_watch.clone().iter().sum::<f32>()));
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
18
src/main.rs
18
src/main.rs
|
@ -3,7 +3,7 @@ mod calcifer;
|
||||||
|
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use calcifer::code_editor::ColorTheme;
|
use calcifer::code_editor::ColorTheme;
|
||||||
use std::{path::Path, sync::Arc, time, thread};
|
use std::{path::Path, sync::Arc, time, thread, ops::Range};
|
||||||
use egui::FontFamily::Proportional;
|
use egui::FontFamily::Proportional;
|
||||||
use egui::FontId;
|
use egui::FontId;
|
||||||
use egui::TextStyle::{Small, Button, Body, Heading, Monospace};
|
use egui::TextStyle::{Small, Button, Body, Heading, Monospace};
|
||||||
|
@ -26,6 +26,7 @@ use build::SAVE_PATH;
|
||||||
use build::TITLE;
|
use build::TITLE;
|
||||||
|
|
||||||
const TERMINAL_HEIGHT : f32 = 200.0;
|
const TERMINAL_HEIGHT : f32 = 200.0;
|
||||||
|
const TERMINAL_RANGE : Range<f32> = 100.0..500.0;
|
||||||
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
||||||
const TIME_LABELS : [&str; 7] = ["input", "settings", "tree", "terminal", "tabs", "content", "windows"];
|
const TIME_LABELS : [&str; 7] = ["input", "settings", "tree", "terminal", "tabs", "content", "windows"];
|
||||||
const MAX_FPS : f32 = 30.0;
|
const MAX_FPS : f32 = 30.0;
|
||||||
|
@ -72,7 +73,9 @@ struct Calcifer {
|
||||||
theme: ColorTheme,
|
theme: ColorTheme,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
|
|
||||||
tree_display: bool,
|
tree_visible: bool,
|
||||||
|
profiler_visible: bool,
|
||||||
|
terminal_visible: bool,
|
||||||
|
|
||||||
close_tab_confirm: tools::confirm::ConfirmWindow,
|
close_tab_confirm: tools::confirm::ConfirmWindow,
|
||||||
tab_to_close: usize,
|
tab_to_close: usize,
|
||||||
|
@ -80,7 +83,7 @@ struct Calcifer {
|
||||||
|
|
||||||
search: tools::search::SearchWindow,
|
search: tools::search::SearchWindow,
|
||||||
settings_menu: tools::settings::SettingsWindow,
|
settings_menu: tools::settings::SettingsWindow,
|
||||||
profiler_menu: tools::profiler::ProfilerWindow,
|
shortcuts_menu: tools::shortcuts::ShortcutsWindow,
|
||||||
|
|
||||||
time_watch: Vec<f32>,
|
time_watch: Vec<f32>,
|
||||||
next_frame: time::Instant,
|
next_frame: time::Instant,
|
||||||
|
@ -99,7 +102,9 @@ impl Default for Calcifer {
|
||||||
theme: DEFAULT_THEMES[0],
|
theme: DEFAULT_THEMES[0],
|
||||||
font_size: 14.0,
|
font_size: 14.0,
|
||||||
|
|
||||||
tree_display: false,
|
tree_visible: false,
|
||||||
|
profiler_visible: false,
|
||||||
|
terminal_visible: false,
|
||||||
|
|
||||||
close_tab_confirm: tools::confirm::ConfirmWindow::new("You have some unsaved changes, Do you still want to close this document ?", "Confirm Close"),
|
close_tab_confirm: tools::confirm::ConfirmWindow::new("You have some unsaved changes, Do you still want to close this document ?", "Confirm Close"),
|
||||||
tab_to_close: 0,
|
tab_to_close: 0,
|
||||||
|
@ -107,7 +112,7 @@ impl Default for Calcifer {
|
||||||
|
|
||||||
search: tools::search::SearchWindow::default(),
|
search: tools::search::SearchWindow::default(),
|
||||||
settings_menu: tools::settings::SettingsWindow::new(DEFAULT_THEMES[0]),
|
settings_menu: tools::settings::SettingsWindow::new(DEFAULT_THEMES[0]),
|
||||||
profiler_menu: tools::profiler::ProfilerWindow::new(),
|
shortcuts_menu: tools::shortcuts::ShortcutsWindow::new(),
|
||||||
|
|
||||||
time_watch: vec![0.0; TIME_LABELS.len()],
|
time_watch: vec![0.0; TIME_LABELS.len()],
|
||||||
next_frame: time::Instant::now(),
|
next_frame: time::Instant::now(),
|
||||||
|
@ -134,7 +139,7 @@ impl eframe::App for Calcifer {
|
||||||
.into();
|
.into();
|
||||||
ctx.set_style(style);
|
ctx.set_style(style);
|
||||||
|
|
||||||
if ctx.input( |i| i.key_pressed(egui::Key::T) && i.modifiers.ctrl) && !self.refresh_confirm.visible {
|
if ctx.input( |i| i.key_pressed(egui::Key::R) && i.modifiers.ctrl) && !self.refresh_confirm.visible {
|
||||||
if self.tabs[self.selected_tab.to_index()].saved {
|
if self.tabs[self.selected_tab.to_index()].saved {
|
||||||
self.tabs[self.selected_tab.to_index()].refresh();
|
self.tabs[self.selected_tab.to_index()].refresh();
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,6 +189,7 @@ impl eframe::App for Calcifer {
|
||||||
self.time_watch[2] = watch.elapsed().as_micros() as f32 / 1000.0;
|
self.time_watch[2] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
watch = time::Instant::now();
|
watch = time::Instant::now();
|
||||||
|
|
||||||
|
self.draw_bottom_tray(ctx);
|
||||||
self.draw_terminal_panel(ctx);
|
self.draw_terminal_panel(ctx);
|
||||||
|
|
||||||
self.time_watch[3] = watch.elapsed().as_micros() as f32 / 1000.0;
|
self.time_watch[3] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
|
|
|
@ -23,10 +23,10 @@ impl ConfirmWindow {
|
||||||
pub fn show(&mut self, ctx: &egui::Context) {
|
pub fn show(&mut self, ctx: &egui::Context) {
|
||||||
let mut visible = self.visible.clone();
|
let mut visible = self.visible.clone();
|
||||||
egui::Window::new(self.id.clone())
|
egui::Window::new(self.id.clone())
|
||||||
.open(&mut visible) //I want it to be able to change its visibility (if user close manually)
|
.open(&mut visible)
|
||||||
.vscroll(true)
|
.vscroll(true)
|
||||||
.hscroll(true)
|
.hscroll(true)
|
||||||
.show(ctx, |ui| self.ui(ui)); //but I want to edit the rest of the parameters and maybe close automatically
|
.show(ctx, |ui| self.ui(ui));
|
||||||
self.visible = self.visible.clone() && visible;
|
self.visible = self.visible.clone() && visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use toml::Value;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
pub mod confirm;
|
pub mod confirm;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
pub mod profiler;
|
pub mod shortcuts;
|
||||||
|
|
||||||
pub mod terminal;
|
pub mod terminal;
|
||||||
pub use terminal::*;
|
pub use terminal::*;
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
use eframe::egui;
|
|
||||||
use crate::TIME_LABELS;
|
|
||||||
|
|
||||||
|
|
||||||
pub struct ProfilerWindow {
|
|
||||||
pub visible: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl ProfilerWindow {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
visible: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pub fn show(&mut self, ctx: &egui::Context, time_watch: Vec<f32>) {
|
|
||||||
let mut visible = self.visible.clone();
|
|
||||||
egui::Window::new("Profiler")
|
|
||||||
.open(&mut visible) //I want it to be able to change its visibility (if user close manually)
|
|
||||||
.vscroll(true)
|
|
||||||
.hscroll(true)
|
|
||||||
.show(ctx, |ui| self.ui(ui, time_watch)); //but I want to edit the rest of the parameters and maybe close automatically
|
|
||||||
self.visible = self.visible.clone() && visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn ui(&mut self, ui: &mut egui::Ui, time_watch: Vec<f32>) {
|
|
||||||
ui.set_min_width(100.0);
|
|
||||||
|
|
||||||
for (index, entry) in TIME_LABELS.iter().enumerate() {
|
|
||||||
ui.label(format!("{} : {:.1} ms", entry, time_watch[index]));
|
|
||||||
}
|
|
||||||
ui.separator();
|
|
||||||
ui.label(&format!("total : {:.1} ms", time_watch.clone().iter().sum::<f32>()));
|
|
||||||
}
|
|
||||||
}
|
|
42
src/tools/shortcuts.rs
Normal file
42
src/tools/shortcuts.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
use eframe::egui;
|
||||||
|
|
||||||
|
|
||||||
|
pub struct ShortcutsWindow {
|
||||||
|
pub visible: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl ShortcutsWindow {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
visible: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn show(&mut self, ctx: &egui::Context) {
|
||||||
|
let mut visible = self.visible.clone();
|
||||||
|
egui::Window::new("Shortcuts")
|
||||||
|
.open(&mut visible)
|
||||||
|
.vscroll(true)
|
||||||
|
.hscroll(true)
|
||||||
|
.show(ctx, |ui| self.ui(ui,));
|
||||||
|
self.visible = self.visible.clone() && visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||||
|
ui.set_min_width(250.0);
|
||||||
|
ui.label("Ctrl+S : save file");
|
||||||
|
ui.label("Ctrl+Shift+S : save file as");
|
||||||
|
ui.label("Ctrl+R : reload file");
|
||||||
|
ui.separator();
|
||||||
|
ui.label("Ctrl+F : open search window");
|
||||||
|
ui.separator();
|
||||||
|
ui.label("Ctrl+Z : undo");
|
||||||
|
ui.label("Ctrl+Y : redo");
|
||||||
|
ui.label("Tab on selection : add indent of selection");
|
||||||
|
ui.label("Shift+Tab on selection : remove indent of selection");
|
||||||
|
ui.label("Ctrl+E : comment selection");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue