mirror of https://github.com/lapce/lapce.git
fix event
This commit is contained in:
parent
386ff068d5
commit
803a646496
|
@ -25,6 +25,7 @@
|
||||||
editor::LapceEditorBufferData,
|
editor::LapceEditorBufferData,
|
||||||
keypress::KeyPressFocus,
|
keypress::KeyPressFocus,
|
||||||
panel::PanelPosition,
|
panel::PanelPosition,
|
||||||
|
settings::SettingsValueKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -517,10 +518,6 @@ fn event(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let editor = data.main_split.editors.get(&self.view_id).unwrap().clone();
|
|
||||||
let mut editor_data = data.editor_view_content(self.view_id);
|
|
||||||
let doc = editor_data.doc.clone();
|
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::MouseDown(mouse_event) => match mouse_event.button {
|
Event::MouseDown(mouse_event) => match mouse_event.button {
|
||||||
druid::MouseButton::Left => {
|
druid::MouseButton::Left => {
|
||||||
|
@ -535,6 +532,7 @@ fn event(
|
||||||
let command = cmd.get_unchecked(LAPCE_UI_COMMAND);
|
let command = cmd.get_unchecked(LAPCE_UI_COMMAND);
|
||||||
if let LapceUICommand::Focus = command {
|
if let LapceUICommand::Focus = command {
|
||||||
self.request_focus(ctx, data, true);
|
self.request_focus(ctx, data, true);
|
||||||
|
let editor_data = data.editor_view_content(self.view_id);
|
||||||
self.ensure_cursor_visible(
|
self.ensure_cursor_visible(
|
||||||
ctx,
|
ctx,
|
||||||
&editor_data,
|
&editor_data,
|
||||||
|
@ -556,19 +554,39 @@ fn event(
|
||||||
}
|
}
|
||||||
Event::Timer(id) if self.last_idle_timer == *id => {
|
Event::Timer(id) if self.last_idle_timer == *id => {
|
||||||
ctx.set_handled();
|
ctx.set_handled();
|
||||||
if let BufferContent::SettingsValue(name, _) =
|
let editor_data = data.editor_view_content(self.view_id);
|
||||||
|
if let BufferContent::SettingsValue(name, kind) =
|
||||||
&editor_data.editor.content
|
&editor_data.editor.content
|
||||||
{
|
{
|
||||||
// ctx.submit_command(Command::new(
|
let content = editor_data.doc.buffer().text().to_string();
|
||||||
// LAPCE_UI_COMMAND,
|
let new_value = match kind {
|
||||||
// LapceUICommand::UpdateSettingsFile(
|
SettingsValueKind::String => {
|
||||||
// name.to_string(),
|
Some(serde_json::json!(content))
|
||||||
// editor_data.doc.buffer().text().to_string(),
|
}
|
||||||
// ),
|
SettingsValueKind::Number => {
|
||||||
// Target::Widget(data.id),
|
content.parse::<i64>().ok().map(|n| serde_json::json!(n))
|
||||||
// ));
|
}
|
||||||
|
SettingsValueKind::Bool => None,
|
||||||
|
};
|
||||||
|
if let Some(new_value) = new_value {
|
||||||
|
ctx.submit_command(Command::new(
|
||||||
|
LAPCE_UI_COMMAND,
|
||||||
|
LapceUICommand::UpdateSettingsFile(
|
||||||
|
name.to_string(),
|
||||||
|
new_value,
|
||||||
|
),
|
||||||
|
Target::Widget(data.id),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
let editor = data.main_split.editors.get(&self.view_id).unwrap().clone();
|
||||||
|
let mut editor_data = data.editor_view_content(self.view_id);
|
||||||
|
let doc = editor_data.doc.clone();
|
||||||
|
match event {
|
||||||
Event::KeyDown(key_event) => {
|
Event::KeyDown(key_event) => {
|
||||||
ctx.set_handled();
|
ctx.set_handled();
|
||||||
let mut keypress = data.keypress.clone();
|
let mut keypress = data.keypress.clone();
|
||||||
|
|
Loading…
Reference in New Issue