diff --git a/.gitignore b/.gitignore index ea8c4bf..d0a38e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +*.tar.gz diff --git a/shell.nix b/shell.nix index 3f9454d..d718dee 100644 --- a/shell.nix +++ b/shell.nix @@ -26,10 +26,6 @@ mkShell { xorg.libX11 wayland libxkbcommon - python3Packages.virtualenv - python3Packages.plyer - python3Packages.pygobject3 - python3Packages.pillow ]; shellHook = '' diff --git a/src/core/app.rs b/src/core/app.rs index 9e96d8b..bf75374 100644 --- a/src/core/app.rs +++ b/src/core/app.rs @@ -74,7 +74,6 @@ impl Calcifer { ..Default::default() }; - println!("zoom : {}", app_state.zoom.clone()); if app_state.zoom != 0.0 { new.zoom = app_state.zoom; } diff --git a/src/core/ui.rs b/src/core/ui.rs index 29613e2..fad00bb 100644 --- a/src/core/ui.rs +++ b/src/core/ui.rs @@ -314,6 +314,25 @@ impl Calcifer { )); self.search_menu.result_selected = true; } + + if self.got_focus { + CodeEditor::default() + .id_source("code editor") + .with_rows(max(45, lines)) + .with_fontsize(self.font_size) + .with_theme(self.theme) + .with_syntax(to_syntax(¤t_tab.language)) + .with_numlines(true) + .show( + ui, + &mut current_tab.code.clone(), + &mut current_tab.saved.clone(), + &mut current_tab.last_cursor.clone(), + &mut current_tab.scroll_offset.clone(), + override_cursor.clone(), + ); + return + } CodeEditor::default() .id_source("code editor") diff --git a/src/main.rs b/src/main.rs index be7bb9e..24c72e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,9 @@ fn main() -> Result<(), eframe::Error> { } struct Calcifer { + focused: bool, + got_focus: bool, + selected_tab: usize, tabs: Vec, @@ -97,6 +100,9 @@ struct Calcifer { impl Default for Calcifer { fn default() -> Self { Self { + focused: true, + got_focus: false, + selected_tab: 0, tabs: vec![panels::Tab::default()], @@ -222,6 +228,16 @@ impl eframe::App for Calcifer { self.search_menu.visible = !self.search_menu.visible; self.search_menu.initialized = !self.search_menu.visible; } + + self.got_focus = false; + if ctx.input(|i| !i.viewport().focused.unwrap_or_default()) { + self.focused = false; + } else { + if !self.focused { + self.got_focus = true; + } + self.focused = true; + } if ctx.input(|i| i.viewport().close_requested()) { let mut unsaved_tabs: Vec = vec![];