Run cargo fmt and fix lints
This commit is contained in:
parent
7db5256b72
commit
0c6d4eb23f
3 changed files with 17 additions and 23 deletions
|
|
@ -338,7 +338,7 @@ where
|
||||||
let text_bounds = bounds.shrink(self.padding);
|
let text_bounds = bounds.shrink(self.padding);
|
||||||
let translation = text_bounds.position() - Point::ORIGIN;
|
let translation = text_bounds.position() - Point::ORIGIN;
|
||||||
|
|
||||||
if let Some(_) = state.focus.as_ref() {
|
if state.focus.is_some() {
|
||||||
let position = match internal.editor.cursor() {
|
let position = match internal.editor.cursor() {
|
||||||
Cursor::Caret(position) => position,
|
Cursor::Caret(position) => position,
|
||||||
Cursor::Selection(ranges) => ranges
|
Cursor::Selection(ranges) => ranges
|
||||||
|
|
@ -872,10 +872,11 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
shell.update_caret_info(if state.is_focused() {
|
shell.update_caret_info(if state.is_focused() {
|
||||||
let rect = self
|
let rect =
|
||||||
.caret_rect(tree, renderer, layout)
|
self.caret_rect(tree, renderer, layout).unwrap_or_default();
|
||||||
.unwrap_or(Rectangle::default());
|
|
||||||
let bottom_left = Point::new(rect.x, rect.y + rect.height);
|
let bottom_left = Point::new(rect.x, rect.y + rect.height);
|
||||||
|
|
||||||
Some(CaretInfo {
|
Some(CaretInfo {
|
||||||
position: bottom_left,
|
position: bottom_left,
|
||||||
input_method_allowed: true,
|
input_method_allowed: true,
|
||||||
|
|
|
||||||
|
|
@ -407,18 +407,15 @@ where
|
||||||
let mut children_layout = layout.children();
|
let mut children_layout = layout.children();
|
||||||
let text_bounds = children_layout.next().unwrap().bounds();
|
let text_bounds = children_layout.next().unwrap().bounds();
|
||||||
|
|
||||||
if let Some(_) = state
|
if state
|
||||||
.is_focused
|
.is_focused
|
||||||
.as_ref()
|
.is_some_and(|focus| focus.is_window_focused)
|
||||||
.filter(|focus| focus.is_window_focused)
|
|
||||||
{
|
{
|
||||||
let caret_index = match state.cursor.state(value) {
|
let caret_index = match state.cursor.state(value) {
|
||||||
cursor::State::Index(position) => position,
|
cursor::State::Index(position) => position,
|
||||||
cursor::State::Selection { start, end } => {
|
cursor::State::Selection { start, end } => start.min(end),
|
||||||
let left = start.min(end);
|
|
||||||
left
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let text = state.value.raw();
|
let text = state.value.raw();
|
||||||
let (caret_x, offset) = measure_cursor_and_scroll_offset(
|
let (caret_x, offset) = measure_cursor_and_scroll_offset(
|
||||||
text,
|
text,
|
||||||
|
|
@ -433,6 +430,7 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
let x = (text_bounds.x + caret_x).floor();
|
let x = (text_bounds.x + caret_x).floor();
|
||||||
|
|
||||||
Some(Rectangle {
|
Some(Rectangle {
|
||||||
x: (alignment_offset - offset) + x,
|
x: (alignment_offset - offset) + x,
|
||||||
y: text_bounds.y,
|
y: text_bounds.y,
|
||||||
|
|
@ -1250,7 +1248,7 @@ where
|
||||||
|
|
||||||
state.keyboard_modifiers = *modifiers;
|
state.keyboard_modifiers = *modifiers;
|
||||||
}
|
}
|
||||||
Event::InputMethod(input_method::Event::Commit(string)) => {
|
Event::InputMethod(input_method::Event::Commit(text)) => {
|
||||||
let state = state::<Renderer>(tree);
|
let state = state::<Renderer>(tree);
|
||||||
|
|
||||||
if let Some(focus) = &mut state.is_focused {
|
if let Some(focus) = &mut state.is_focused {
|
||||||
|
|
@ -1258,21 +1256,18 @@ where
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
state.is_pasting = None;
|
|
||||||
|
|
||||||
let mut editor =
|
let mut editor =
|
||||||
Editor::new(&mut self.value, &mut state.cursor);
|
Editor::new(&mut self.value, &mut state.cursor);
|
||||||
|
editor.paste(Value::new(text));
|
||||||
|
|
||||||
editor.paste(Value::new(&string));
|
focus.updated_at = Instant::now();
|
||||||
|
state.is_pasting = None;
|
||||||
|
|
||||||
let message = (on_input)(editor.contents());
|
let message = (on_input)(editor.contents());
|
||||||
shell.publish(message);
|
shell.publish(message);
|
||||||
|
shell.capture_event();
|
||||||
focus.updated_at = Instant::now();
|
|
||||||
|
|
||||||
update_cache(state, &self.value);
|
update_cache(state, &self.value);
|
||||||
|
|
||||||
shell.capture_event();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Window(window::Event::Unfocused) => {
|
Event::Window(window::Event::Unfocused) => {
|
||||||
|
|
|
||||||
|
|
@ -186,11 +186,9 @@ where
|
||||||
WindowEvent::ModifiersChanged(new_modifiers) => {
|
WindowEvent::ModifiersChanged(new_modifiers) => {
|
||||||
self.modifiers = new_modifiers.state();
|
self.modifiers = new_modifiers.state();
|
||||||
}
|
}
|
||||||
WindowEvent::Ime(ime) => {
|
WindowEvent::Ime(Ime::Preedit(text, _)) => {
|
||||||
if let Ime::Preedit(text, _) = ime {
|
|
||||||
self.preedit = text.clone();
|
self.preedit = text.clone();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
event:
|
event:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue