mirror of https://github.com/lapce/lapce.git
Merge pull request #1019 from panekj/fix/window
fix: add CloseWindow command, properly handle window/app closing
This commit is contained in:
commit
ba3f6d6b95
|
@ -1,3 +1,9 @@
|
|||
# --------------------------------- Window ---------------------------------------------
|
||||
|
||||
[[keymaps]]
|
||||
command = "window_close"
|
||||
key = "Meta+Shift+W"
|
||||
|
||||
# --------------------------------- General --------------------------------------------
|
||||
|
||||
[[keymaps]]
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
# --------------------------------- Window ---------------------------------------------
|
||||
|
||||
[[keymaps]]
|
||||
command = "close_window"
|
||||
key = "Alt+F4"
|
||||
|
||||
# --------------------------------- General --------------------------------------------
|
||||
|
||||
[[keymaps]]
|
||||
|
|
|
@ -273,6 +273,10 @@ pub enum LapceWorkbenchCommand {
|
|||
#[strum(serialize = "new_window")]
|
||||
NewWindow,
|
||||
|
||||
#[strum(message = "Close Window")]
|
||||
#[strum(serialize = "close_window")]
|
||||
CloseWindow,
|
||||
|
||||
#[strum(message = "New File")]
|
||||
#[strum(serialize = "new_file")]
|
||||
NewFile,
|
||||
|
@ -566,6 +570,7 @@ pub enum LapceUICommand {
|
|||
FilterItems,
|
||||
RestartToUpdate(PathBuf, ReleaseInfo),
|
||||
NewWindow(WindowId),
|
||||
CloseWindow(WindowId),
|
||||
ReloadWindow,
|
||||
CloseBuffers(Vec<BufferId>),
|
||||
RequestPaintRect(Rect),
|
||||
|
|
|
@ -1401,6 +1401,13 @@ pub fn run_workbench_command(
|
|||
Target::Global,
|
||||
));
|
||||
}
|
||||
LapceWorkbenchCommand::CloseWindow => {
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::CloseWindow(self.window_id),
|
||||
Target::Auto,
|
||||
));
|
||||
}
|
||||
LapceWorkbenchCommand::ReloadWindow => {
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
|
|
|
@ -498,6 +498,15 @@ fn command(
|
|||
ctx.new_window(desc);
|
||||
return druid::Handled::Yes;
|
||||
}
|
||||
LapceUICommand::CloseWindow(window_id) => {
|
||||
ctx.submit_command(Command::new(
|
||||
druid::commands::CLOSE_WINDOW,
|
||||
(),
|
||||
Target::Window(*window_id),
|
||||
));
|
||||
let _ = data.db.save_app(data);
|
||||
return druid::Handled::Yes;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -829,7 +829,11 @@ pub fn window_controls(
|
|||
|
||||
commands.push((
|
||||
close_rect,
|
||||
Command::new(druid::commands::QUIT_APP, (), Target::Global),
|
||||
Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::CloseWindow(window_id),
|
||||
Target::Auto,
|
||||
),
|
||||
));
|
||||
|
||||
let hover_color = {
|
||||
|
|
Loading…
Reference in New Issue