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
|
/target
|
||||||
|
*.tar.gz
|
||||||
|
|
|
@ -26,10 +26,6 @@ mkShell {
|
||||||
xorg.libX11
|
xorg.libX11
|
||||||
wayland
|
wayland
|
||||||
libxkbcommon
|
libxkbcommon
|
||||||
python3Packages.virtualenv
|
|
||||||
python3Packages.plyer
|
|
||||||
python3Packages.pygobject3
|
|
||||||
python3Packages.pillow
|
|
||||||
];
|
];
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|
|
@ -74,7 +74,6 @@ impl Calcifer {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("zoom : {}", app_state.zoom.clone());
|
|
||||||
if app_state.zoom != 0.0 {
|
if app_state.zoom != 0.0 {
|
||||||
new.zoom = app_state.zoom;
|
new.zoom = app_state.zoom;
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,6 +315,25 @@ impl Calcifer {
|
||||||
self.search_menu.result_selected = true;
|
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()
|
CodeEditor::default()
|
||||||
.id_source("code editor")
|
.id_source("code editor")
|
||||||
.with_rows(max(45, lines))
|
.with_rows(max(45, lines))
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -59,6 +59,9 @@ fn main() -> Result<(), eframe::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Calcifer {
|
struct Calcifer {
|
||||||
|
focused: bool,
|
||||||
|
got_focus: bool,
|
||||||
|
|
||||||
selected_tab: usize,
|
selected_tab: usize,
|
||||||
tabs: Vec<panels::Tab>,
|
tabs: Vec<panels::Tab>,
|
||||||
|
|
||||||
|
@ -97,6 +100,9 @@ struct Calcifer {
|
||||||
impl Default for Calcifer {
|
impl Default for Calcifer {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
focused: true,
|
||||||
|
got_focus: false,
|
||||||
|
|
||||||
selected_tab: 0,
|
selected_tab: 0,
|
||||||
tabs: vec![panels::Tab::default()],
|
tabs: vec![panels::Tab::default()],
|
||||||
|
|
||||||
|
@ -223,6 +229,16 @@ impl eframe::App for Calcifer {
|
||||||
self.search_menu.initialized = !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()) {
|
if ctx.input(|i| i.viewport().close_requested()) {
|
||||||
let mut unsaved_tabs: Vec<usize> = vec![];
|
let mut unsaved_tabs: Vec<usize> = vec![];
|
||||||
for (index, tab) in self.tabs.iter().enumerate() {
|
for (index, tab) in self.tabs.iter().enumerate() {
|
||||||
|
|
Loading…
Reference in a new issue