Update vulnerable dependencies and migrate to Iced 0.14.

This commit is contained in:
2026-08-09 17:16:26 +02:00
parent c757314c91
commit 520e1d86ea
38 changed files with 1105 additions and 1237 deletions

View File

@@ -7,7 +7,6 @@ use iced::advanced::renderer;
use iced::advanced::text;
use iced::advanced::widget::{self, Widget};
use iced::advanced::{Clipboard, Shell};
use iced::event::Status;
use iced::keyboard;
use iced::mouse;
use iced::{Color, Element, Event, Length, Pixels, Point, Rectangle, Shadow, Size, Theme, Vector};
@@ -54,8 +53,9 @@ pub fn mono_metrics() -> &'static MonoMetrics {
buffer.set_text(
&mut font_system,
"M",
Attrs::new().family(Family::Monospace),
&Attrs::new().family(Family::Monospace),
Shaping::Advanced,
None,
);
buffer.shape_until_scroll(&mut font_system, false);
@@ -313,7 +313,7 @@ where
}
fn layout(
&self,
&mut self,
_tree: &mut widget::Tree,
_renderer: &Renderer,
limits: &layout::Limits,
@@ -350,6 +350,7 @@ where
offset: Vector::new(0.0, 3.0),
blur_radius: 14.0,
},
snap: true,
},
theme.palette().background,
);
@@ -365,6 +366,7 @@ where
},
border: iced::Border::default(),
shadow: iced::Shadow::default(),
snap: true,
},
Color::from_rgb8(0x2B, 0x2B, 0x2B),
);
@@ -465,6 +467,7 @@ where
},
border: iced::Border::default(),
shadow: iced::Shadow::default(),
snap: true,
},
SELECTION_BG,
);
@@ -489,8 +492,8 @@ where
metrics.line_height,
)),
font,
horizontal_alignment: iced::alignment::Horizontal::Right,
vertical_alignment: iced::alignment::Vertical::Top,
align_x: iced::alignment::Horizontal::Right.into(),
align_y: iced::alignment::Vertical::Top,
shaping: iced::widget::text::Shaping::Basic,
wrapping: iced::widget::text::Wrapping::None,
},
@@ -546,8 +549,8 @@ where
metrics.line_height,
)),
font,
horizontal_alignment: iced::alignment::Horizontal::Left,
vertical_alignment: iced::alignment::Vertical::Top,
align_x: iced::alignment::Horizontal::Left.into(),
align_y: iced::alignment::Vertical::Top,
shaping: iced::widget::text::Shaping::Advanced,
wrapping: iced::widget::text::Wrapping::None,
},
@@ -577,8 +580,8 @@ where
metrics.line_height,
)),
font,
horizontal_alignment: iced::alignment::Horizontal::Left,
vertical_alignment: iced::alignment::Vertical::Top,
align_x: iced::alignment::Horizontal::Left.into(),
align_y: iced::alignment::Vertical::Top,
shaping: iced::widget::text::Shaping::Advanced,
wrapping: iced::widget::text::Wrapping::None,
},
@@ -603,6 +606,7 @@ where
},
border: iced::Border::default(),
shadow: iced::Shadow::default(),
snap: true,
},
CURSOR_COLOR,
);
@@ -622,6 +626,7 @@ where
},
border: iced::Border::default(),
shadow: iced::Shadow::default(),
snap: true,
},
CURSOR_COLOR,
);
@@ -656,6 +661,7 @@ where
},
border: iced::Border::default(),
shadow: iced::Shadow::default(),
snap: true,
},
SCROLLBAR_TRACK,
);
@@ -674,6 +680,7 @@ where
..iced::Border::default()
},
shadow: iced::Shadow::default(),
snap: true,
},
if is_hover {
SCROLLBAR_THUMB_HOVER
@@ -684,17 +691,17 @@ where
}
}
fn on_event(
fn update(
&mut self,
tree: &mut widget::Tree,
event: Event,
event: &Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
_renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
) -> Status {
) {
let state = tree.state.downcast_mut::<EditorState>();
let bounds = layout.bounds();
let metrics = mono_metrics();
@@ -734,11 +741,13 @@ where
let new_scroll = (ratio * max_scroll as f32).round() as usize;
self.buffer.borrow_mut().set_scroll(new_scroll, max_scroll);
}
return Status::Captured;
shell.capture_event();
return;
}
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => {
state.scrollbar_drag = None;
return Status::Captured;
shell.capture_event();
return;
}
_ => {}
}
@@ -771,7 +780,8 @@ where
state.scrollbar_drag = Some(thumb_height / 2.0);
}
state.is_focused = true;
return Status::Captured;
shell.capture_event();
return;
}
}
@@ -811,7 +821,8 @@ where
state.last_click_col = col;
}
}
return Status::Captured;
shell.capture_event();
return;
} else {
state.is_focused = false;
}
@@ -859,7 +870,8 @@ where
buf.set_selection(anchor_line, anchor_col, clamped_line, clamped_col);
buf.set_cursor(clamped_line, clamped_col);
}
return Status::Captured;
shell.capture_event();
return;
}
}
Event::Mouse(mouse::Event::WheelScrolled { delta }) if cursor.is_over(bounds) => {
@@ -872,7 +884,8 @@ where
let total = total_visual_lines(&buf, cpl);
let max_scroll = total.saturating_sub(vis);
buf.scroll_by_clamped(lines, max_scroll);
return Status::Captured;
shell.capture_event();
return;
}
Event::Keyboard(keyboard::Event::KeyPressed {
key,
@@ -900,7 +913,7 @@ where
match key {
// Cmd+Z = undo, Cmd+Shift+Z = redo
keyboard::Key::Character(ref c) if is_cmd && c.as_str() == "z" => {
keyboard::Key::Character(c) if is_cmd && c.as_str() == "z" => {
{
let mut buf = self.buffer.borrow_mut();
if is_shift {
@@ -913,7 +926,7 @@ where
self.emit_change(shell);
}
// Cmd+Y = redo (Windows convention)
keyboard::Key::Character(ref c) if is_cmd && c.as_str() == "y" => {
keyboard::Key::Character(c) if is_cmd && c.as_str() == "y" => {
{
let mut buf = self.buffer.borrow_mut();
buf.redo();
@@ -922,18 +935,18 @@ where
self.emit_change(shell);
}
// Cmd+A = select all
keyboard::Key::Character(ref c) if is_cmd && c.as_str() == "a" => {
keyboard::Key::Character(c) if is_cmd && c.as_str() == "a" => {
self.buffer.borrow_mut().select_all();
}
// Cmd+C = copy
keyboard::Key::Character(ref c) if is_cmd && c.as_str() == "c" => {
keyboard::Key::Character(c) if is_cmd && c.as_str() == "c" => {
let text = self.buffer.borrow().selected_text();
if !text.is_empty() {
clipboard.write(iced::advanced::clipboard::Kind::Standard, text);
}
}
// Cmd+X = cut
keyboard::Key::Character(ref c) if is_cmd && c.as_str() == "x" => {
keyboard::Key::Character(c) if is_cmd && c.as_str() == "x" => {
let text = self.buffer.borrow().selected_text();
if !text.is_empty() {
clipboard.write(iced::advanced::clipboard::Kind::Standard, text);
@@ -942,7 +955,7 @@ where
}
}
// Cmd+V = paste
keyboard::Key::Character(ref c) if is_cmd && c.as_str() == "v" => {
keyboard::Key::Character(c) if is_cmd && c.as_str() == "v" => {
if let Some(text) =
clipboard.read(iced::advanced::clipboard::Kind::Standard)
{
@@ -954,7 +967,7 @@ where
}
}
// Cmd+S = save
keyboard::Key::Character(ref c) if is_cmd && c.as_str() == "s" => {
keyboard::Key::Character(c) if is_cmd && c.as_str() == "s" => {
if let Some(ref on_change) = self.on_change {
shell.publish((on_change)(EditorMessage::SaveRequested));
}
@@ -1083,13 +1096,13 @@ where
}
self.emit_change(shell);
}
_ => return Status::Ignored,
_ => return,
}
return Status::Captured;
shell.capture_event();
return;
}
_ => {}
}
Status::Ignored
}
}