mirror of https://github.com/lapce/lapce.git
esc on settings
This commit is contained in:
parent
36d2a854c5
commit
7a886a3093
|
@ -574,6 +574,8 @@ pub enum LapceUICommand {
|
|||
CancelPalette,
|
||||
ShowCodeActions,
|
||||
CancelCodeActions,
|
||||
Hide,
|
||||
ResignFocus,
|
||||
Focus,
|
||||
EnsureEditorTabActiveVisble,
|
||||
FocusSourceControl,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use druid::{Env, EventCtx, Modifiers, WidgetId};
|
||||
use druid::{Command, Env, EventCtx, Modifiers, Target, WidgetId};
|
||||
|
||||
use crate::{
|
||||
command::{CommandExecuted, LapceCommand},
|
||||
command::{CommandExecuted, LapceCommand, LapceUICommand, LAPCE_UI_COMMAND},
|
||||
keypress::KeyPressFocus,
|
||||
state::Mode,
|
||||
};
|
||||
|
@ -36,14 +36,18 @@ fn check_condition(&self, condition: &str) -> bool {
|
|||
|
||||
fn run_command(
|
||||
&mut self,
|
||||
_ctx: &mut EventCtx,
|
||||
ctx: &mut EventCtx,
|
||||
command: &LapceCommand,
|
||||
_count: Option<usize>,
|
||||
_mods: Modifiers,
|
||||
_env: &Env,
|
||||
) -> CommandExecuted {
|
||||
if let LapceCommand::ModalClose = command {
|
||||
self.shown = false;
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::Hide,
|
||||
Target::Widget(self.panel_widget_id),
|
||||
));
|
||||
CommandExecuted::Yes
|
||||
} else {
|
||||
CommandExecuted::No
|
||||
|
|
|
@ -143,6 +143,7 @@ fn event(
|
|||
}
|
||||
keys.push(keypress);
|
||||
ctx.request_paint();
|
||||
ctx.set_handled();
|
||||
}
|
||||
} else {
|
||||
let mut keypress = data.keypress.clone();
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
use inflector::Inflector;
|
||||
use lapce_data::{
|
||||
buffer::{Buffer, BufferContent},
|
||||
command::{CommandExecuted, LapceCommand, LapceUICommand, LAPCE_UI_COMMAND},
|
||||
command::{
|
||||
CommandExecuted, LapceCommand, LapceUICommand, LAPCE_NEW_COMMAND,
|
||||
LAPCE_UI_COMMAND,
|
||||
},
|
||||
config::{EditorConfig, LapceConfig, LapceTheme},
|
||||
data::{LapceEditorData, LapceTabData},
|
||||
keypress::KeyPressFocus,
|
||||
|
@ -114,6 +117,7 @@ fn mouse_down(
|
|||
}
|
||||
|
||||
ctx.set_handled();
|
||||
ctx.request_focus();
|
||||
if self.switcher_rect.contains(mouse_event.pos) {
|
||||
let index = ((mouse_event.pos.y - self.switcher_rect.y0)
|
||||
/ self.switcher_line_height)
|
||||
|
@ -145,7 +149,16 @@ fn event(
|
|||
if !data.settings.shown {
|
||||
return;
|
||||
}
|
||||
self.children[self.active].event(ctx, event, data, env);
|
||||
match event {
|
||||
Event::Command(cmd) if cmd.is(LAPCE_UI_COMMAND) => {}
|
||||
Event::Command(cmd) if cmd.is(LAPCE_NEW_COMMAND) => {}
|
||||
_ => {
|
||||
self.children[self.active].event(ctx, event, data, env);
|
||||
}
|
||||
}
|
||||
if ctx.is_handled() {
|
||||
return;
|
||||
}
|
||||
match event {
|
||||
Event::KeyDown(key_event) => {
|
||||
let mut keypress = data.keypress.clone();
|
||||
|
@ -181,11 +194,23 @@ fn event(
|
|||
let command = cmd.get_unchecked(LAPCE_UI_COMMAND);
|
||||
match command {
|
||||
LapceUICommand::ShowSettings => {
|
||||
ctx.request_focus();
|
||||
self.active = 0;
|
||||
}
|
||||
LapceUICommand::ShowKeybindings => {
|
||||
ctx.request_focus();
|
||||
self.active = 2;
|
||||
}
|
||||
LapceUICommand::Hide => {
|
||||
Arc::make_mut(&mut data.settings).shown = false;
|
||||
if let Some(active) = *data.main_split.active {
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::Focus,
|
||||
Target::Widget(active),
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue