mirror of https://github.com/lapce/lapce.git
Fix rebase mistake
This commit is contained in:
parent
79aafd6c9f
commit
b7e49d330b
|
@ -727,12 +727,6 @@ pub fn value(
|
||||||
fn get_key(&self) -> String {
|
fn get_key(&self) -> String {
|
||||||
format!("{}.{}", self.kind, self.name.to_kebab_case())
|
format!("{}.{}", self.kind, self.name.to_kebab_case())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_value(&mut self, ctx: &mut EventCtx, value: serde_json::Value) {
|
|
||||||
self.value = value;
|
|
||||||
self.value_changed = true;
|
|
||||||
self.last_idle_timer = ctx.request_timer(Duration::from_millis(300));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeyPressFocus for LapceSettingsItemKeypress {
|
impl KeyPressFocus for LapceSettingsItemKeypress {
|
||||||
|
@ -793,35 +787,13 @@ fn event(
|
||||||
) {
|
) {
|
||||||
if let Some(input) = self.input_widget.as_mut() {
|
if let Some(input) = self.input_widget.as_mut() {
|
||||||
match event {
|
match event {
|
||||||
Event::KeyDown(key_event) => {
|
|
||||||
let mut f = LapceSettingsItemKeypress {
|
|
||||||
input: self.input.clone(), // Clone so we can check for change
|
|
||||||
cursor: self.cursor,
|
|
||||||
};
|
|
||||||
let mut_keypress = Arc::make_mut(&mut data.keypress);
|
|
||||||
mut_keypress.key_down(ctx, key_event, &mut f, env);
|
|
||||||
self.cursor = f.cursor;
|
|
||||||
if f.input != self.input {
|
|
||||||
self.input = f.input;
|
|
||||||
let new_value = match &self.value {
|
|
||||||
serde_json::Value::Number(_n) => {
|
|
||||||
if let Ok(new_n) = self.input.parse::<i64>() {
|
|
||||||
serde_json::json!(new_n)
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
serde_json::Value::String(_s) => {
|
|
||||||
serde_json::json!(self.input)
|
|
||||||
}
|
|
||||||
_ => return,
|
|
||||||
};
|
|
||||||
self.update_value(ctx, new_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Event::Wheel(_) => {}
|
Event::Wheel(_) => {}
|
||||||
|
_ => {
|
||||||
|
input.event(ctx, event, data, env);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match event {
|
||||||
Event::MouseDown(mouse_event) => {
|
Event::MouseDown(mouse_event) => {
|
||||||
// ctx.request_focus();
|
// ctx.request_focus();
|
||||||
let input = self.input.clone();
|
let input = self.input.clone();
|
||||||
|
@ -832,9 +804,7 @@ fn event(
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(
|
.text_color(
|
||||||
data.config
|
data.config
|
||||||
.get_color_unchecked(
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
LapceTheme::EDITOR_FOREGROUND,
|
|
||||||
)
|
|
||||||
.clone(),
|
.clone(),
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
@ -856,8 +826,7 @@ fn event(
|
||||||
self.cursor = hit.idx;
|
self.cursor = hit.idx;
|
||||||
}
|
}
|
||||||
} else if let serde_json::Value::Bool(checked) = self.value {
|
} else if let serde_json::Value::Bool(checked) = self.value {
|
||||||
let rect =
|
let rect = Size::new(self.checkbox_width, self.checkbox_width)
|
||||||
Size::new(self.checkbox_width, self.checkbox_width)
|
|
||||||
.to_rect()
|
.to_rect()
|
||||||
.with_origin(Point::new(
|
.with_origin(Point::new(
|
||||||
0.0,
|
0.0,
|
||||||
|
@ -865,7 +834,10 @@ fn event(
|
||||||
+ self.padding * 3.0,
|
+ self.padding * 3.0,
|
||||||
));
|
));
|
||||||
if rect.contains(mouse_event.pos) {
|
if rect.contains(mouse_event.pos) {
|
||||||
self.update_value(ctx, serde_json::json!(!checked));
|
self.value = serde_json::json!(!checked);
|
||||||
|
self.value_changed = true;
|
||||||
|
self.last_idle_timer =
|
||||||
|
ctx.request_timer(Duration::from_millis(300));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,10 +864,8 @@ fn event(
|
||||||
Target::Widget(data.id),
|
Target::Widget(data.id),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
input.event(ctx, event, data, env);
|
_ => {}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,14 +928,11 @@ fn update(
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
ctx.submit_command(Command::new(
|
|
||||||
LAPCE_UI_COMMAND,
|
self.value = new_value;
|
||||||
LapceUICommand::UpdateSettingsFile(
|
self.value_changed = true;
|
||||||
self.get_key(),
|
self.last_idle_timer =
|
||||||
new_value,
|
ctx.request_timer(Duration::from_millis(300));
|
||||||
),
|
|
||||||
Target::Widget(data.id),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue