fixed the key input when switching workspaces
This commit is contained in:
parent
f4a62c9c32
commit
358fd4c983
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/target
|
||||
*.tar.gz
|
||||
|
|
|
@ -26,10 +26,6 @@ mkShell {
|
|||
xorg.libX11
|
||||
wayland
|
||||
libxkbcommon
|
||||
python3Packages.virtualenv
|
||||
python3Packages.plyer
|
||||
python3Packages.pygobject3
|
||||
python3Packages.pillow
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -59,6 +59,9 @@ fn main() -> Result<(), eframe::Error> {
|
|||
}
|
||||
|
||||
struct Calcifer {
|
||||
focused: bool,
|
||||
got_focus: bool,
|
||||
|
||||
selected_tab: usize,
|
||||
tabs: Vec<panels::Tab>,
|
||||
|
||||
|
@ -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<usize> = vec![];
|
||||
|
|
Loading…
Reference in a new issue